|
| 1 | +# This CMake script keeps the files in the new standard library build in sync |
| 2 | +# with the existing standard library. |
| 3 | + |
| 4 | +# TODO: Once the migration is completed, we can delete this file |
| 5 | + |
| 6 | +cmake_minimum_required(VERSION 3.21) |
| 7 | + |
| 8 | +# Where the standard library lives today |
| 9 | +set(StdlibSources "${CMAKE_CURRENT_LIST_DIR}/../stdlib") |
| 10 | + |
| 11 | +message(STATUS "Source dir: ${StdlibSources}") |
| 12 | + |
| 13 | +# Copy the files under the "name" directory in the standard library into the new |
| 14 | +# location under Runtimes |
| 15 | +function(copy_library_sources name from_prefix to_prefix) |
| 16 | + message(STATUS "${name}[${StdlibSources}/${from_prefix}/${name}] -> ${to_prefix}/${name} ") |
| 17 | + |
| 18 | + file(GLOB_RECURSE filenames |
| 19 | + FOLLOW_SYMLINKS |
| 20 | + LIST_DIRECTORIES FALSE |
| 21 | + RELATIVE "${StdlibSources}/${from_prefix}" |
| 22 | + "${StdlibSources}/${from_prefix}/${name}/*.swift" |
| 23 | + "${StdlibSources}/${from_prefix}/${name}/*.h" |
| 24 | + "${StdlibSources}/${from_prefix}/${name}/*.cpp" |
| 25 | + "${StdlibSources}/${from_prefix}/${name}/*.c" |
| 26 | + "${StdlibSources}/${from_prefix}/${name}/*.mm" |
| 27 | + "${StdlibSources}/${from_prefix}/${name}/*.m" |
| 28 | + "${StdlibSources}/${from_prefix}/${name}/*.def" |
| 29 | + "${StdlibSources}/${from_prefix}/${name}/*.gyb" |
| 30 | + "${StdlibSources}/${from_prefix}/${name}/*.apinotes" |
| 31 | + "${StdlibSources}/${from_prefix}/${name}/*.yaml") |
| 32 | + |
| 33 | + foreach(file ${filenames}) |
| 34 | + # Get and create the directory |
| 35 | + get_filename_component(dirname ${file} DIRECTORY) |
| 36 | + file(MAKE_DIRECTORY "${to_prefix}/${dirname}") |
| 37 | + file(COPY_FILE |
| 38 | + "${StdlibSources}/${from_prefix}/${file}" # From |
| 39 | + "${CMAKE_CURRENT_LIST_DIR}/${to_prefix}/${file}" # To |
| 40 | + RESULT _output |
| 41 | + ONLY_IF_DIFFERENT) |
| 42 | + if(_output) |
| 43 | + message(SEND_ERROR |
| 44 | + "Copy ${from_prefix}/${file} -> ${to_prefix}/${file} Failed: ${_output}") |
| 45 | + endif() |
| 46 | + endforeach() |
| 47 | +endfunction() |
| 48 | + |
| 49 | +# Directories in the existing standard library that make up the Core project |
| 50 | + |
| 51 | +# Copy shared core headers |
| 52 | +copy_library_sources(include "" "Core") |
| 53 | + |
| 54 | +set(CoreLibs |
| 55 | + LLVMSupport) |
| 56 | + |
| 57 | + # Add these as we get them building |
| 58 | + # core |
| 59 | + # Concurrency |
| 60 | + # SwiftOnoneSUpport |
| 61 | + # CommandLineSupport |
| 62 | + # Demangling |
| 63 | + # runtime) |
| 64 | + |
| 65 | +foreach(library ${CoreLibs}) |
| 66 | + copy_library_sources(${library} "public" "Core") |
| 67 | +endforeach() |
| 68 | + |
| 69 | +# TODO: Add source directories for the platform overlays, supplemental |
| 70 | +# libraries, and test support libraries. |
0 commit comments