Skip to content

Commit d26ca1c

Browse files
committed
SwiftShims: update shims copying logic
Update the shims logic to make sure that it works for Xcode as well. Rather than adding additional rules, just simplify it down to the one canonical way in modern LLVM land. The headers are always installed to the LLVM_LIBRARY_OUTPUT_INTDIR which will be defined for us in both the standalone and unified build mode. This allows us to just remove all the work to find the headers since they will always be in one location.
1 parent b36c77c commit d26ca1c

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,35 +84,7 @@ endif()
8484
# First extract the "version" used for Clang's resource directory.
8585
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
8686
"${LLVM_PACKAGE_VERSION}")
87-
88-
# Function to find LLVM or Clang headers
89-
function(find_llvm_clang_headers suffix description out_var)
90-
file(TO_CMAKE_PATH "${SWIFT_PATH_TO_CLANG_BUILD}" PATH_TO_CLANG_BUILD)
91-
92-
set(headers_locations
93-
"${LLVM_LIBRARY_DIR}${suffix}"
94-
"${PATH_TO_CLANG_BUILD}/${CMAKE_CFG_INTDIR}/lib${suffix}"
95-
"${PATH_TO_CLANG_BUILD}/${LLVM_BUILD_TYPE}/lib${suffix}")
96-
97-
set(headers_location)
98-
foreach(loc ${headers_locations})
99-
if(EXISTS "${loc}")
100-
set(headers_location "${loc}")
101-
set(${out_var} "${loc}" PARENT_SCOPE)
102-
break()
103-
endif()
104-
endforeach()
105-
if("${headers_location}" STREQUAL "")
106-
message(FATAL_ERROR "${description} headers were not found in any of the following locations: ${headers_locations}")
107-
endif()
108-
endfunction()
109-
110-
if(SWIFT_BUILT_STANDALONE)
111-
find_llvm_clang_headers("/clang/${CLANG_VERSION}" "Clang"
112-
clang_headers_location)
113-
else() # NOT SWIFT_BUILT_STANDALONE
114-
set(clang_headers_location "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}")
115-
endif()
87+
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
11688

11789
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
11890
set(cmake_symlink_option "copy_directory")
@@ -152,7 +124,7 @@ swift_install_symlink_component(clang-resource-dir-symlink
152124
# Possibly install Clang headers under Clang's resource directory in case we
153125
# need to use a different version of the headers than the installed Clang. This
154126
# should be used in conjunction with clang-resource-dir-symlink.
155-
file(TO_CMAKE_PATH "${SWIFT_PATH_TO_CLANG_BUILD}"
127+
file(TO_CMAKE_PATH "${LLVM_LIBRARY_OUTPUT_INTDIR}"
156128
_SWIFT_SHIMS_PATH_TO_CLANG_BUILD)
157129
swift_install_in_component(clang-builtin-headers-in-clang-resource-dir
158130
DIRECTORY "${_SWIFT_SHIMS_PATH_TO_CLANG_BUILD}/lib/clang"

0 commit comments

Comments
 (0)