Skip to content

Commit 8385137

Browse files
committed
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.
1 parent 50871f9 commit 8385137

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,11 @@ endif()
15831583
# New standard library build
15841584
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
15851585
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
1586+
1587+
add_custom_target(PopulateRuntimeSourceDir
1588+
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake"
1589+
COMMENT "Copying sources into new runtime build")
1590+
15861591
foreach(sdk ${SWIFT_SDKS})
15871592
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
15881593
# Provide a mechanism to skip building one of these runtimes
@@ -1599,6 +1604,8 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
15991604
# TODO: Add this once we're ready to start swapping out the libraries
16001605
# for testing
16011606
# INSTALL_DIR "${CMAKE_BINARY_DIR}/"
1607+
1608+
DEPENDS PopulateRuntimeSourceDir
16021609
CMAKE_ARGS
16031610
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib/swift/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}
16041611
# Compiler will see mismatched swift modules and fail initial checks
@@ -1616,8 +1623,4 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16161623
endif()
16171624
endforeach()
16181625
endforeach()
1619-
1620-
# Materialize sources in the new build
1621-
execute_process(COMMAND
1622-
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake")
16231626
endif()

Runtimes/Resync.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ message(STATUS "Source dir: ${StdlibSources}")
1515
function(copy_library_sources name from_prefix to_prefix)
1616
message(STATUS "${name}[${StdlibSources}/${from_prefix}/${name}] -> ${to_prefix}/${name} ")
1717

18+
set(full_to_prefix "${CMAKE_CURRENT_LIST_DIR}/${to_prefix}")
19+
1820
file(GLOB_RECURSE filenames
1921
FOLLOW_SYMLINKS
2022
LIST_DIRECTORIES FALSE
@@ -36,15 +38,15 @@ function(copy_library_sources name from_prefix to_prefix)
3638
foreach(file ${filenames})
3739
# Get and create the directory
3840
get_filename_component(dirname ${file} DIRECTORY)
39-
file(MAKE_DIRECTORY "${to_prefix}/${dirname}")
41+
file(MAKE_DIRECTORY "${full_to_prefix}/${dirname}")
4042
file(COPY_FILE
4143
"${StdlibSources}/${from_prefix}/${file}" # From
42-
"${CMAKE_CURRENT_LIST_DIR}/${to_prefix}/${file}" # To
44+
"${full_to_prefix}/${file}" # To
4345
RESULT _output
4446
ONLY_IF_DIFFERENT)
4547
if(_output)
4648
message(SEND_ERROR
47-
"Copy ${from_prefix}/${file} -> ${to_prefix}/${file} Failed: ${_output}")
49+
"Copy ${from_prefix}/${file} -> ${full_to_prefix}/${file} Failed: ${_output}")
4850
endif()
4951
endforeach()
5052
endfunction()

0 commit comments

Comments
 (0)