Skip to content

Commit 7d264fd

Browse files
committed
cmake: symlink framework ABI baseline data into the build directory
When running the ABI checker from the build artifact, the executable should be able to find baselines in the same relative paths as if it's running from a toolchain.
1 parent 8584d22 commit 7d264fd

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

utils/api_checker/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
set(framework "FrameworkABIBaseline")
12
swift_install_in_component(FILES "swift-api-checker.py"
23
DESTINATION "bin"
34
COMPONENT toolchain-tools)
45
swift_install_in_component(DIRECTORY "sdk-module-lists"
56
DESTINATION "bin"
67
COMPONENT toolchain-tools)
7-
swift_install_in_component(DIRECTORY "FrameworkABIBaseline"
8+
swift_install_in_component(DIRECTORY "${framework}"
89
DESTINATION "lib/swift"
910
COMPONENT toolchain-tools)
11+
12+
# Add symlink of FrameworkABIBaseline to the build dir. This ensures we can
13+
# find the baseline data from the same relative path as if we are running the
14+
# checker from the toolchain.
15+
set(SWIFTLIB_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")
16+
set(dest "${SWIFTLIB_DIR}/${framework}")
17+
set(source "${CMAKE_CURRENT_SOURCE_DIR}/${framework}")
18+
19+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
20+
set(CMAKE_SYMLINK_COMMAND copy)
21+
else()
22+
set(CMAKE_SYMLINK_COMMAND create_symlink)
23+
endif()
24+
add_custom_command(OUTPUT "${dest}"
25+
DEPENDS "${source}"
26+
COMMAND "${CMAKE_COMMAND}" "-E" "${CMAKE_SYMLINK_COMMAND}" "${source}" "${dest}")
27+
add_custom_target("symlink_abi_checker_data" ALL
28+
DEPENDS "${dest}"
29+
COMMENT "Symlinking ABI checker baseline data to ${dest}")

0 commit comments

Comments
 (0)