mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Auto populate runtime source directory
This patch causes the convenient flow to automatically populate the sources into the new runtime directory layout. This is run at build-time so that it repopulates on each build. Since the resync script uses `COPY_IF_DIFFERENT`, only files that change in the main source directory are copied over, so incremental builds should still work. Fixed a small bug in the resync script to ensure that it creates the subdirectories in the right places.
This commit is contained in:
@@ -1583,6 +1583,11 @@ endif()
|
||||
# New standard library build
|
||||
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
|
||||
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
|
||||
|
||||
add_custom_target(PopulateRuntimeSourceDir
|
||||
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake"
|
||||
COMMENT "Copying sources into new runtime build")
|
||||
|
||||
foreach(sdk ${SWIFT_SDKS})
|
||||
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
|
||||
# Provide a mechanism to skip building one of these runtimes
|
||||
@@ -1599,6 +1604,8 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
|
||||
# TODO: Add this once we're ready to start swapping out the libraries
|
||||
# for testing
|
||||
# INSTALL_DIR "${CMAKE_BINARY_DIR}/"
|
||||
|
||||
DEPENDS PopulateRuntimeSourceDir
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib/swift/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}
|
||||
# Compiler will see mismatched swift modules and fail initial checks
|
||||
@@ -1616,8 +1623,4 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# Materialize sources in the new build
|
||||
execute_process(COMMAND
|
||||
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake")
|
||||
endif()
|
||||
|
||||
@@ -15,6 +15,8 @@ message(STATUS "Source dir: ${StdlibSources}")
|
||||
function(copy_library_sources name from_prefix to_prefix)
|
||||
message(STATUS "${name}[${StdlibSources}/${from_prefix}/${name}] -> ${to_prefix}/${name} ")
|
||||
|
||||
set(full_to_prefix "${CMAKE_CURRENT_LIST_DIR}/${to_prefix}")
|
||||
|
||||
file(GLOB_RECURSE filenames
|
||||
FOLLOW_SYMLINKS
|
||||
LIST_DIRECTORIES FALSE
|
||||
@@ -36,15 +38,15 @@ function(copy_library_sources name from_prefix to_prefix)
|
||||
foreach(file ${filenames})
|
||||
# Get and create the directory
|
||||
get_filename_component(dirname ${file} DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${to_prefix}/${dirname}")
|
||||
file(MAKE_DIRECTORY "${full_to_prefix}/${dirname}")
|
||||
file(COPY_FILE
|
||||
"${StdlibSources}/${from_prefix}/${file}" # From
|
||||
"${CMAKE_CURRENT_LIST_DIR}/${to_prefix}/${file}" # To
|
||||
"${full_to_prefix}/${file}" # To
|
||||
RESULT _output
|
||||
ONLY_IF_DIFFERENT)
|
||||
if(_output)
|
||||
message(SEND_ERROR
|
||||
"Copy ${from_prefix}/${file} -> ${to_prefix}/${file} Failed: ${_output}")
|
||||
"Copy ${from_prefix}/${file} -> ${full_to_prefix}/${file} Failed: ${_output}")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user