Skip to content

Commit ce16ef3

Browse files
committed
build: remove sed usage in build system
`sed` is not available on all platforms, we cannot depend on that to rewrite the module map. As a temporary stop gap, write the file statically and generate it at build time. Eventually, this could be replaced with a tool or CMake based text processing to generate the content. This repairs part of the build for Windows with bootstrapping.
1 parent 9c4972f commit ce16ef3

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,25 @@ else()
230230

231231
add_subdirectory(Sources)
232232

233-
# This is a hack to get correct dependencies from imported C++ headers:
234-
# step 1: generate a dummy source file, which just includes all headers defined in include/swift/module.modulemap
235-
add_custom_command(
236-
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
237-
COMMAND
238-
"sed"
239-
-n -e "/header/!d" -e "s/.*header/#include/" -e "w ${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
240-
"${CMAKE_CURRENT_SOURCE_DIR}/../include/swift/module.modulemap"
241-
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../include/swift/module.modulemap"
242-
COMMENT "Generate HeaderDependencies.cpp"
243-
)
244-
233+
# TODO: generate this dynamically through the modulemap; this cannot use `sed`
234+
# as that is not available on all paltforms (e.g. Windows).
235+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
236+
"\
237+
#include \"Basic/BridgedSwiftObject.h\" \
238+
#include \"Basic/BasicBridging.h\" \
239+
#include \"Basic/SourceLoc.h\" \
240+
\
241+
#include \"AST/ASTBridging.h\" \
242+
#include \"AST/DiagnosticEngine.h\" \
243+
#include \"AST/DiagnosticConsumer.h\" \
244+
\
245+
#include \"SIL/SILBridging.h\" \
246+
\
247+
#include \"SILOptimizer/OptimizerBridging.h\" \
248+
\
249+
#include \"Parse/RegexParserBridging.h\" \
250+
")
251+
245252
# step 2: build a library containing that source file. This library depends on all the included header files.
246253
# The swift modules can now depend on that target.
247254
# Note that this library is unused, i.e. not linked to anything.

0 commit comments

Comments
 (0)