Skip to content

Commit dfdec8a

Browse files
kateinoigakukunAnka
authored andcommitted
[build] Replace glibc specific naming in libc-like modulemap generation loop
1 parent ce71355 commit dfdec8a

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(swiftMusl ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
102102
${swift_platform_sources}
@@ -129,7 +129,7 @@ add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SD
129129
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
130130
TARGET_SDKS WASI
131131
INSTALL_IN_COMPONENT sdk-overlay
132-
DEPENDS glibc_modulemap)
132+
DEPENDS libc_modulemap)
133133

134134
add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
135135
ucrt.swift
@@ -148,116 +148,116 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE
148148
TARGET_SDKS WINDOWS
149149
INSTALL_IN_COMPONENT sdk-overlay)
150150

151-
set(glibc_modulemap_target_list)
151+
set(libc_modulemap_target_list)
152152
foreach(sdk ${SWIFT_SDKS})
153153
if("${sdk}" STREQUAL "LINUX" OR
154154
"${sdk}" STREQUAL "FREEBSD" OR
155155
"${sdk}" STREQUAL "OPENBSD" OR
156156
"${sdk}" STREQUAL "ANDROID" OR
157157
"${sdk}" STREQUAL "CYGWIN" OR
158158
"${sdk}" STREQUAL "HAIKU")
159-
set(glibc_modulemap_source "glibc.modulemap.gyb")
160-
set(glibc_header_source "SwiftGlibc.h.gyb")
159+
set(libc_modulemap_source "glibc.modulemap.gyb")
160+
set(libc_header_source "SwiftGlibc.h.gyb")
161161
elseif("${sdk}" STREQUAL "WASI")
162-
set(glibc_modulemap_source "wasi-libc.modulemap.gyb")
163-
set(glibc_header_source "SwiftWASILibc.h.gyb")
162+
set(libc_modulemap_source "wasi-libc.modulemap.gyb")
163+
set(libc_header_source "SwiftWASILibc.h.gyb")
164164
else()
165165
continue()
166166
endif()
167167

168-
string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}")
169-
string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}")
168+
string(REGEX REPLACE "\\.gyb$" "" libc_modulemap_outname "${libc_modulemap_source}")
169+
string(REGEX REPLACE "\\.gyb$" "" libc_header_outname "${libc_header_source}")
170170

171171
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
172172
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
173173
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")
174174
set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}")
175175

176-
set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}")
177-
set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}")
176+
set(libc_modulemap_out "${module_dir}/${libc_modulemap_outname}")
177+
set(libc_modulemap_out_static "${module_dir_static}/${libc_modulemap_outname}")
178178

179179
# Configure the module map based on the target. Each platform needs to
180-
# reference different headers, based on what's available in their glibc.
181-
# This is the 'glibc.modulemap' in the 'resource-dir', so
180+
# reference different headers, based on what's available in their libc.
181+
# This is the .modulemap in the 'resource-dir', so
182182
# it's the one we'll look at during the build process.
183-
handle_gyb_source_single(glibc_modulemap_target
184-
SOURCE "${glibc_modulemap_source}"
185-
OUTPUT "${glibc_modulemap_out}"
183+
handle_gyb_source_single(libc_modulemap_target
184+
SOURCE "${libc_modulemap_source}"
185+
OUTPUT "${libc_modulemap_out}"
186186
FLAGS
187187
"-DCMAKE_SDK=${sdk}")
188188

189-
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})
189+
list(APPEND libc_modulemap_target_list ${libc_modulemap_target})
190190

191-
set(glibc_header_out "${module_dir}/${glibc_header_outname}")
192-
set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}")
193-
handle_gyb_source_single(glibc_header_target
194-
SOURCE "${glibc_header_source}"
195-
OUTPUT "${glibc_header_out}"
191+
set(libc_header_out "${module_dir}/${libc_header_outname}")
192+
set(libc_header_out_static "${module_dir_static}/${libc_header_outname}")
193+
handle_gyb_source_single(libc_header_target
194+
SOURCE "${libc_header_source}"
195+
OUTPUT "${libc_header_out}"
196196
FLAGS "-DCMAKE_SDK=${sdk}")
197-
list(APPEND glibc_modulemap_target_list ${glibc_header_target})
197+
list(APPEND libc_modulemap_target_list ${libc_header_target})
198198

199199
if(SWIFT_BUILD_STATIC_STDLIB)
200200
add_custom_command_target(
201-
copy_glibc_modulemap_header_static
201+
copy_libc_modulemap_header_static
202202
COMMAND
203203
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static}
204204
COMMAND
205205
"${CMAKE_COMMAND}" "-E" "copy"
206-
${glibc_modulemap_out} ${glibc_modulemap_out_static}
206+
${libc_modulemap_out} ${libc_modulemap_out_static}
207207
COMMAND
208208
"${CMAKE_COMMAND}" "-E" "copy"
209-
${glibc_header_out} ${glibc_header_out_static}
210-
OUTPUT ${glibc_modulemap_out_static} ${glibc_header_out_static}
209+
${libc_header_out} ${libc_header_out_static}
210+
OUTPUT ${libc_modulemap_out_static} ${libc_header_out_static}
211211
DEPENDS
212-
"${glibc_modulemap_target}"
213-
"${glibc_header_target}"
214-
COMMENT "Copying Glibc modulemap and header to static resources")
212+
"${libc_modulemap_target}"
213+
"${libc_header_target}"
214+
COMMENT "Copying libc modulemap and header to static resources")
215215

216-
list(APPEND glibc_modulemap_target_list
217-
${copy_glibc_modulemap_header_static})
216+
list(APPEND libc_modulemap_target_list
217+
${copy_libc_modulemap_header_static})
218218
endif()
219219

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

227-
handle_gyb_source_single(glibc_modulemap_native_target
228-
SOURCE "${glibc_modulemap_source}"
229-
OUTPUT "${glibc_sysroot_relative_modulemap_out}"
227+
handle_gyb_source_single(libc_modulemap_native_target
228+
SOURCE "${libc_modulemap_source}"
229+
OUTPUT "${libc_sysroot_relative_modulemap_out}"
230230
FLAGS "-DCMAKE_SDK=${sdk}")
231231

232-
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target})
233-
set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out})
232+
list(APPEND libc_modulemap_target_list ${libc_modulemap_native_target})
233+
set(libc_modulemap_out ${libc_sysroot_relative_modulemap_out})
234234
endif()
235235

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

241-
swift_install_in_component(FILES "${glibc_modulemap_out}"
241+
swift_install_in_component(FILES "${libc_modulemap_out}"
242242
DESTINATION "lib/swift/${arch_subdir}"
243243
COMPONENT sdk-overlay)
244-
swift_install_in_component(FILES "${glibc_header_out}"
244+
swift_install_in_component(FILES "${libc_header_out}"
245245
DESTINATION "lib/swift/${arch_subdir}"
246246
COMPONENT sdk-overlay)
247247

248248
if(SWIFT_BUILD_STATIC_STDLIB)
249-
swift_install_in_component(FILES "${glibc_modulemap_out}"
249+
swift_install_in_component(FILES "${libc_modulemap_out}"
250250
DESTINATION "lib/swift_static/${arch_subdir}"
251251
COMPONENT sdk-overlay)
252-
swift_install_in_component(FILES "${glibc_header_out}"
252+
swift_install_in_component(FILES "${libc_header_out}"
253253
DESTINATION "lib/swift_static/${arch_subdir}"
254254
COMPONENT sdk-overlay)
255255
endif()
256256
endforeach()
257257
endforeach()
258-
add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list})
259-
set_property(TARGET glibc_modulemap PROPERTY FOLDER "Miscellaneous")
260-
add_dependencies(sdk-overlay glibc_modulemap)
258+
add_custom_target(libc_modulemap DEPENDS ${libc_modulemap_target_list})
259+
set_property(TARGET libc_modulemap PROPERTY FOLDER "Miscellaneous")
260+
add_dependencies(sdk-overlay libc_modulemap)
261261

262262
if(WINDOWS IN_LIST SWIFT_SDKS)
263263
swift_install_in_component(FILES

0 commit comments

Comments
 (0)