Skip to content

Commit e8ced33

Browse files
committed
swift-symbolgraph-extract: Infer target triple.
Infer the `-target` argument to `swift-synthesize-interface` to be the host triple when unspecified instead of emitting an error.
1 parent 3ffb218 commit e8ced33

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/DriverTool/swift_symbolgraph_extract_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
8383
if (auto *A = ParsedArgs.getLastArg(OPT_target)) {
8484
Target = llvm::Triple(A->getValue());
8585
} else {
86-
Diags.diagnose(SourceLoc(), diag::error_option_required, "-target");
87-
return EXIT_FAILURE;
86+
Target = llvm::Triple(llvm::sys::getDefaultTargetTriple());
8887
}
8988

9089
std::string OutputDir;

test/SymbolGraph/Relationships/MemberOf/Basic.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/Output)
23
// RUN: %target-build-swift %s -module-name Basic -emit-module -emit-module-path %t/
3-
// RUN: %target-swift-symbolgraph-extract -module-name Basic -I %t -pretty-print -output-dir %t
4-
// RUN: %FileCheck %s --input-file %t/Basic.symbols.json
4+
// RUN: %target-swift-symbolgraph-extract -module-name Basic -I %t -pretty-print -output-dir %t/Output
5+
// RUN: %FileCheck %s --input-file %t/Output/Basic.symbols.json
6+
7+
// Verify that -target can be inferred
8+
// RUN: %empty-directory(%t/Output)
9+
// RUN: %swift-symbolgraph-extract -module-name Basic -I %t -pretty-print -output-dir %t/Output
10+
// RUN: %FileCheck %s --input-file %t/Output/Basic.symbols.json
11+
512
public struct S {
613
public var x: Int
714
}

test/lit.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ config.substitutions.append( ('%swift-path', config.swift) )
755755
config.substitutions.append( ('%swift-plugin-server', config.swift_plugin_server) )
756756
config.substitutions.append( ('%swift-parse-test', config.swift_parse_test) )
757757
config.substitutions.append( ('%swift-scan-test', config.swift_scan_test) )
758+
config.substitutions.append( ('%swift-symbolgraph-extract', config.swift_symbolgraph_extract) )
758759
config.substitutions.append( ('%swift-synthesize-interface', config.swift_synthesize_interface) )
759760
config.substitutions.append( ('%validate-json', f"{config.python} -m json.tool") )
760761

0 commit comments

Comments
 (0)