@@ -8,39 +8,21 @@ 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 )
@@ -51,6 +33,42 @@ function(copy_library_sources name from_prefix to_prefix)
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
0 commit comments