1616#
1717function (add_swift_compiler_module module)
1818 cmake_parse_arguments (ALSM
19- ""
19+ "ADD_TO_SYNTAXPARSE "
2020 ""
2121 "DEPENDS;SOURCES"
2222 ${ARGN} )
@@ -35,6 +35,7 @@ function(add_swift_compiler_module module)
3535
3636 set_property (TARGET ${target_name} PROPERTY module_name ${module} )
3737 set_property (TARGET ${target_name} PROPERTY module_depends ${ALSM_DEPENDS} )
38+ set_property (TARGET ${target_name} PROPERTY add_to_syntaxparse ${ALSM_ADD_TO_SYNTAXPARSE} )
3839
3940 get_property (modules GLOBAL PROPERTY swift_compiler_modules)
4041 set_property (GLOBAL PROPERTY swift_compiler_modules ${modules} ${module} )
@@ -120,13 +121,16 @@ function(add_swift_compiler_modules_library name)
120121
121122 set (all_obj_files)
122123 set (all_module_targets)
124+ set (syntaxparse_obj_files)
125+ set (syntaxparse_module_targets)
123126 get_property (modules GLOBAL PROPERTY "swift_compiler_modules" )
124127 foreach (module ${modules} )
125128
126129 set (module_target "SwiftModule${module} " )
127130 get_target_property (module ${module_target} "module_name" )
128131 get_target_property (sources ${module_target} SOURCES )
129132 get_target_property (dependencies ${module_target} "module_depends" )
133+ get_target_property (add_to_syntaxparse ${module_target} "add_to_syntaxparse" )
130134 set (deps, "" )
131135 if (dependencies)
132136 foreach (dep_module ${dependencies} )
@@ -146,6 +150,9 @@ function(add_swift_compiler_modules_library name)
146150 set_property (TARGET ${module_target} PROPERTY "module_file" "${module_file} " )
147151
148152 set (all_obj_files ${all_obj_files} ${module_obj_file} )
153+ if (add_to_syntaxparse)
154+ set (syntaxparse_obj_files ${syntaxparse_obj_files} ${module_obj_file} )
155+ endif ()
149156
150157 # Compile the module into an object file
151158 add_custom_command_target(dep_target OUTPUT ${module_obj_file}
@@ -168,6 +175,9 @@ function(add_swift_compiler_modules_library name)
168175
169176 set ("${module} _dep_target" ${dep_target} )
170177 set (all_module_targets ${all_module_targets} ${dep_target} )
178+ if (add_to_syntaxparse)
179+ set (syntaxparse_module_targets ${syntaxparse_module_targets} ${dep_target} )
180+ endif ()
171181 endforeach ()
172182
173183 # Create a static library containing all module object files.
@@ -181,6 +191,15 @@ function(add_swift_compiler_modules_library name)
181191 add_dependencies (${name} ${all_module_targets} )
182192 set_target_properties (${name} PROPERTIES LINKER_LANGUAGE CXX)
183193 set_property (GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name} )
194+
195+ if (XCODE)
196+ set (syntaxparse_obj_files force_lib.c ${syntaxparse_obj_files} )
197+ endif ()
198+ add_library ("${name} _SwiftSyntax" STATIC ${syntaxparse_obj_files} )
199+ add_dependencies ("${name} _SwiftSyntax" ${syntaxparse_module_targets} )
200+ set_target_properties ("${name} _SwiftSyntax" PROPERTIES LINKER_LANGUAGE CXX)
201+ set_property (GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS "${name} _SwiftSyntax" )
202+
184203endfunction ()
185204
186205
@@ -190,6 +209,7 @@ add_swift_host_library(swiftCompilerStub OBJECT stubs.cpp)
190209if (NOT BOOTSTRAPPING_MODE)
191210
192211 add_library (swiftCompilerModules ALIAS swiftCompilerStub)
212+ add_library (swiftCompilerModules_SwiftSyntax ALIAS swiftCompilerStub)
193213
194214else ()
195215 # Note: "Swift" is not added intentionally here, because it would break
0 commit comments