Skip to content

Commit 32339e2

Browse files
kateinoigakukunrunner
authored andcommitted
[wasm][build] Install ICU static libraries under swift_static
1 parent 636419e commit 32339e2

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
@@ -256,10 +256,31 @@ foreach(sdk ${SWIFT_SDKS})
256256
add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix})
257257
endif()
258258

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

0 commit comments

Comments
 (0)