Skip to content

Usability fixes for swift-api-dump #17527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/IDE/print_module_missing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Make sure we emit some kind of error message when we cannot find the module
// to print.

// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=NoSuchModule -source-filename=%s 2> %t.err
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING < %t.err

// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=Swift.NoSuchSubModule -source-filename=%s 2> %t.suberr
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING-SUBMODULE < %t.suberr

// CHECK-MISSING: 'NoSuchModule'
// CHECK-MISSING-SUBMODULE: 'Swift.NoSuchSubModule'
4 changes: 4 additions & 0 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
// Get the (sub)module to print.
auto *M = getModuleByFullName(Context, ModuleToPrint);
if (!M) {
llvm::errs() << "error: could not find module '" << ModuleToPrint
<< "'\n";
ExitCode = 1;
continue;
}
Expand All @@ -1873,6 +1875,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
if (ModuleName.size() > 1) {
M = getModuleByFullName(Context, ModuleName[0]);
if (!M) {
llvm::errs() << "error: could not find module '" << ModuleName[0]
<< "'\n";
ExitCode = 1;
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions utils/swift-api-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# (Objective-)C APIs, any API notes added on top of those APIs, and the
# Clang importer itself. One can execute it to dump the API of a given
# module within a particular SDK, e.g., UIKit from the iOS SDK as seen in
# Swift 3 compatibility mode:
# Swift 4 compatibility mode:
#
# /path/to/bin/dir/swift-api-dump.py -swift-version 3 -o output-dir \
# /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir \
# -m UIKit -s iphoneos
#
# The "-m" argument can be omitted, in which case the script will collect
# all of the frameworks in the named SDK(s) and dump their APIs.
#
# One can supply multiple SDKs, written as a list. For example, to
# dump the API for all frameworks across macOS, iOS, watchOS, and tvOS,
# in Swift 4, use:
# in Swift 4.2, use:
#
# /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir \
# /path/to/bin/dir/swift-api-dump.py -swift-version 4.2 -o output-dir \
# -s macosx iphoneos watchos appletvos
#

Expand Down Expand Up @@ -102,7 +102,7 @@ def create_parser():
parser.add_argument('--enable-infer-import-as-member', action='store_true',
help='Infer when a global could be imported as a ' +
'member.')
parser.add_argument('-swift-version', type=int, metavar='N',
parser.add_argument('-swift-version', metavar='N',
help='the Swift version to use')
parser.add_argument('-show-overlay', action='store_true',
help='Show overlay API in addition to Objective-C ' +
Expand Down Expand Up @@ -326,7 +326,7 @@ def main():
if args.enable_infer_import_as_member:
extra_args = extra_args + ['-enable-infer-import-as-member']
if args.swift_version:
extra_args = extra_args + ['-swift-version', '%d' % args.swift_version]
extra_args = extra_args + ['-swift-version', '%s' % args.swift_version]

# Create a .swift file we can feed into swift-ide-test
subprocess.call(['touch', source_filename])
Expand Down