Skip to content

Commit 60afbb7

Browse files
committed
DNM/build: identify points of incorrectness
This identifies the points where we do not account for linking on Windows which is required for macros.
1 parent cfd070f commit 60afbb7

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
573573
else()
574574
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${ASRLF_BOOTSTRAPPING_MODE}'")
575575
endif()
576+
else()
577+
target_link_directories(${target} PRIVATE
578+
${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/Windows/x86_64)
576579
endif()
577580
578581
if(SWIFT_SWIFT_PARSER)

lib/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ if (SWIFT_SWIFT_PARSER)
4646
"${CMAKE_SHARED_LIBRARY_SUFFIX}"
4747
OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES)
4848

49+
list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "${CMAKE_IMPORT_LIBRARY_PREFIX}"
50+
OUTPUT_VARIABLE SWIFT_SYNTAX_IMPORT_LIBRARIES)
51+
list(TRANSFORM SWIFT_SYNTAX_IMPORT_LIBRARIES APPEND
52+
"${CMAKE_IMPORT_LIBRARY_SUFFIX}" OUTPUT_VARIABLE
53+
SWIFT_SYNTAX_IMPORT_LIBRARIES)
54+
4955
# Interface library to collect swiftinterfaces and swiftmodules from
5056
# SwiftSyntax
5157
add_library(swiftSyntaxLibraries INTERFACE)
@@ -64,6 +70,7 @@ if (SWIFT_SWIFT_PARSER)
6470
)
6571
endif()
6672

73+
if(FALSE)
6774
add_custom_command(
6875
OUTPUT "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}"
6976
DEPENDS "${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${sharedlib}"
@@ -81,10 +88,47 @@ if (SWIFT_SWIFT_PARSER)
8188
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host"
8289
COMPONENT compiler
8390
)
91+
else()
92+
93+
set(path "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/bin/${sharedlib}")
94+
cmake_path(NATIVE_PATH path NORMALIZE source)
95+
96+
set(path "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${sharedlib}")
97+
cmake_path(NATIVE_PATH path NORMALIZE destination)
98+
99+
add_custom_command(OUTPUT ${destination}
100+
DEPENDS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/bin/${sharedlib}"
101+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${source} ${destination})
102+
add_custom_target(copy_swiftSyntaxLibrary_${sharedlib}
103+
DEPENDS ${destination}
104+
COMMENT "copying ${sharedlib}")
105+
swift_install_in_component(PROGRAMS ${destination}
106+
DESTINATION bin
107+
COMPONENT compiler)
108+
endif()
84109

85110
add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${sharedlib})
86111
endforeach()
87112

113+
foreach(implib ${SWIFT_SYNTAX_IMPORT_LIBRARIES})
114+
set(path "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host/${implib}")
115+
cmake_path(NATIVE_PATH path NORMALIZE source)
116+
117+
set(path "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib/swift/windows/${implib}")
118+
cmake_path(NATIVE_PATH path NORMALIZE destination)
119+
120+
add_custom_command(OUTPUT ${destination}
121+
DEPENDS ${source}
122+
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${source} ${destination})
123+
add_custom_target(copy_swiftSyntaxLibrary_${implib}
124+
DEPENDS ${destination}
125+
COMMENT "Copying ${implib}")
126+
swift_install_in_component(PROGRAMS ${destination}
127+
DESTINATION lib
128+
COMPONENT compiler)
129+
add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${implib})
130+
endforeach()
131+
88132
# Copy all of the Swift modules from earlyswiftsyntax so they can be found
89133
# in the same relative place within the build directory as in the final
90134
# toolchain.

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
162162
file(RELATIVE_PATH relative_hostlib_path "${path}" "${SWIFTLIB_DIR}/host")
163163
list(APPEND RPATH_LIST "$ORIGIN/${relative_hostlib_path}")
164164
endif()
165+
else()
166+
target_link_directories(${target} PRIVATE
167+
${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/Windows/x86_64)
165168
endif()
166169

167170
if(SWIFT_SWIFT_PARSER)

tools/driver/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# parser is built in.
66
function(add_swift_parser_link_libraries target)
77
if(SWIFT_SWIFT_PARSER)
8+
target_link_directories(${target} PRIVATE
9+
${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/Windows/x86_64)
810
target_link_libraries(${target}
911
PRIVATE swiftCore)
1012

0 commit comments

Comments
 (0)