Skip to content

Commit f03d9a0

Browse files
committed
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.
1 parent a01e080 commit f03d9a0

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,17 @@ SortedCFDatabase.def
7878
htmlcov
7979
.coverage
8080
/benchmark/scripts/Benchmark_Driverc
81+
82+
#==============================================================================#
83+
# Ignore copied Swift Stdlib files while migrating stdlib
84+
#==============================================================================#
85+
Runtimes/**/*.swift
86+
Runtimes/**/*.h
87+
Runtimes/**/*.cpp
88+
Runtimes/**/*.c
89+
Runtimes/**/*.m
90+
Runtimes/**/*.mm
91+
Runtimes/**/*.def
92+
Runtimes/**/*.gyb
93+
Runtimes/**/*.apinotes
94+
Runtimes/**/*.yaml

Runtimes/Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
This directory contains the pieces of the Swift runtime libraries.
44

5+
## Development
6+
7+
While we're bringing up the new standard library build, please do not commit the
8+
standard library source files. Use the `Resync.cmake` file to copy the files as
9+
needed.
10+
11+
```sh
12+
$ cmake -P Resync.cmake
13+
```
14+
15+
> [!IMPORTANT]
16+
> Re-run this script after updating your Swift checkout to ensure that you are
17+
> building the latest standard library sources.
18+
19+
Once the migration is completed, we will be deleting this script. It
20+
is a temporary workaround to avoid trying to keep multiple sets of files in
21+
sync.
22+
523
## Layering
624

725
```

Runtimes/Resync.cmake

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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

Comments
 (0)