Skip to content

Commit f94b96e

Browse files
committed
Augment add_swift_tool_symlink to set the target destination
Also ensure we don't symlink to swift-frontend twice
1 parent 79b5a1d commit f94b96e

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
321321
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
322322
endif()
323323

324-
set(SWIFT_TOOLS_INSTALL_DIR "bin" CACHE PATH
325-
"Path for binary subdirectory to use during installation.
326-
Used by add_swift_tool_symlink in AddSwift.cmake so that llvm_install_symlink generates the installation script properly.")
327-
328324
#
329325
# User-configurable Swift Standard Library specific options.
330326
#

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,16 @@ function(add_swift_fuzzer_host_tool executable)
956956
target_link_libraries(${executable} PRIVATE "-fsanitize=fuzzer")
957957
endfunction()
958958

959-
macro(add_swift_tool_symlink name dest component)
959+
macro(add_swift_tool_symlink name dest component destination)
960+
# This is used by llvm_install_symlink to determine where
961+
# to put the target link
962+
# we decide to define this "locally" to the macro instead of the
963+
# main CMakeLists.txt so to align with how we configure installation
964+
# across our scripts (i.e. granular control for each program in a component)
965+
set(SWIFT_TOOLS_INSTALL_DIR destination)
960966
llvm_add_tool_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE)
961967
llvm_install_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE COMPONENT ${component})
968+
unset(SWIFT_TOOLS_INSTALL_DIR)
962969
endmacro()
963970

964971
# Declare that files in this library are built with LLVM's support

tools/driver/CMakeLists.txt

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,36 +111,13 @@ swift_create_post_build_symlink(swift-frontend
111111
DESTINATION "swift-api-digester${CMAKE_EXECUTABLE_SUFFIX}"
112112
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
113113

114-
add_swift_tool_symlink(swift swift-frontend compiler)
115-
add_swift_tool_symlink(swiftc swift-frontend compiler)
116-
add_swift_tool_symlink(swift-symbolgraph-extract swift-frontend compiler)
117-
add_swift_tool_symlink(swift-api-extract swift-frontend compiler)
118-
add_swift_tool_symlink(swift-autolink-extract swift-frontend autolink-driver)
119-
add_swift_tool_symlink(swift-indent swift-frontend editor-integration)
120-
add_swift_tool_symlink(swift-api-digester swift-frontend compiler)
114+
add_swift_tool_symlink(swift swift-frontend compiler "bin")
115+
add_swift_tool_symlink(swiftc swift-frontend compiler "bin")
116+
add_swift_tool_symlink(swift-symbolgraph-extract swift-frontend compiler "bin")
117+
add_swift_tool_symlink(swift-api-extract swift-frontend compiler "bin")
118+
add_swift_tool_symlink(swift-autolink-extract swift-frontend autolink-driver "bin")
119+
add_swift_tool_symlink(swift-indent swift-frontend editor-integration "bin")
120+
add_swift_tool_symlink(swift-api-digester swift-frontend compiler "bin")
121121

122122
add_dependencies(compiler swift-frontend)
123-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift${CMAKE_EXECUTABLE_SUFFIX}"
124-
DESTINATION "bin"
125-
COMPONENT compiler)
126-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swiftc${CMAKE_EXECUTABLE_SUFFIX}"
127-
DESTINATION "bin"
128-
COMPONENT compiler)
129-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-symbolgraph-extract${CMAKE_EXECUTABLE_SUFFIX}"
130-
DESTINATION "bin"
131-
COMPONENT compiler)
132-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-api-extract${CMAKE_EXECUTABLE_SUFFIX}"
133-
DESTINATION "bin"
134-
COMPONENT compiler)
135-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-api-digester${CMAKE_EXECUTABLE_SUFFIX}"
136-
DESTINATION "bin"
137-
COMPONENT compiler)
138-
add_dependencies(autolink-driver swift-frontend)
139-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-autolink-extract${CMAKE_EXECUTABLE_SUFFIX}"
140-
DESTINATION "bin"
141-
COMPONENT autolink-driver)
142-
add_dependencies(editor-integration swift-frontend)
143-
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-indent${CMAKE_EXECUTABLE_SUFFIX}"
144-
DESTINATION "bin"
145-
COMPONENT editor-integration)
146123

0 commit comments

Comments
 (0)