Skip to content

Commit 7e37256

Browse files
committed
[Plugins] Build and install _CompilerPluginSupport module directory.
Fix the generated layout for the `_CompilerPluginSupport` Swift module, so that properly-named Swift interfaces are placed within a `.swiftmodule` subdirectory. Install that directory into lib/swift.
1 parent e8838bc commit 7e37256

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/CompilerPluginSupport/CMakeLists.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,36 @@ if(SWIFT_SWIFT_PARSER)
2626
set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
2727
endif()
2828

29+
# Determine the Swift module path
30+
set(module_triple ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_MODULE})
31+
set(module_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
32+
set(module_base "${module_dir}/${module_name}.swiftmodule")
33+
set(module_file "${module_base}/${module_triple}.swiftmodule")
34+
set(module_interface_file "${module_base}/${module_triple}.swiftinterface")
35+
set(module_doc_file "${module_base}/${module_triple}.swiftdoc")
36+
2937
get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}"
3038
MACCATALYST_BUILD_FLAVOR ""
3139
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
3240

41+
# Add a custom target to create the module directory.
42+
add_custom_command_target(
43+
create_module_dirs_dependency_target
44+
COMMAND "${CMAKE_COMMAND}" -E make_directory ${module_base}
45+
OUTPUT ${module_base}
46+
COMMENT "Generating module directory for ${module_name}")
47+
add_dependencies(${library_name} ${create_module_dirs_dependency_target})
48+
49+
# Build the module with library evolution enabled and install into the
50+
# appropriate locations.
3351
target_compile_options("${library_name}" PRIVATE
3452
$<$<COMPILE_LANGUAGE:Swift>:
3553
-module-name;${module_name};
3654
-enable-library-evolution;
37-
-emit-module-interface;
55+
-emit-module-path;
56+
"${module_file}";
57+
-emit-module-interface-path;
58+
"${module_interface_file}";
3859
-target;${target}>)
3960

4061
target_link_libraries("${library_name}"
@@ -56,4 +77,7 @@ if(SWIFT_SWIFT_PARSER)
5677
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
5778
COMPONENT compiler)
5879

80+
swift_install_in_component(DIRECTORY "${module_base}"
81+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift"
82+
COMPONENT compiler)
5983
endif()

0 commit comments

Comments
 (0)