Skip to content

Commit 590caf9

Browse files
authored
Merge pull request #60518 from compnerd/sed
build: remove `sed` usage in build system
2 parents 633cc34 + 7c80c32 commit 590caf9

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,28 @@ 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+
#
236+
# step 1: generate a dummy source file, which just includes all headers
237+
# defined in include/swift/module.modulemap
238+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
239+
"
240+
#include \"Basic/BridgedSwiftObject.h\"
241+
#include \"Basic/BasicBridging.h\"
242+
#include \"Basic/SourceLoc.h\"
243+
244+
#include \"AST/ASTBridging.h\"
245+
#include \"AST/DiagnosticEngine.h\"
246+
#include \"AST/DiagnosticConsumer.h\"
247+
248+
#include \"SIL/SILBridging.h\"
249+
250+
#include \"SILOptimizer/OptimizerBridging.h\"
251+
252+
#include \"Parse/RegexParserBridging.h\"
253+
")
254+
245255
# step 2: build a library containing that source file. This library depends on all the included header files.
246256
# The swift modules can now depend on that target.
247257
# Note that this library is unused, i.e. not linked to anything.

0 commit comments

Comments
 (0)