Skip to content

Commit 6abae18

Browse files
kateinoigakukunrunner
authored andcommitted
[wasm][build] Install ICU static libraries under swift_static
1 parent ae83e92 commit 6abae18

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
@@ -252,10 +252,31 @@ foreach(sdk ${SWIFT_SDKS})
252252
add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix})
253253
endif()
254254

255+
string(TOLOWER "${sdk}" lowercase_sdk)
255256
# Generate the static-stdlib-args.lnk file used by -static-stdlib option for
256257
# 'GenericUnix' (eg linux)
257258
if(${SWIFT_SDK_${sdk}_OBJECT_FORMAT} STREQUAL ELF)
258259
string(TOLOWER "${sdk}" lowercase_sdk)
260+
if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
261+
set(libicu_i18n_a -licui18nswift)
262+
set(libicu_uc_a -licuucswift)
263+
set(libicu_data_a -licudataswift)
264+
else()
265+
find_package(ICU REQUIRED COMPONENTS uc i18n)
266+
get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
267+
get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
268+
269+
set(libicu_i18n_a -licui18n)
270+
set(libicu_uc_a -licuuc)
271+
set(libicu_data_a)
272+
if(EXISTS ${ICU_I18N_LIBDIR}/libicui18n.a AND
273+
EXISTS ${ICU_UC_LIBDIR}/libicuuc.a AND
274+
EXISTS ${ICU_UC_LIBDIR}/libicudata.a)
275+
set(libicu_i18n_a ${ICU_I18N_LIBDIR}/libicui18n.a)
276+
set(libicu_uc_a ${ICU_UC_LIBDIR}/libicuuc.a)
277+
set(libicu_data_a ${ICU_UC_LIBDIR}/libicudata.a)
278+
endif()
279+
endif()
259280
set(libpthread -lpthread)
260281
set(concurrency_libs)
261282
set(android_libraries)
@@ -282,6 +303,28 @@ ${concurrency_libs}
282303
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
283304
DESTINATION "lib/swift_static/${lowercase_sdk}"
284305
COMPONENT stdlib)
306+
elseif("${sdk}" STREQUAL "WASI")
307+
set(swift_icu_libs_wasi_list)
308+
set(icu_modules UC I18N DATA)
309+
foreach(module IN LISTS icu_modules)
310+
set(module_lib "${SWIFT_WASI_wasm32_ICU_${module}}")
311+
get_filename_component(module_lib_name ${module_lib} NAME)
312+
add_custom_command_target(swift_icu_${module}_${sdk}
313+
COMMAND
314+
"${CMAKE_COMMAND}" -E copy
315+
"${module_lib}"
316+
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
317+
OUTPUT
318+
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
319+
DEPENDS
320+
"${module_lib}")
321+
list(APPEND swift_icu_libs_wasi_list ${swift_icu_${module}_${sdk}})
322+
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
323+
DESTINATION "lib/swift_static/${lowercase_sdk}"
324+
COMPONENT stdlib)
325+
endforeach()
326+
add_custom_target(swift_icu_libs_wasi ALL DEPENDS ${swift_icu_libs_wasi_list})
327+
add_dependencies(stdlib swift_icu_libs_wasi)
285328
endif()
286329
endforeach()
287330
endforeach()

0 commit comments

Comments
 (0)