Skip to content

Commit aa845fb

Browse files
[build] Replace glibc specific naming in libc-like modulemap generation loop
1 parent 15d3377 commit aa845fb

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

stdlib/public/Platform/CMakeLists.txt

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O
9696
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
9797
TARGET_SDKS "${swiftGlibc_target_sdks}"
9898
INSTALL_IN_COMPONENT sdk-overlay
99-
DEPENDS glibc_modulemap)
99+
DEPENDS libc_modulemap)
100100

101101
add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
102102
${swift_platform_sources}
@@ -113,7 +113,7 @@ add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SD
113113
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
114114
TARGET_SDKS WASI
115115
INSTALL_IN_COMPONENT sdk-overlay
116-
DEPENDS glibc_modulemap)
116+
DEPENDS libc_modulemap)
117117

118118
add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
119119
ucrt.swift
@@ -132,116 +132,116 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE
132132
TARGET_SDKS WINDOWS
133133
INSTALL_IN_COMPONENT sdk-overlay)
134134

135-
set(glibc_modulemap_target_list)
135+
set(libc_modulemap_target_list)
136136
foreach(sdk ${SWIFT_SDKS})
137137
if("${sdk}" STREQUAL "LINUX" OR
138138
"${sdk}" STREQUAL "FREEBSD" OR
139139
"${sdk}" STREQUAL "OPENBSD" OR
140140
"${sdk}" STREQUAL "ANDROID" OR
141141
"${sdk}" STREQUAL "CYGWIN" OR
142142
"${sdk}" STREQUAL "HAIKU")
143-
set(glibc_modulemap_source "glibc.modulemap.gyb")
144-
set(glibc_header_source "SwiftGlibc.h.gyb")
143+
set(libc_modulemap_source "glibc.modulemap.gyb")
144+
set(libc_header_source "SwiftGlibc.h.gyb")
145145
elseif("${sdk}" STREQUAL "WASI")
146-
set(glibc_modulemap_source "wasi-libc.modulemap.gyb")
147-
set(glibc_header_source "SwiftWASILibc.h.gyb")
146+
set(libc_modulemap_source "wasi-libc.modulemap.gyb")
147+
set(libc_header_source "SwiftWASILibc.h.gyb")
148148
else()
149149
continue()
150150
endif()
151151

152-
string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}")
153-
string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}")
152+
string(REGEX REPLACE "\\.gyb$" "" libc_modulemap_outname "${libc_modulemap_source}")
153+
string(REGEX REPLACE "\\.gyb$" "" libc_header_outname "${libc_header_source}")
154154

155155
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
156156
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
157157
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")
158158
set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}")
159159

160-
set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}")
161-
set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}")
160+
set(libc_modulemap_out "${module_dir}/${libc_modulemap_outname}")
161+
set(libc_modulemap_out_static "${module_dir_static}/${libc_modulemap_outname}")
162162

163163
# Configure the module map based on the target. Each platform needs to
164-
# reference different headers, based on what's available in their glibc.
165-
# This is the 'glibc.modulemap' in the 'resource-dir', so
164+
# reference different headers, based on what's available in their libc.
165+
# This is the .modulemap in the 'resource-dir', so
166166
# it's the one we'll look at during the build process.
167-
handle_gyb_source_single(glibc_modulemap_target
168-
SOURCE "${glibc_modulemap_source}"
169-
OUTPUT "${glibc_modulemap_out}"
167+
handle_gyb_source_single(libc_modulemap_target
168+
SOURCE "${libc_modulemap_source}"
169+
OUTPUT "${libc_modulemap_out}"
170170
FLAGS
171171
"-DCMAKE_SDK=${sdk}")
172172

173-
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})
173+
list(APPEND libc_modulemap_target_list ${libc_modulemap_target})
174174

175-
set(glibc_header_out "${module_dir}/${glibc_header_outname}")
176-
set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}")
177-
handle_gyb_source_single(glibc_header_target
178-
SOURCE "${glibc_header_source}"
179-
OUTPUT "${glibc_header_out}"
175+
set(libc_header_out "${module_dir}/${libc_header_outname}")
176+
set(libc_header_out_static "${module_dir_static}/${libc_header_outname}")
177+
handle_gyb_source_single(libc_header_target
178+
SOURCE "${libc_header_source}"
179+
OUTPUT "${libc_header_out}"
180180
FLAGS "-DCMAKE_SDK=${sdk}")
181-
list(APPEND glibc_modulemap_target_list ${glibc_header_target})
181+
list(APPEND libc_modulemap_target_list ${libc_header_target})
182182

183183
if(SWIFT_BUILD_STATIC_STDLIB)
184184
add_custom_command_target(
185-
copy_glibc_modulemap_header_static
185+
copy_libc_modulemap_header_static
186186
COMMAND
187187
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static}
188188
COMMAND
189189
"${CMAKE_COMMAND}" "-E" "copy"
190-
${glibc_modulemap_out} ${glibc_modulemap_out_static}
190+
${libc_modulemap_out} ${libc_modulemap_out_static}
191191
COMMAND
192192
"${CMAKE_COMMAND}" "-E" "copy"
193-
${glibc_header_out} ${glibc_header_out_static}
194-
OUTPUT ${glibc_modulemap_out_static} ${glibc_header_out_static}
193+
${libc_header_out} ${libc_header_out_static}
194+
OUTPUT ${libc_modulemap_out_static} ${libc_header_out_static}
195195
DEPENDS
196-
"${glibc_modulemap_target}"
197-
"${glibc_header_target}"
198-
COMMENT "Copying Glibc modulemap and header to static resources")
196+
"${libc_modulemap_target}"
197+
"${libc_header_target}"
198+
COMMENT "Copying libc modulemap and header to static resources")
199199

200-
list(APPEND glibc_modulemap_target_list
201-
${copy_glibc_modulemap_header_static})
200+
list(APPEND libc_modulemap_target_list
201+
${copy_libc_modulemap_header_static})
202202
endif()
203203

204204
# If this SDK is a target for a non-native host, except if it's for Android
205205
# with its own native sysroot, create a native modulemap without a sysroot
206206
# prefix. This is the one we'll install instead.
207207
if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND
208208
NOT (${sdk} STREQUAL ANDROID AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL ""))
209-
set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${glibc_modulemap_outname}")
209+
set(libc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${libc_modulemap_outname}")
210210

211-
handle_gyb_source_single(glibc_modulemap_native_target
212-
SOURCE "${glibc_modulemap_source}"
213-
OUTPUT "${glibc_sysroot_relative_modulemap_out}"
211+
handle_gyb_source_single(libc_modulemap_native_target
212+
SOURCE "${libc_modulemap_source}"
213+
OUTPUT "${libc_sysroot_relative_modulemap_out}"
214214
FLAGS "-DCMAKE_SDK=${sdk}")
215215

216-
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target})
217-
set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out})
216+
list(APPEND libc_modulemap_target_list ${libc_modulemap_native_target})
217+
set(libc_modulemap_out ${libc_sysroot_relative_modulemap_out})
218218
endif()
219219

220220
# FIXME: When SDK is a cross-compile target (SDK != Host), the generated
221221
# modulemap will be relative to the Host, with hardcoded paths.
222222
# It is not relocatable to the target platform itself.
223223
# This affects any cross-compiled targets that use glibc.modulemap.
224224

225-
swift_install_in_component(FILES "${glibc_modulemap_out}"
225+
swift_install_in_component(FILES "${libc_modulemap_out}"
226226
DESTINATION "lib/swift/${arch_subdir}"
227227
COMPONENT sdk-overlay)
228-
swift_install_in_component(FILES "${glibc_header_out}"
228+
swift_install_in_component(FILES "${libc_header_out}"
229229
DESTINATION "lib/swift/${arch_subdir}"
230230
COMPONENT sdk-overlay)
231231

232232
if(SWIFT_BUILD_STATIC_STDLIB)
233-
swift_install_in_component(FILES "${glibc_modulemap_out}"
233+
swift_install_in_component(FILES "${libc_modulemap_out}"
234234
DESTINATION "lib/swift_static/${arch_subdir}"
235235
COMPONENT sdk-overlay)
236-
swift_install_in_component(FILES "${glibc_header_out}"
236+
swift_install_in_component(FILES "${libc_header_out}"
237237
DESTINATION "lib/swift_static/${arch_subdir}"
238238
COMPONENT sdk-overlay)
239239
endif()
240240
endforeach()
241241
endforeach()
242-
add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list})
243-
set_property(TARGET glibc_modulemap PROPERTY FOLDER "Miscellaneous")
244-
add_dependencies(sdk-overlay glibc_modulemap)
242+
add_custom_target(libc_modulemap DEPENDS ${libc_modulemap_target_list})
243+
set_property(TARGET libc_modulemap PROPERTY FOLDER "Miscellaneous")
244+
add_dependencies(sdk-overlay libc_modulemap)
245245

246246
if(WINDOWS IN_LIST SWIFT_SDKS)
247247
swift_install_in_component(FILES

0 commit comments

Comments
 (0)