From f03d9a01e6a1ef952bc8b57a910c69e116aa3a46 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Thu, 10 Oct 2024 15:28:26 -0700 Subject: [PATCH] Adding stdlib resync script Adding a quick script to keep the pieces of the standard library in sync between the new stdlib build and the old one. --- .gitignore | 14 +++++++++ Runtimes/Readme.md | 18 +++++++++++ Runtimes/Resync.cmake | 70 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 Runtimes/Resync.cmake diff --git a/.gitignore b/.gitignore index a977c42acf2..b335dbd2c7e 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,17 @@ SortedCFDatabase.def htmlcov .coverage /benchmark/scripts/Benchmark_Driverc + +#==============================================================================# +# Ignore copied Swift Stdlib files while migrating stdlib +#==============================================================================# +Runtimes/**/*.swift +Runtimes/**/*.h +Runtimes/**/*.cpp +Runtimes/**/*.c +Runtimes/**/*.m +Runtimes/**/*.mm +Runtimes/**/*.def +Runtimes/**/*.gyb +Runtimes/**/*.apinotes +Runtimes/**/*.yaml diff --git a/Runtimes/Readme.md b/Runtimes/Readme.md index c00f30946af..8907e1edfa7 100644 --- a/Runtimes/Readme.md +++ b/Runtimes/Readme.md @@ -2,6 +2,24 @@ This directory contains the pieces of the Swift runtime libraries. +## Development + +While we're bringing up the new standard library build, please do not commit the +standard library source files. Use the `Resync.cmake` file to copy the files as +needed. + +```sh +$ cmake -P Resync.cmake +``` + +> [!IMPORTANT] +> Re-run this script after updating your Swift checkout to ensure that you are +> building the latest standard library sources. + +Once the migration is completed, we will be deleting this script. It +is a temporary workaround to avoid trying to keep multiple sets of files in +sync. + ## Layering ``` diff --git a/Runtimes/Resync.cmake b/Runtimes/Resync.cmake new file mode 100644 index 00000000000..8f264fac045 --- /dev/null +++ b/Runtimes/Resync.cmake @@ -0,0 +1,70 @@ +# This CMake script keeps the files in the new standard library build in sync +# with the existing standard library. + +# TODO: Once the migration is completed, we can delete this file + +cmake_minimum_required(VERSION 3.21) + +# Where the standard library lives today +set(StdlibSources "${CMAKE_CURRENT_LIST_DIR}/../stdlib") + +message(STATUS "Source dir: ${StdlibSources}") + +# Copy the files under the "name" directory in the standard library into the new +# location under Runtimes +function(copy_library_sources name from_prefix to_prefix) + message(STATUS "${name}[${StdlibSources}/${from_prefix}/${name}] -> ${to_prefix}/${name} ") + + file(GLOB_RECURSE filenames + FOLLOW_SYMLINKS + LIST_DIRECTORIES FALSE + RELATIVE "${StdlibSources}/${from_prefix}" + "${StdlibSources}/${from_prefix}/${name}/*.swift" + "${StdlibSources}/${from_prefix}/${name}/*.h" + "${StdlibSources}/${from_prefix}/${name}/*.cpp" + "${StdlibSources}/${from_prefix}/${name}/*.c" + "${StdlibSources}/${from_prefix}/${name}/*.mm" + "${StdlibSources}/${from_prefix}/${name}/*.m" + "${StdlibSources}/${from_prefix}/${name}/*.def" + "${StdlibSources}/${from_prefix}/${name}/*.gyb" + "${StdlibSources}/${from_prefix}/${name}/*.apinotes" + "${StdlibSources}/${from_prefix}/${name}/*.yaml") + + foreach(file ${filenames}) + # Get and create the directory + get_filename_component(dirname ${file} DIRECTORY) + file(MAKE_DIRECTORY "${to_prefix}/${dirname}") + file(COPY_FILE + "${StdlibSources}/${from_prefix}/${file}" # From + "${CMAKE_CURRENT_LIST_DIR}/${to_prefix}/${file}" # To + RESULT _output + ONLY_IF_DIFFERENT) + if(_output) + message(SEND_ERROR + "Copy ${from_prefix}/${file} -> ${to_prefix}/${file} Failed: ${_output}") + endif() + endforeach() +endfunction() + +# Directories in the existing standard library that make up the Core project + +# Copy shared core headers +copy_library_sources(include "" "Core") + +set(CoreLibs + LLVMSupport) + + # Add these as we get them building + # core + # Concurrency + # SwiftOnoneSUpport + # CommandLineSupport + # Demangling + # runtime) + +foreach(library ${CoreLibs}) + copy_library_sources(${library} "public" "Core") +endforeach() + +# TODO: Add source directories for the platform overlays, supplemental +# libraries, and test support libraries.