Skip to content

Commit 42a3a19

Browse files
authored
Merge pull request #25757 from Rostepher/lay-me-out-to-dry-5.1
[Build System: CMake] Move the legacy_layouts CMake target generation into stdlib/public/legacy_layouts/CMakeLists.txt (5.1 branch).
2 parents ae66180 + b67018e commit 42a3a19

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

stdlib/CMakeLists.txt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -113,48 +113,6 @@ if(SWIFT_STDLIB_ENABLE_SIB_TARGETS)
113113
endif()
114114
swift_create_stdlib_targets("swift-test-stdlib" "" FALSE)
115115

116-
foreach(sdk ${SWIFT_SDKS})
117-
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
118-
set(platform "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
119-
set(input "${SWIFT_SOURCE_DIR}/stdlib/public/legacy_layouts/${platform}/layouts-${arch}.yaml")
120-
set(output "${SWIFTLIB_DIR}/${platform}/layouts-${arch}.yaml")
121-
122-
if(EXISTS "${input}")
123-
# Copy the input file to the build directory.
124-
add_custom_command(
125-
OUTPUT "${output}"
126-
DEPENDS "${input}"
127-
COMMAND
128-
"${CMAKE_COMMAND}" -E copy
129-
"${input}"
130-
"${output}")
131-
132-
# Define a target for this so that we can depend on it when
133-
# building Swift sources.
134-
add_custom_target(
135-
"copy-legacy-layouts-${platform}-${arch}"
136-
DEPENDS "${output}"
137-
SOURCES "${input}")
138-
139-
# Make sure we ultimately always do this as part of building the
140-
# standard library. In practice we'll do this earlier if at least
141-
# one Swift source file has changed.
142-
add_dependencies(
143-
"swift-stdlib-${platform}-${arch}"
144-
"copy-legacy-layouts-${platform}-${arch}")
145-
146-
swift_install_in_component(compiler
147-
FILES ${input}
148-
DESTINATION "lib/swift/${platform}/")
149-
else()
150-
# Add a dummy target that does nothing so we can still depend on it
151-
# later without checking if the input files exist.
152-
add_custom_target(
153-
"copy-legacy-layouts-${platform}-${arch}")
154-
endif()
155-
endforeach()
156-
endforeach()
157-
158116
add_subdirectory(public)
159117
add_subdirectory(private)
160118
add_subdirectory(tools)

stdlib/public/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if(CXX_SUPPORTS_DEFAULT_HIDDEN_VISIBILITY)
5252
list(APPEND SWIFT_RUNTIME_CORE_CXX_FLAGS "-fvisibility=hidden")
5353
endif()
5454

55+
add_subdirectory(legacy_layouts)
5556
add_subdirectory(SwiftShims)
5657

5758
if(SWIFT_BUILD_STDLIB)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
add_custom_target("copy-legacy-layouts" ALL)
2+
3+
foreach(sdk ${SWIFT_SDKS})
4+
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
5+
set(platform "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
6+
7+
set(input "${SWIFT_SOURCE_DIR}/stdlib/public/legacy_layouts/${platform}/layouts-${arch}.yaml")
8+
set(output "${SWIFTLIB_DIR}/${platform}/layouts-${arch}.yaml")
9+
10+
set(copy_target "copy-legacy-layouts-${platform}-${arch}")
11+
set(stdlib_target "swift-stdlib-${platform}-${arch}")
12+
13+
if(EXISTS "${input}")
14+
# Copy the input file to the build directory.
15+
add_custom_command(
16+
OUTPUT "${output}"
17+
DEPENDS "${input}"
18+
COMMAND "${CMAKE_COMMAND}" -E copy "${input}" "${output}")
19+
20+
# Define a target for this so that we can depend on it when
21+
# building Swift sources.
22+
add_custom_target(
23+
"${copy_target}"
24+
DEPENDS "${output}"
25+
SOURCES "${input}")
26+
27+
# Make sure we ultimately always do this as part of building the
28+
# standard library. In practice we'll do this earlier if at least
29+
# one Swift source file has changed.
30+
if(TARGET "${stdlib_target}")
31+
add_dependencies("${stdlib_target}" "${copy_target}")
32+
endif()
33+
34+
swift_install_in_component(compiler
35+
FILES "${input}"
36+
DESTINATION "lib/swift/${platform}/")
37+
else()
38+
# Add a dummy target that does nothing so we can still depend on it
39+
# later without checking if the input files exist.
40+
add_custom_target("${copy_target}")
41+
endif()
42+
43+
add_dependencies("copy-legacy-layouts" "${copy_target}")
44+
endforeach()
45+
endforeach()

0 commit comments

Comments
 (0)