Skip to content

Commit c163971

Browse files
kateinoigakukunrunner
authored andcommitted
[wasm][build] Install ICU static libraries under swift_static
1 parent 287b1de commit c163971

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

stdlib/public/runtime/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,31 @@ foreach(sdk ${SWIFT_SDKS})
258258
add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix})
259259
endif()
260260

261+
string(TOLOWER "${sdk}" lowercase_sdk)
261262
# Generate the static-stdlib-args.lnk file used by -static-stdlib option for
262263
# 'GenericUnix' (eg linux)
263264
if(SWIFT_SDK_${sdk}_OBJECT_FORMAT STREQUAL "ELF")
264265
string(TOLOWER "${sdk}" lowercase_sdk)
266+
if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
267+
set(libicu_i18n_a -licui18nswift)
268+
set(libicu_uc_a -licuucswift)
269+
set(libicu_data_a -licudataswift)
270+
else()
271+
find_package(ICU REQUIRED COMPONENTS uc i18n)
272+
get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
273+
get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
274+
275+
set(libicu_i18n_a -licui18n)
276+
set(libicu_uc_a -licuuc)
277+
set(libicu_data_a)
278+
if(EXISTS ${ICU_I18N_LIBDIR}/libicui18n.a AND
279+
EXISTS ${ICU_UC_LIBDIR}/libicuuc.a AND
280+
EXISTS ${ICU_UC_LIBDIR}/libicudata.a)
281+
set(libicu_i18n_a ${ICU_I18N_LIBDIR}/libicui18n.a)
282+
set(libicu_uc_a ${ICU_UC_LIBDIR}/libicuuc.a)
283+
set(libicu_data_a ${ICU_UC_LIBDIR}/libicudata.a)
284+
endif()
285+
endif()
265286
set(libpthread -lpthread)
266287
set(concurrency_libs)
267288
set(android_libraries)
@@ -288,6 +309,28 @@ ${concurrency_libs}
288309
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
289310
DESTINATION "lib/swift_static/${lowercase_sdk}"
290311
COMPONENT stdlib)
312+
elseif("${sdk}" STREQUAL "WASI")
313+
set(swift_icu_libs_wasi_list)
314+
set(icu_modules UC I18N DATA)
315+
foreach(module IN LISTS icu_modules)
316+
set(module_lib "${SWIFT_WASI_wasm32_ICU_${module}}")
317+
get_filename_component(module_lib_name ${module_lib} NAME)
318+
add_custom_command_target(swift_icu_${module}_${sdk}
319+
COMMAND
320+
"${CMAKE_COMMAND}" -E copy
321+
"${module_lib}"
322+
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
323+
OUTPUT
324+
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
325+
DEPENDS
326+
"${module_lib}")
327+
list(APPEND swift_icu_libs_wasi_list ${swift_icu_${module}_${sdk}})
328+
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
329+
DESTINATION "lib/swift_static/${lowercase_sdk}"
330+
COMPONENT stdlib)
331+
endforeach()
332+
add_custom_target(swift_icu_libs_wasi ALL DEPENDS ${swift_icu_libs_wasi_list})
333+
add_dependencies(stdlib swift_icu_libs_wasi)
291334
endif()
292335
endforeach()
293336
endforeach()

0 commit comments

Comments
 (0)