Files
swift-mirror/lib/Migrator/CMakeLists.txt
Daniel Rodríguez Troitiño 42e43edef3 [cmake] Unify usage of create_symlink/copy across the build files. (#72202)
In several places, there was the same or similar code to either do
a symlink or use copy/copy_if_different/copy_directory in Windows
systems. The checks were also slightly different in some cases.

There is a `SWIFT_COPY_OR_SYMLINK` that can be controlled as a CMake
option, and uses `CMAKE_HOST_UNIX` as default. Change all cases that
I can find to use that value. Also create a parallel value
`SWIFT_COPY_OR_SYMLINK_DIR` to apply to directories.

There is still a couple of cases that are specific to macOS SourceKit
framework which I have left as-is, since symlinks is probably the only
right thing to do there.

There's a case for Windows specifically that uses symlinks (in
523f807694/cmake/modules/SwiftConfigureSDK.cmake (L502))
which I have not modified as well.
2024-03-09 18:03:55 -08:00

60 lines
1.6 KiB
CMake

set(datafiles
macos4.json
ios4.json
tvos4.json
watchos4.json
overlay4.json
macos42.json
ios42.json
tvos42.json
watchos42.json
overlay42.json
)
set(SWIFTLIB_DIR
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")
set(output_dir "${SWIFTLIB_DIR}/migrator")
add_custom_command(
OUTPUT "${output_dir}"
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
set(outputs)
foreach(input ${datafiles})
set(source "${CMAKE_CURRENT_SOURCE_DIR}/${input}")
set(dest "${output_dir}/${input}")
add_custom_command(OUTPUT
"${output_dir}/${input}"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/${input}"
COMMAND
"${CMAKE_COMMAND}" "-E" "${SWIFT_COPY_OR_SYMLINK}" "${source}" "${dest}")
list(APPEND outputs "${output_dir}/${input}")
endforeach()
list(APPEND outputs "${output_dir}")
add_custom_target("symlink_migrator_data"
DEPENDS "${output_dir}" "${outputs}"
COMMENT "Symlinking migrator data to ${output_dir}")
swift_install_in_component(FILES ${datafiles}
DESTINATION "lib/swift/migrator"
COMPONENT compiler)
add_swift_host_library(swiftMigrator STATIC
APIDiffMigratorPass.cpp
EditorAdapter.cpp
FixitApplyDiagnosticConsumer.cpp
Migrator.cpp
MigrationState.cpp
OptionalTryMigratorPass.cpp
RewriteBufferEditsReceiver.cpp)
target_link_libraries(swiftMigrator PRIVATE
swiftIDE)
add_dependencies(swiftMigrator
"symlink_migrator_data")
set_swift_llvm_is_available(swiftMigrator)