@@ -8,49 +8,67 @@ cmake_minimum_required(VERSION 3.21)
8
8
# Where the standard library lives today
9
9
set (StdlibSources "${CMAKE_CURRENT_LIST_DIR} /../stdlib" )
10
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} " )
11
+ # Copy a list of files
12
+ function (copy_files from_prefix to_prefix)
13
+ cmake_parse_arguments (ARG "" "ROOT" "FILES" ${ARGN} )
14
+ if ( NOT ARG_ROOT)
15
+ set (ARG_ROOT ${StdlibSources} )
16
+ endif ( )
17
17
18
18
set (full_to_prefix "${CMAKE_CURRENT_LIST_DIR} /${to_prefix} " )
19
19
20
- file (GLOB_RECURSE filenames
21
- FOLLOW_SYMLINKS
22
- LIST_DIRECTORIES FALSE
23
- RELATIVE "${StdlibSources} /${from_prefix} "
24
- "${StdlibSources} /${from_prefix} /${name} /*.swift"
25
- "${StdlibSources} /${from_prefix} /${name} /*.h"
26
- "${StdlibSources} /${from_prefix} /${name} /*.cpp"
27
- "${StdlibSources} /${from_prefix} /${name} /*.c"
28
- "${StdlibSources} /${from_prefix} /${name} /*.mm"
29
- "${StdlibSources} /${from_prefix} /${name} /*.m"
30
- "${StdlibSources} /${from_prefix} /${name} /*.def"
31
- "${StdlibSources} /${from_prefix} /${name} /*.gyb"
32
- "${StdlibSources} /${from_prefix} /${name} /*.apinotes"
33
- "${StdlibSources} /${from_prefix} /${name} /*.yaml"
34
- "${StdlibSources} /${from_prefix} /${name} /*.inc"
35
- "${StdlibSources} /${from_prefix} /${name} /*.modulemap"
36
- "${StdlibSources} /${from_prefix} /${name} /*.json" )
37
-
38
- foreach (file ${filenames} )
20
+ foreach (file ${ARG_FILES} )
39
21
# Get and create the directory
40
22
get_filename_component (dirname ${file} DIRECTORY )
41
23
file (MAKE_DIRECTORY "${full_to_prefix} /${dirname} " )
42
24
file (COPY_FILE
43
- "${StdlibSources } /${from_prefix} /${file} " # From
25
+ "${ARG_ROOT } /${from_prefix} /${file} " # From
44
26
"${full_to_prefix} /${file} " # To
45
27
RESULT _output
46
28
ONLY_IF_DIFFERENT)
47
29
if (_output)
48
30
message (SEND_ERROR
49
- "Copy ${from_prefix} /${file} -> ${full_to_prefix} /${file} Failed: ${_output} " )
31
+ "Copy ${ARG_ROOT} / ${ from_prefix} /${file} -> ${full_to_prefix} /${file} Failed: ${_output} " )
50
32
endif ()
51
33
endforeach ()
52
34
endfunction ()
53
35
36
+ # Copy the files under the "name" directory in the standard library into the new
37
+ # location under Runtimes
38
+ function (copy_library_sources name from_prefix to_prefix)
39
+ cmake_parse_arguments (ARG "" "ROOT" "" ${ARGN} )
40
+
41
+ if (NOT ARG_ROOT)
42
+ set (ARG_ROOT ${StdlibSources} )
43
+ endif ()
44
+
45
+ message (STATUS "${name} [${ARG_ROOT} /${from_prefix} /${name} ] -> ${to_prefix} /${name} " )
46
+
47
+ set (full_to_prefix "${CMAKE_CURRENT_LIST_DIR} /${to_prefix} " )
48
+
49
+ file (GLOB_RECURSE filenames
50
+ FOLLOW_SYMLINKS
51
+ LIST_DIRECTORIES FALSE
52
+ RELATIVE "${ARG_ROOT} /${from_prefix} "
53
+ "${ARG_ROOT} /${from_prefix} /${name} /*.swift"
54
+ "${ARG_ROOT} /${from_prefix} /${name} /*.h"
55
+ "${ARG_ROOT} /${from_prefix} /${name} /*.cpp"
56
+ "${ARG_ROOT} /${from_prefix} /${name} /*.c"
57
+ "${ARG_ROOT} /${from_prefix} /${name} /*.mm"
58
+ "${ARG_ROOT} /${from_prefix} /${name} /*.m"
59
+ "${ARG_ROOT} /${from_prefix} /${name} /*.def"
60
+ "${ARG_ROOT} /${from_prefix} /${name} /*.gyb"
61
+ "${ARG_ROOT} /${from_prefix} /${name} /*.apinotes"
62
+ "${ARG_ROOT} /${from_prefix} /${name} /*.yaml"
63
+ "${ARG_ROOT} /${from_prefix} /${name} /*.inc"
64
+ "${ARG_ROOT} /${from_prefix} /${name} /*.modulemap"
65
+ "${ARG_ROOT} /${from_prefix} /${name} /*.json" )
66
+
67
+ copy_files("${from_prefix} " "${to_prefix} "
68
+ ROOT "${ARG_ROOT} "
69
+ FILES ${filenames} )
70
+ endfunction ()
71
+
54
72
# Directories in the existing standard library that make up the Core project
55
73
56
74
# Copy shared core headers
@@ -59,63 +77,6 @@ copy_library_sources(include "" "Core")
59
77
# Copy magic linker symbols
60
78
copy_library_sources("linker-support" "" "Core" )
61
79
62
- # Copy Plist
63
- message (STATUS "plist[${StdlibSources} /Info.plist.in] -> Core/Info.plist.in" )
64
- file (COPY_FILE
65
- "${StdlibSources} /Info.plist.in" # From
66
- "${CMAKE_CURRENT_LIST_DIR} /Core/Info.plist.in" # To
67
- RESULT _output
68
- ONLY_IF_DIFFERENT)
69
- if (_output)
70
- message (SEND_ERROR
71
- "Copy ${StdlibSources} /Info.plist.in] -> Core/Info.plist.in Failed: ${_output} " )
72
- endif ()
73
-
74
- # Copy Windows clang overlays
75
- message (STATUS "modulemap[${StdlibSources} /Windows/ucrt.modulemap] -> Overlay/Windows/clang" )
76
- file (COPY_FILE
77
- "${StdlibSources} /public/Platform/ucrt.modulemap" # From
78
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/clang/ucrt.modulemap" # To
79
- RESULT _output
80
- ONLY_IF_DIFFERENT)
81
- if (_output)
82
- message (SEND_ERROR
83
- "Copy ${StdlibSources} /public/Platform/ucrt.modulemap -> Overlay/Windows/clang/ucrt.modulemap Failed: ${_output} " )
84
- endif ()
85
-
86
- message (STATUS "modulemap[${StdlibSources} /Windows/winsdk.modulemap] -> Overlay/Windows/clang" )
87
- file (COPY_FILE
88
- "${StdlibSources} /public/Platform/winsdk.modulemap" # From
89
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/clang/winsdk.modulemap" # To
90
- RESULT _output
91
- ONLY_IF_DIFFERENT)
92
- if (_output)
93
- message (SEND_ERROR
94
- "Copy ${StdlibSources} /public/Platform/winsdk.modulemap -> Overlay/Windows/clang/winsdk.modulemap Failed: ${_output} " )
95
- endif ()
96
-
97
- message (STATUS "modulemap[${StdlibSources} /Windows/vcruntime.modulemap] -> Overlay/Windows/clang" )
98
- file (COPY_FILE
99
- "${StdlibSources} /public/Platform/vcruntime.modulemap" # From
100
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/clang/vcruntime.modulemap" # To
101
- RESULT _output
102
- ONLY_IF_DIFFERENT)
103
- if (_output)
104
- message (SEND_ERROR
105
- "Copy ${StdlibSources} /public/Platform/vcruntime.modulemap -> Overlay/Windows/clang/vcruntime.modulemap Failed: ${_output} " )
106
- endif ()
107
-
108
- message (STATUS "APINotes[${StdlibSources} /Windows/vcruntime.apinotes] -> Overlay/Windows/clang" )
109
- file (COPY_FILE
110
- "${StdlibSources} /public/Platform/vcruntime.apinotes" # From
111
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/clang/vcruntime.apinotes" # To
112
- RESULT _output
113
- ONLY_IF_DIFFERENT)
114
- if (_output)
115
- message (SEND_ERROR
116
- "Copy ${StdlibSources} /public/Platform/vcruntime.apinotes -> Overlay/Windows/clang/vcruntime.modulemap Failed: ${_output} " )
117
- endif ()
118
-
119
80
set (CoreLibs
120
81
LLVMSupport
121
82
SwiftShims
@@ -128,36 +89,35 @@ set(CoreLibs
128
89
Concurrency
129
90
Concurrency/InternalShims)
130
91
131
- # Add these as we get them building
132
- # Demangling
133
-
134
92
foreach (library ${CoreLibs} )
135
93
copy_library_sources(${library} "public" "Core" )
136
94
endforeach ()
137
95
138
- message (STATUS "CRT[${StdlibSources} /public/Platform] -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/CRT" )
139
- foreach (file ucrt.swift Platform.swift POSIXError.swift TiocConstants.swift tgmath.swift.gyb)
140
- file (COPY_FILE
141
- "${StdlibSources} /public/Platform/${file} "
142
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/CRT/${file} "
143
- RESULT _output
144
- ONLY_IF_DIFFERENT)
145
- if (_output)
146
- message (SEND_ERROR
147
- "Copy Platform/${file} -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/CRT/${file} Failed: ${_output} " )
148
- endif ()
149
- endforeach ()
96
+ message (STATUS "plist[${StdlibSources} /Info.plist.in] -> Core/Info.plist.in" )
97
+ copy_files("" "Core" FILES "Info.plist.in" )
150
98
99
+ # Platform Overlays
100
+
101
+ # Windows Overlay
151
102
message (STATUS "WinSDK[${StdlibSources} /public/Windows] -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/WinSDK" )
152
- file (COPY_FILE
153
- "${StdlibSources} /public/Windows/WinSDK.swift"
154
- "${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/WinSDK/WinSDK.swift"
155
- RESULT _output
156
- ONLY_IF_DIFFERENT)
157
- if (_output)
158
- message (SEND_ERROR
159
- "Copy Windows/WinSDK.swift -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/WinSDK/WinSDK.swift Failed: ${_output} " )
160
- endif ()
103
+ copy_files(public /Windows Overlay/Windows/WinSDK FILES WinSDK.swift)
104
+
105
+ message (STATUS "Windows Modulemaps[${StdlibSources} /Platform] -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/clang" )
106
+ copy_files(public /Platform Overlay/Windows/clang
107
+ FILES
108
+ ucrt.modulemap
109
+ winsdk.modulemap
110
+ vcruntime.modulemap
111
+ vcruntime.apinotes)
112
+
113
+ message (STATUS "CRT[${StdlibSources} /public/Platform] -> ${CMAKE_CURRENT_LIST_DIR} /Overlay/Windows/CRT" )
114
+ copy_files(public /Platform Overlay/Windows/CRT
115
+ FILES
116
+ ucrt.swift
117
+ Platform.swift
118
+ POSIXError.swift
119
+ TiocConstants.swift
120
+ tgmath.swift.gyb)
161
121
162
122
# TODO: Add source directories for the platform overlays, supplemental
163
123
# libraries, and test support libraries.
0 commit comments