Skip to content

Commit 66691ee

Browse files
committed
[Build System: CMake] Move the legacy_layouts CMake target generation into stdlib/public/legacy_layouts/CMakeLists.txt.
Any time users build and install the compiler they should also be installing the legacy_layouts for the same Darwin platforms.
1 parent ce5b3cc commit 66691ee

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,8 @@ endif()
10781078
if(SWIFT_BUILD_STDLIB)
10791079
add_subdirectory(stdlib)
10801080
else()
1081+
add_subdirectory(stdlib/public/legacy_layouts)
1082+
10811083
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10821084
# ensure we build that when building tools.
10831085
if(SWIFT_INCLUDE_TOOLS)

stdlib/CMakeLists.txt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -128,48 +128,6 @@ if(SWIFT_STDLIB_ENABLE_SIB_TARGETS)
128128
endif()
129129
swift_create_stdlib_targets("swift-test-stdlib" "" FALSE)
130130

131-
foreach(sdk ${SWIFT_SDKS})
132-
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
133-
set(platform "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
134-
set(input "${SWIFT_SOURCE_DIR}/stdlib/public/legacy_layouts/${platform}/layouts-${arch}.yaml")
135-
set(output "${SWIFTLIB_DIR}/${platform}/layouts-${arch}.yaml")
136-
137-
if(EXISTS "${input}")
138-
# Copy the input file to the build directory.
139-
add_custom_command(
140-
OUTPUT "${output}"
141-
DEPENDS "${input}"
142-
COMMAND
143-
"${CMAKE_COMMAND}" -E copy
144-
"${input}"
145-
"${output}")
146-
147-
# Define a target for this so that we can depend on it when
148-
# building Swift sources.
149-
add_custom_target(
150-
"copy-legacy-layouts-${platform}-${arch}"
151-
DEPENDS "${output}"
152-
SOURCES "${input}")
153-
154-
# Make sure we ultimately always do this as part of building the
155-
# standard library. In practice we'll do this earlier if at least
156-
# one Swift source file has changed.
157-
add_dependencies(
158-
"swift-stdlib-${platform}-${arch}"
159-
"copy-legacy-layouts-${platform}-${arch}")
160-
161-
swift_install_in_component(FILES ${input}
162-
DESTINATION "lib/swift/${platform}/"
163-
COMPONENT compiler)
164-
else()
165-
# Add a dummy target that does nothing so we can still depend on it
166-
# later without checking if the input files exist.
167-
add_custom_target(
168-
"copy-legacy-layouts-${platform}-${arch}")
169-
endif()
170-
endforeach()
171-
endforeach()
172-
173131
add_subdirectory(public)
174132
add_subdirectory(private)
175133
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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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(
35+
FILES "${input}"
36+
DESTINATION "lib/swift/${platform}/"
37+
COMPONENT compiler)
38+
else()
39+
# Add a dummy target that does nothing so we can still depend on it
40+
# later without checking if the input files exist.
41+
add_custom_target("${copy_target}")
42+
endif()
43+
44+
add_dependencies("copy-legacy-layouts" "${copy_target}")
45+
endforeach()
46+
endforeach()

0 commit comments

Comments
 (0)