@@ -8,39 +8,21 @@ cmake_minimum_required(VERSION 3.21)
88# Where the standard library lives today
99set (StdlibSources "${CMAKE_CURRENT_LIST_DIR} /../stdlib" )
1010
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 ( )
1717
1818 set (full_to_prefix "${CMAKE_CURRENT_LIST_DIR} /${to_prefix} " )
1919
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} )
3921 # Get and create the directory
4022 get_filename_component (dirname ${file} DIRECTORY )
4123 file (MAKE_DIRECTORY "${full_to_prefix} /${dirname} " )
4224 file (COPY_FILE
43- "${StdlibSources } /${from_prefix} /${file} " # From
25+ "${ARG_ROOT } /${from_prefix} /${file} " # From
4426 "${full_to_prefix} /${file} " # To
4527 RESULT _output
4628 ONLY_IF_DIFFERENT)
@@ -51,6 +33,42 @@ function(copy_library_sources name from_prefix to_prefix)
5133 endforeach ()
5234endfunction ()
5335
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+
5472# Directories in the existing standard library that make up the Core project
5573
5674# Copy shared core headers
0 commit comments