@@ -49,9 +49,9 @@ function(handle_swift_sources
4949 dependency_sibgen_target_out_var_name
5050 sourcesvar externalvar name )
5151 cmake_parse_arguments (SWIFTSOURCES
52- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;NO_LINK_NAME;IS_FRAGILE"
52+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;NO_LINK_NAME;IS_FRAGILE;ONLY_SWIFTMODULE "
5353 "SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
54- "DEPENDS;COMPILE_FLAGS;MODULE_NAME;ENABLE_LTO"
54+ "DEPENDS;COMPILE_FLAGS;MODULE_NAME;MODULE_DIR; ENABLE_LTO"
5555 ${ARGN} )
5656 translate_flag(${SWIFTSOURCES_IS_MAIN} "IS_MAIN" IS_MAIN_arg)
5757 translate_flag(${SWIFTSOURCES_IS_STDLIB} "IS_STDLIB" IS_STDLIB_arg)
@@ -65,6 +65,7 @@ function(handle_swift_sources
6565 STATIC_arg)
6666 translate_flag(${SWIFTSOURCES_NO_LINK_NAME} "NO_LINK_NAME" NO_LINK_NAME_arg)
6767 translate_flag(${SWIFTSOURCES_IS_FRAGILE} "IS_FRAGILE" IS_FRAGILE_arg)
68+ translate_flag(${SWIFTSOURCES_ONLY_SWIFTMODULE} "ONLY_SWIFTMODULE" ONLY_SWIFTMODULE_arg)
6869 if (DEFINED SWIFTSOURCES_BOOTSTRAPPING)
6970 set (BOOTSTRAPPING_arg "BOOTSTRAPPING" ${SWIFTSOURCES_BOOTSTRAPPING} )
7071 endif ()
@@ -146,6 +147,7 @@ function(handle_swift_sources
146147 SDK ${SWIFTSOURCES_SDK}
147148 ARCHITECTURE ${SWIFTSOURCES_ARCHITECTURE}
148149 MODULE_NAME ${SWIFTSOURCES_MODULE_NAME}
150+ MODULE_DIR ${SWIFTSOURCES_MODULE_DIR}
149151 ${IS_MAIN_arg}
150152 ${IS_STDLIB_arg}
151153 ${IS_STDLIB_CORE_arg}
@@ -154,6 +156,7 @@ function(handle_swift_sources
154156 ${STATIC_arg}
155157 ${BOOTSTRAPPING_arg}
156158 ${IS_FRAGILE_arg}
159+ ${ONLY_SWIFTMODULE_arg}
157160 INSTALL_IN_COMPONENT "${SWIFTSOURCES_INSTALL_IN_COMPONENT} "
158161 MACCATALYST_BUILD_FLAVOR "${SWIFTSOURCES_MACCATALYST_BUILD_FLAVOR} " )
159162 set ("${dependency_target_out_var_name} " "${dependency_target} " PARENT_SCOPE)
@@ -378,7 +381,7 @@ function(_compile_swift_files
378381 dependency_sib_target_out_var_name dependency_sibopt_target_out_var_name
379382 dependency_sibgen_target_out_var_name)
380383 cmake_parse_arguments (SWIFTFILE
381- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;IS_FRAGILE"
384+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;IS_FRAGILE;ONLY_SWIFTMODULE "
382385 "OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
383386 "SOURCES;FLAGS;DEPENDS;SDK;ARCHITECTURE;OPT_FLAGS;MODULE_DIR"
384387 ${ARGN} )
@@ -903,13 +906,7 @@ function(_compile_swift_files
903906 endif ()
904907 endif ()
905908
906- # First generate the obj dirs
907909 list (REMOVE_DUPLICATES dirs_to_create)
908- add_custom_command_target(
909- create_dirs_dependency_target
910- COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
911- OUTPUT ${dirs_to_create}
912- COMMENT "Generating dirs for ${first_output} " )
913910
914911 # Then we can compile both the object files and the swiftmodule files
915912 # in parallel in this target for the object file, and ...
@@ -940,8 +937,10 @@ function(_compile_swift_files
940937 set (copy_legacy_layouts_dep)
941938 endif ()
942939
940+ if (NOT SWIFTFILE_ONLY_SWIFTMODULE)
943941 add_custom_command_target(
944942 dependency_target
943+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
945944 COMMAND
946945 ${set_environment_args}
947946 "$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -955,10 +954,10 @@ function(_compile_swift_files
955954 ${swift_compiler_tool_dep}
956955 ${source_files} ${SWIFTFILE_DEPENDS}
957956 ${swift_ide_test_dependency}
958- ${create_dirs_dependency_target}
959957 ${copy_legacy_layouts_dep}
960958 COMMENT "Compiling ${first_output} " )
961959 set ("${dependency_target_out_var_name} " "${dependency_target} " PARENT_SCOPE)
960+ endif ()
962961
963962 # This is the target to generate:
964963 #
@@ -978,6 +977,7 @@ function(_compile_swift_files
978977 if (NOT SWIFTFILE_IS_MAIN)
979978 add_custom_command_target(
980979 module_dependency_target
980+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
981981 COMMAND
982982 "${CMAKE_COMMAND} " "-E" "remove" "-f" ${module_outputs}
983983 COMMAND
@@ -997,7 +997,6 @@ function(_compile_swift_files
997997 ${swift_compiler_tool_dep}
998998 ${source_files} ${SWIFTFILE_DEPENDS}
999999 ${swift_ide_test_dependency}
1000- ${create_dirs_dependency_target}
10011000 ${copy_legacy_layouts_dep}
10021001 COMMENT "Generating ${module_file} " )
10031002
@@ -1010,6 +1009,7 @@ function(_compile_swift_files
10101009 endif ()
10111010 add_custom_command_target(
10121011 module_dependency_target_static
1012+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
10131013 COMMAND
10141014 "${CMAKE_COMMAND} " "-E" "make_directory" ${module_dir_static}
10151015 ${specific_module_dir_static}
@@ -1026,7 +1026,6 @@ function(_compile_swift_files
10261026 ${swift_compiler_tool_dep}
10271027 ${source_files} ${SWIFTFILE_DEPENDS}
10281028 ${swift_ide_test_dependency}
1029- ${create_dirs_dependency_target}
10301029 ${copy_legacy_layouts_dep}
10311030 COMMENT "Generating ${module_file} " )
10321031 set ("${dependency_module_target_out_var_name} " "${module_dependency_target_static} " PARENT_SCOPE)
@@ -1084,6 +1083,7 @@ function(_compile_swift_files
10841083 # This is the target to generate the .sib files. It is not built by default.
10851084 add_custom_command_target(
10861085 sib_dependency_target
1086+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
10871087 COMMAND
10881088 ${set_environment_args}
10891089 "$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1096,14 +1096,14 @@ function(_compile_swift_files
10961096 "${file_path} "
10971097 ${swift_compiler_tool_dep}
10981098 ${source_files} ${SWIFTFILE_DEPENDS}
1099- ${create_dirs_dependency_target}
11001099 ${copy_legacy_layouts_dep}
11011100 COMMENT "Generating ${sib_file} "
11021101 EXCLUDE_FROM_ALL )
11031102 set ("${dependency_sib_target_out_var_name} " "${sib_dependency_target} " PARENT_SCOPE)
11041103
11051104 add_custom_command_target(
11061105 sibopt_dependency_target
1106+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
11071107 COMMAND
11081108 ${set_environment_args}
11091109 "$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1116,7 +1116,6 @@ function(_compile_swift_files
11161116 "${file_path} "
11171117 ${swift_compiler_tool_dep}
11181118 ${source_files} ${SWIFTFILE_DEPENDS}
1119- ${create_dirs_dependency_target}
11201119 ${copy_legacy_layouts_dep}
11211120 COMMENT "Generating ${sibopt_file} "
11221121 EXCLUDE_FROM_ALL )
@@ -1125,6 +1124,7 @@ function(_compile_swift_files
11251124 # This is the target to generate the .sibgen files. It is not built by default.
11261125 add_custom_command_target(
11271126 sibgen_dependency_target
1127+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
11281128 COMMAND
11291129 ${set_environment_args}
11301130 "$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1137,7 +1137,6 @@ function(_compile_swift_files
11371137 "${file_path} "
11381138 ${swift_compiler_tool_dep}
11391139 ${source_files} ${SWIFTFILE_DEPENDS}
1140- ${create_dirs_dependency_target}
11411140 ${copy_legacy_layouts_dep}
11421141 COMMENT "Generating ${sibgen_file} "
11431142 EXCLUDE_FROM_ALL )
0 commit comments