Skip to content

Commit f85b180

Browse files
committed
Symlink 'swift' and 'swiftc' to 'swift-driver', when available
1 parent f7c3f5a commit f85b180

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tools/driver/CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,31 @@ add_swift_parser_link_libraries(swift-frontend)
7777
# to ensure that `swiftc` forwards to the standalone driver when invoked.
7878
swift_create_early_driver_copies(swift-frontend)
7979

80-
swift_create_post_build_symlink(swift-frontend
81-
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
82-
DESTINATION "swift${CMAKE_EXECUTABLE_SUFFIX}"
83-
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
80+
# If a `swift-driver` executable adjacent to the `swift-frontend` executable exists
81+
# then the `swift` and `swiftc` symlinks should point to it by-default
82+
if(EXISTS "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-driver" AND EXISTS "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-help")
83+
message(STATUS "Pointing 'swift' and 'swiftc' symlinks at 'swift-driver'.")
84+
swift_create_post_build_symlink(swift-frontend
85+
SOURCE "swift-driver${CMAKE_EXECUTABLE_SUFFIX}"
86+
DESTINATION "swift${CMAKE_EXECUTABLE_SUFFIX}"
87+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
88+
89+
swift_create_post_build_symlink(swift-frontend
90+
SOURCE "swift-driver${CMAKE_EXECUTABLE_SUFFIX}"
91+
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
92+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
93+
else()
94+
message(STATUS "Pointing 'swift' and 'swiftc' symlinks at 'swift-frontend' - no early SwiftDriver build found.")
95+
swift_create_post_build_symlink(swift-frontend
96+
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
97+
DESTINATION "swift${CMAKE_EXECUTABLE_SUFFIX}"
98+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
8499

85-
swift_create_post_build_symlink(swift-frontend
86-
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
87-
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
88-
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
100+
swift_create_post_build_symlink(swift-frontend
101+
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
102+
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
103+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
104+
endif()
89105

90106
swift_create_post_build_symlink(swift-frontend
91107
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"

0 commit comments

Comments
 (0)