Skip to content

Commit b2c1035

Browse files
committed
swift_build_sdk_interfaces.py: builds compiled modules from an SDK
...by crawling it and looking for module interfaces. This is the tool Apple is using for the "prebuilt-modules" directory in the toolchain in Xcode.app, which avoids even a first-use cost for importing modules from Apple SDKs as long as the SDKs haven't changed. We've been landing changes to support this model on the compiler side, so the tool to generate the "prebuilt" compiled modules belongs in the compiler repo too. (In theory this could be used with open-source toolchains as well, or for alternate SDKs.)
1 parent a22b4f7 commit b2c1035

File tree

40 files changed

+801
-0
lines changed

40 files changed

+801
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
3+
4+
garbage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -parse-stdlib
3+
4+
garbage

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/x86_64.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64-apple-ios-macabi.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64-apple-macos.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/iOSSupport/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/x86_64.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/System/iOSSupport/usr/lib/swift/Foo.swiftmodule/x86_64.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/iosmac-sdk/MacOSX.sdk/usr/lib/swift/Foo.swiftmodule/x86_64.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/mock-sdk/System/Library/Frameworks/BinaryOnly_BAD.framework/Modules/BinaryOnly_BAD.swiftmodule/xyz.swiftmodule

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/mock-sdk/System/Library/Frameworks/FlatInterface_BAD.framework/Modules/FlatInterface_BAD.swiftinterface

Whitespace-only changes.

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/mock-sdk/System/Library/Frameworks/FlatModule_BAD.framework/Modules/FlatModule_BAD.swiftmodule

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct SomeCStruct {
2+
int value;
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Platform {
2+
header "Platform.h"
3+
export *
4+
}

test/ParseableInterface/swift_build_sdk_interfaces/Inputs/system-dependencies-sdk/usr/lib/swift/Swifty.swiftmodule/dummy-file-so-git-includes-this-otherwise-empty-directory

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
3+
4+
garbage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
3+
4+
garbage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -parse-stdlib
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
3+
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
4+
5+
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Normal
6+
// RUN: echo 'public func flat() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Flat.swiftinterface -emit-module -o /dev/null -module-name Flat
7+
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name FMWK
8+
9+
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -v -o %t/prebuilt -check-only
10+
// RUN: ls %t/prebuilt | %FileCheck %s
11+
// CHECK-DAG: Normal.swiftmodule
12+
// CHECK-DAG: Flat.swiftmodule
13+
// CHECK-DAG: FMWK.swiftmodule
14+
15+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
16+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
17+
18+
// Touch a file in the SDK (to make it look like it changed) and try again.
19+
// In -check-only mode, this should force a rebuild.
20+
// RUN: rm -rf %t/MCP
21+
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
22+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
23+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
24+
25+
import Normal
26+
import Flat
27+
import FMWK
28+
29+
func test() {
30+
normal()
31+
flat()
32+
fmwk()
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/mock-sdk/ -o %t/output -debug-crash-compiler 2>&1 | %FileCheck %s
2+
3+
CHECK: Program arguments:
4+
CHECK-SAME: -debug-crash-immediately
5+
CHECK-SAME: {{.+}}.swiftinterface
6+
7+
REQUIRES: asserts
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
3+
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
4+
5+
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Normal
6+
// RUN: echo 'public func flat() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Flat.swiftinterface -emit-module -o /dev/null -module-name Flat
7+
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name FMWK
8+
9+
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -v -o %t/prebuilt
10+
// RUN: ls %t/prebuilt | %FileCheck %s
11+
// CHECK-DAG: Normal.swiftmodule
12+
// CHECK-DAG: Flat.swiftmodule
13+
// CHECK-DAG: FMWK.swiftmodule
14+
15+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
16+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
17+
18+
// Touch a file in the SDK (to make it look like it changed) and try again.
19+
// This should still be able to use the prebuilt modules because they track
20+
// content hashes, not just size+mtime.
21+
// RUN: rm -rf %t/MCP
22+
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
23+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
24+
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
25+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
26+
27+
// CHECK-CACHE-DAG: Normal-{{.+}}.swiftmodule
28+
// CHECK-CACHE-DAG: Flat-{{.+}}.swiftmodule
29+
// CHECK-CACHE-DAG: FMWK-{{.+}}.swiftmodule
30+
31+
// Actually change a file in the SDK, to check that we're tracking dependencies
32+
// at all.
33+
// RUN: rm -rf %t/MCP
34+
// RUN: echo "public func another()" >> %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
35+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
36+
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
37+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
38+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
39+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/FMWK-*.swiftmodule
40+
41+
// Without the prebuilt cache everything should still work; it'll just take time
42+
// because we have to build the interfaces.
43+
// RUN: rm -rf %t/MCP
44+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
45+
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
46+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
47+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Flat-*.swiftmodule
48+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/FMWK-*.swiftmodule
49+
50+
51+
import Normal
52+
import Flat
53+
import FMWK
54+
55+
func test() {
56+
normal()
57+
flat()
58+
fmwk()
59+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RUN: not %swift_build_sdk_interfaces 2>&1 | %FileCheck -check-prefix NO-OUTPUT %s
2+
NO-OUTPUT: argument -o is required
3+
4+
RUN: not env -u SDKROOT %swift_build_sdk_interfaces -o %t 2>&1 | %FileCheck -check-prefix NO-SDK %s
5+
NO-SDK: SDKROOT must be set
6+
7+
RUN: not %swift_build_sdk_interfaces -o %t -sdk %S/nonexistent 2>&1 | %FileCheck -check-prefix BAD-SDK %s
8+
BAD-SDK: invalid SDK: {{.+[/\\]nonexistent$}}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/mock-sdk/ -v -n -o %t/output > %t.txt
2+
RUN: %FileCheck %s < %t.txt
3+
RUN: %FileCheck -check-prefix NEGATIVE %s < %t.txt
4+
5+
CHECK-DAG: System/Library/Frameworks/Simple.framework/Modules/Simple.swiftmodule/xyz.swiftinterface -o {{.+}}output/Simple.swiftmodule/xyz.swiftmodule
6+
CHECK-DAG: usr/lib/swift/Flat.swiftinterface -o {{.+}}output/Flat.swiftmodule
7+
CHECK-DAG: usr/lib/swift/Normal.swiftmodule/xyz.swiftinterface -o {{.+}}output/Normal.swiftmodule/xyz.swiftmodule
8+
CHECK-DAG: System/iOSSupport/System/Library/Frameworks/Simple.framework/Modules/Simple.swiftmodule/xyzzy.swiftinterface -o {{.+}}output/Simple.swiftmodule/xyzzy.swiftmodule
9+
CHECK-DAG: System/iOSSupport/usr/lib/swift/Caramel.swiftmodule/xyz.swiftinterface -o {{.+}}output/Caramel.swiftmodule/xyz.swiftmodule
10+
11+
NEGATIVE-NOT: BAD
12+
13+
RUN: env SDKROOT=%S/Inputs/mock-sdk/ %swift_build_sdk_interfaces -v -n -o %t/output > %t.txt
14+
RUN: %FileCheck %s < %t.txt
15+
RUN: %FileCheck -check-prefix NEGATIVE %s < %t.txt
16+
17+
# Make sure the stdlib is processed first.
18+
RUN: %empty-directory(%t)
19+
RUN: cp -r %S/Inputs/mock-sdk %t/sdk
20+
RUN: mkdir %t/sdk/usr/lib/swift/Swift.swiftmodule
21+
RUN: touch %t/sdk/usr/lib/swift/Swift.swiftmodule/abc.swiftinterface
22+
RUN: touch %t/sdk/usr/lib/swift/Swift.swiftmodule/def.swiftinterface
23+
RUN: %swift_build_sdk_interfaces -sdk %t/sdk -v -n -o %t/output | %FileCheck -check-prefix CHECK-WITH-STDLIB %s
24+
25+
CHECK-WITH-STDLIB-NOT: .swiftinterface -o
26+
CHECK-WITH-STDLIB: Swift.swiftmodule/{{abc|def}}.swiftinterface -o
27+
CHECK-WITH-STDLIB-NOT: .swiftinterface -o
28+
CHECK-WITH-STDLIB: Swift.swiftmodule/{{abc|def}}.swiftinterface -o
29+
CHECK-WITH-STDLIB: .swiftinterface -o
30+
31+
# ...unless we pass -skip-stdlib.
32+
RUN: %swift_build_sdk_interfaces -sdk %t/sdk -v -n -o %t/output -skip-stdlib > %t.txt
33+
RUN: %FileCheck -check-prefix CHECK-SKIP-STDLIB %s < %t.txt
34+
RUN: %FileCheck -check-prefix NEGATIVE-SKIP-STDLIB %s < %t.txt
35+
36+
CHECK-SKIP-STDLIB: .swiftinterface -o
37+
NEGATIVE-SKIP-STDLIB-NOT: Swift.swiftmodule
38+
39+
# Check custom searching based on positional arguments.
40+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/mock-sdk/ -v -n -o %t/output System/Library/PrivateFrameworks > %t.txt
41+
RUN: %FileCheck -check-prefix CHECK-CUSTOM-PATHS %s < %t.txt
42+
RUN: %FileCheck -check-prefix NEGATIVE-CUSTOM-PATHS %s < %t.txt
43+
44+
CHECK-CUSTOM-PATHS-DAG: System/Library/PrivateFrameworks/PrivateSimple.framework/Modules/PrivateSimple.swiftmodule/xyz.swiftinterface -o {{.+}}output/PrivateSimple.swiftmodule/xyz.swiftmodule
45+
CHECK-CUSTOM-PATHS-DAG: usr/lib/swift/Flat.swiftinterface -o {{.+}}output/Flat.swiftmodule
46+
CHECK-CUSTOM-PATHS-DAG: usr/lib/swift/Normal.swiftmodule/xyz.swiftinterface -o {{.+}}output/Normal.swiftmodule/xyz.swiftmodule
47+
CHECK-CUSTOM-PATHS-DAG: System/iOSSupport/usr/lib/swift/Caramel.swiftmodule/xyz.swiftinterface -o {{.+}}output/Caramel.swiftmodule/xyz.swiftmodule
48+
NEGATIVE-CUSTOM-PATHS-NOT: System/Library/Frameworks/
49+
50+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/mock-sdk/ -v -n -o %t/output System/Library/Frameworks System/Library/PrivateFrameworks > %t.txt
51+
RUN: %FileCheck -check-prefix CHECK-CUSTOM-PATHS -check-prefix CHECK-NORMAL-PATHS %s < %t.txt
52+
RUN: %FileCheck -check-prefix NEGATIVE %s < %t.txt
53+
54+
CHECK-NORMAL-PATHS-DAG: System/Library/Frameworks/Simple.framework/Modules/Simple.swiftmodule/xyz.swiftinterface -o {{.+}}output/Simple.swiftmodule/xyz.swiftmodule
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -v -o %t/output | %FileCheck %s
2+
3+
CHECK-DAG: # (FAIL) {{.+}}/Bad.swiftinterface
4+
CHECK-DAG: # (PASS) {{.+}}/Good.swiftinterface
5+
6+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -v -o %t/output -ignore-non-stdlib-failures | %FileCheck -check-prefix=CHECK-IGNORING-FAILURES %s
7+
8+
CHECK-IGNORING-FAILURES-DAG: # (XFAIL) {{.+}}/Bad.swiftinterface
9+
CHECK-IGNORING-FAILURES-DAG: # (UPASS) {{.+}}/Good.swiftinterface
10+
11+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/broken-stdlib-sdk/ -v -o %t/output | %FileCheck -check-prefix CHECK-BROKEN-STDLIB %s
12+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/broken-stdlib-sdk/ -v -o %t/output -ignore-non-stdlib-failures | %FileCheck -check-prefix CHECK-BROKEN-STDLIB %s
13+
14+
CHECK-BROKEN-STDLIB: # (FAIL) {{.+}}/Swift.swiftinterface
15+
CHECK-BROKEN-STDLIB-NOT: {{^}}#
16+
17+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/broken-stdlib-sdk/ -v -o %t/output -skip-stdlib | %FileCheck %s
18+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/broken-stdlib-sdk/ -v -o %t/output -skip-stdlib -ignore-non-stdlib-failures | %FileCheck -check-prefix=CHECK-IGNORING-FAILURES %s
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/iosmac-sdk/MacOSX.sdk/ -Fsystem-iosmac SECRET_SEARCH_PATH -v -n -o %t/output > %t.txt
2+
RUN: %FileCheck %s < %t.txt
3+
RUN: %FileCheck -check-prefix NEGATIVE %s < %t.txt
4+
5+
CHECK-DAG: MacOSX.sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/x86_64.swiftinterface -o {{.+}}/output/FMWK.swiftmodule/x86_64-apple-macos.swiftmodule
6+
CHECK-DAG: -Fsystem SECRET_SEARCH_PATH -Fsystem {{.+}}MacOSX.sdk/System/iOSSupport/System/Library/Frameworks {{.+}}MacOSX.sdk/System/iOSSupport/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/x86_64.swiftinterface -o {{.+}}/output/FMWK.swiftmodule/x86_64-apple-ios-macabi.swiftmodule
7+
CHECK-DAG: MacOSX.sdk/usr/lib/swift/Foo.swiftmodule/x86_64.swiftinterface -o {{.+}}output/Foo.swiftmodule/x86_64-apple-macos.swiftmodule
8+
CHECK-DAG: -Fsystem SECRET_SEARCH_PATH -Fsystem {{.+}}MacOSX.sdk/System/iOSSupport/System/Library/Frameworks {{.+}}MacOSX.sdk/System/iOSSupport/usr/lib/swift/Foo.swiftmodule/x86_64.swiftinterface -o {{.+}}output/Foo.swiftmodule/x86_64-apple-ios-macabi.swiftmodule
9+
CHECK-DAG: MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64.swiftinterface -o {{.+}}/output/Zippered.swiftmodule/x86_64-apple-macos.swiftmodule
10+
CHECK-DAG: MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64-apple-macos.swiftinterface -o {{.+}}/output/Zippered.swiftmodule/x86_64-apple-macos.swiftmodule
11+
CHECK-DAG: -Fsystem SECRET_SEARCH_PATH -Fsystem {{.+}}MacOSX.sdk/System/iOSSupport/System/Library/Frameworks {{.+}}MacOSX.sdk/System/Library/Frameworks/Zippered.framework/Modules/Zippered.swiftmodule/x86_64-apple-ios-macabi.swiftinterface -o {{.+}}/output/Zippered.swiftmodule/x86_64-apple-ios-macabi.swiftmodule
12+
13+
NEGATIVE-NOT: iOSSupport{{.+}}{{macos|x86_64}}.swiftmodule
14+
NEGATIVE-NOT: SECRET_SEARCH_PATH{{.+}}{{macos|x86_64}}.swiftmodule
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Make a local copy of the substitutions.
2+
config.substitutions = list(config.substitutions)
3+
4+
swift_build_sdk_interfaces = (r'env SWIFT_EXEC=%%swiftc_driver_plain %r '
5+
r'%%utils/swift_build_sdk_interfaces.py '
6+
r'%%mcp_opt' %
7+
(sys.executable,))
8+
config.substitutions.insert(0, ('%swift_build_sdk_interfaces',
9+
swift_build_sdk_interfaces))
10+
11+
config.suffixes.add('.py')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# RUN: %swift_build_sdk_interfaces -machine-parseable-monotonic-version | \
2+
# RUN: %{python} %s
3+
4+
import sys
5+
6+
lines = list(sys.stdin)
7+
assert len(lines) == 1
8+
assert int(lines[0]) > 0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp -r %S/Inputs/system-dependencies-sdk %t/sdk
3+
// RUN: echo 'import Platform; public func usesCStruct(_: SomeCStruct?) {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Swifty.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Swifty -sdk %t/sdk
4+
5+
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -v -o %t/prebuilt
6+
// RUN: ls %t/prebuilt | %FileCheck %s
7+
// CHECK: Swifty.swiftmodule
8+
9+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
10+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
11+
12+
// Touch a file in the SDK (to make it look like it changed) and try again.
13+
// This should still be able to use the prebuilt modules because they track
14+
// content hashes, not just size+mtime.
15+
// RUN: rm -rf %t/MCP
16+
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/include/Platform.h
17+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
18+
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Swifty-*.swiftmodule
19+
20+
// Actually change a file in the SDK, to check that we're tracking dependencies
21+
// at all.
22+
// RUN: rm -rf %t/MCP
23+
// RUN: echo "void unrelated();" >> %t/sdk/usr/include/Platform.h
24+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
25+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Swifty-*.swiftmodule
26+
27+
// Without the prebuilt cache everything should still work; it'll just take time
28+
// because we have to build the interfaces.
29+
// RUN: rm -rf %t/MCP
30+
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP
31+
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Swifty-*.swiftmodule
32+
33+
import Swifty
34+
35+
usesCStruct(nil)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
RUN: %empty-directory(%t)
2+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -o %t/output -log-path %t/logs | %FileCheck %s
3+
RUN: %FileCheck -check-prefix PRINTS-ERROR %s < %t/logs/Bad-Bad-err.txt
4+
5+
CHECK: # (FAIL) {{.+}}/Bad.swiftinterface
6+
7+
PRINTS-ERROR: unresolved identifier 'garbage'
8+
9+
RUN: %empty-directory(%t)
10+
RUN: echo '["Good"]' > %t/xfails-good.json
11+
RUN: not %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -o %t/output -log-path %t/logs -xfails %t/xfails-good.json | %FileCheck -check-prefix=CHECK-XFAIL-GOOD %s
12+
RUN: %FileCheck -check-prefix PRINTS-ERROR %s < %t/logs/Bad-Bad-err.txt
13+
14+
CHECK-XFAIL-GOOD-DAG: # (FAIL) {{.+}}/Bad.swiftinterface
15+
CHECK-XFAIL-GOOD-DAG: # (UPASS) {{.+}}/Good.swiftinterface
16+
17+
RUN: %empty-directory(%t)
18+
RUN: echo '["Good", "Bad"]' > %t/xfails-good-and-bad.json
19+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -o %t/output -log-path %t/logs -xfails %t/xfails-good-and-bad.json| %FileCheck -check-prefix=CHECK-XFAIL-GOOD-AND-BAD %s
20+
RUN: %FileCheck -check-prefix PRINTS-ERROR %s < %t/logs/Bad-Bad-err.txt
21+
22+
CHECK-XFAIL-GOOD-AND-BAD-DAG: # (XFAIL) {{.+}}/Bad.swiftinterface
23+
CHECK-XFAIL-GOOD-AND-BAD-DAG: # (UPASS) {{.+}}/Good.swiftinterface
24+
25+
RUN: %empty-directory(%t)
26+
RUN: echo '["Bad"]' > %t/xfails-bad.json
27+
RUN: %swift_build_sdk_interfaces -sdk %S/Inputs/xfails-sdk/ -o %t/output -log-path %t/logs -xfails %t/xfails-bad.json | %FileCheck -check-prefix=CHECK-XFAIL-BAD %s
28+
RUN: %FileCheck -check-prefix PRINTS-ERROR %s < %t/logs/Bad-Bad-err.txt
29+
30+
CHECK-XFAIL-BAD: # (XFAIL) {{.+}}/Bad.swiftinterface
31+
32+
RUN: %empty-directory(%t)
33+
RUN: not %swift_build_sdk_interfaces -sdk %t -o %t/output -log-path %t/logs %S/Inputs/xfail-logs-framework/ | %FileCheck -check-prefix=CHECK-FRAMEWORK %s
34+
RUN: %FileCheck -check-prefix PRINTS-ERROR %s < %t/logs/BadFMWK-x86_64-apple-macos-err.txt
35+
36+
CHECK-FRAMEWORK: # (FAIL) {{.+}}/BadFMWK.swiftmodule/x86_64-apple-macos.swiftinterface

0 commit comments

Comments
 (0)