File tree 4 files changed +41
-0
lines changed
4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ void my_native_c ();
Original file line number Diff line number Diff line change
1
+ framework module NativeDep [extern_c] {
2
+ umbrella header "NativeDep.h"
3
+ export *
4
+ }
Original file line number Diff line number Diff line change
1
+ // REQUIRES: objc_interop, OS=macosx
2
+ // RUN: %empty-directory(%t)
3
+ // RUN: mkdir -p %t/NativeDep.framework/Headers %t/NativeDep.framework/Modules %t/cache
4
+ // RUN: cp %S/Inputs/module.modulemap %t/NativeDep.framework/Modules
5
+ // RUN: cp %S/Inputs/NativeDep.h %t/NativeDep.framework/Headers
6
+
7
+ // RUN: %target-swift-frontend %s -emit-module -emit-module-interface-path %t/MyModule.swiftinterface -emit-module-path %t/MyModule.swiftmodule -F %t -enable-library-evolution -module-cache-path %t/cache -module-name MyModule -swift-version 5
8
+
9
+ /// Check that both swiftmodule and swiftinterface can be used as input.
10
+ // RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftmodule -module-name MyModule -module-cache-path %t/cache -F %t | %FileCheck %s
11
+ // RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t/cache -F %t | %FileCheck %s
12
+
13
+ /// Check that if a dependency is missing, error message is emitted and not crashed.
14
+ // RUN: rm -rf %t/NativeDep.framework
15
+ // RUN: not %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftmodule -module-name MyModule -module-cache-path %t/cache 2>&1 | %FileCheck %s --check-prefix=CHECK-ERROR
16
+
17
+ import NativeDep
18
+
19
+ public func callNative ( )
20
+ {
21
+ my_native_c ( )
22
+ }
23
+
24
+ // CHECK: "target": "x86_64-apple-macosx10.9",
25
+ // CHECK-NEXT: "globals": [
26
+ // CHECK-NEXT: {
27
+ // CHECK-NEXT: "name": "_$s8MyModule10callNativeyyF",
28
+ // CHECK-NEXT: "access": "public",
29
+
30
+ // CHECK-ERROR: error: missing required module 'NativeDep'
Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ class SwiftAPIExtractInvocation {
103
103
}
104
104
}
105
105
106
+ Invocation.getLangOptions ().EnableModuleLoadingRemarks = true ;
107
+
106
108
if (auto *A = ParsedArgs.getLastArg (OPT_sdk))
107
109
Invocation.setSDKPath (A->getValue ());
108
110
@@ -207,6 +209,10 @@ class SwiftAPIExtractInvocation {
207
209
return 1 ;
208
210
}
209
211
212
+ // If there are errors emitted when loading module, exit with error.
213
+ if (Instance.getASTContext ().hadError ())
214
+ return 1 ;
215
+
210
216
if (OutputFilename == " -" ) {
211
217
writeAPIJSONFile (M, llvm::outs (), PrettyPrint);
212
218
return 0 ;
You can’t perform that action at this time.
0 commit comments