Skip to content

Commit 8fb3f68

Browse files
authored
Don't install the binary Swift module when building for Apple platforms (#837)
This modifies the CMake rules to stop installing binary .swiftmodule files when building for Apple platforms. ### Motivation: Apple platforms have a stable ABI and modules for those platforms should instead use the textual .swiftinterface which is already installed by CMake. The binary .swiftmodule permits access to [SPI](https://github.com/swiftlang/swift-testing/blob/main/Documentation/SPI.md) declarations from the testing library, and these are not intended to be exposed in distribution builds. Although this PR only removes access to these on macOS, since it's the only platform which has a textual .swiftinterface currently, we intend to investigate ways to match this behavior for other platforms in the future. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated. Resolves rdar://136083081
1 parent 3c71e00 commit 8fb3f68

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmake/modules/SwiftModuleInstallation.cmake

+7-3
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@ function(_swift_testing_install_target module)
8686
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
8787
DESTINATION "${module_dir}"
8888
RENAME ${SwiftTesting_MODULE_TRIPLE}.swiftdoc)
89-
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
90-
DESTINATION "${module_dir}"
91-
RENAME ${SwiftTesting_MODULE_TRIPLE}.swiftmodule)
9289
if(APPLE)
9390
# Only Darwin has stable ABI.
9491
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftinterface
9592
DESTINATION "${module_dir}"
9693
RENAME ${SwiftTesting_MODULE_TRIPLE}.swiftinterface)
94+
else()
95+
# Only install the binary .swiftmodule on platforms which do not have a
96+
# stable ABI. Other platforms will use the textual .swiftinterface
97+
# (installed above) and this limits access to this module's SPIs.
98+
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
99+
DESTINATION "${module_dir}"
100+
RENAME ${SwiftTesting_MODULE_TRIPLE}.swiftmodule)
97101
endif()
98102
endfunction()
99103

0 commit comments

Comments
 (0)