Skip to content

Commit 7dd7b3d

Browse files
committed
Install ICU with CMake
1 parent 97e31ef commit 7dd7b3d

File tree

7 files changed

+40
-44
lines changed

7 files changed

+40
-44
lines changed

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,36 @@ function(swift_icu_variables_set sdk arch result)
897897
endif()
898898
endfunction()
899899

900+
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL "WASI")
901+
set(WASI_ICU_URL "" CACHE STRING
902+
"Download URL for the WASI ICU distribution")
903+
set(WASI_ICU_MD5 "" CACHE STRING
904+
"The expected MD5 hash of the WASI ICU distribution archive")
905+
906+
file(DOWNLOAD "${WASI_ICU_URL}" "${SWIFT_SOURCE_DIR}/../icu.tar.xz"
907+
EXPECTED_HASH MD5=${WASI_ICU_MD5})
908+
909+
get_filename_component(SWIFT_SOURCE_BASEDIR "${SWIFT_SOURCE_DIR}" DIRECTORY)
910+
set(WASI_ICU_OUT_LIB "${SWIFT_SOURCE_BASEDIR}/icu_out/lib")
911+
set(SWIFT_WASI_wasm32_ICU_UC_INCLUDE "${SWIFT_SOURCE_BASEDIR}/icu_out/include")
912+
set(SWIFT_WASI_wasm32_ICU_I18N_INCLUDE "${SWIFT_SOURCE_BASEDIR}/icu_out/include")
913+
set(SWIFT_WASI_wasm32_ICU_UC "${WASI_ICU_OUT_LIB}/libicuuc.a")
914+
set(SWIFT_WASI_wasm32_ICU_I18N "${WASI_ICU_OUT_LIB}/libicui18n.a")
915+
set(SWIFT_WASI_wasm32_ICU_DATA "${WASI_ICU_OUT_LIB}/libicudata.a")
916+
917+
set(WASI_ICU_DISTRIBUTION_TARGET)
918+
add_custom_command_target(WASI_ICU_DISTRIBUTION_TARGET
919+
COMMAND
920+
${CMAKE_COMMAND} -E
921+
tar xfv "${SWIFT_SOURCE_BASEDIR}/icu.tar.xz"
922+
WORKING_DIRECTORY
923+
"${SWIFT_SOURCE_BASEDIR}"
924+
OUTPUT
925+
"${SWIFT_WASI_wasm32_ICU_DATA}"
926+
"${SWIFT_WASI_wasm32_ICU_I18N}"
927+
"${SWIFT_WASI_wasm32_ICU_UC}")
928+
endif()
929+
900930
# ICU is provided through CoreFoundation on Darwin. On other hosts, if the ICU
901931
# unicode and i18n include and library paths are not defined, perform a standard
902932
# package lookup. Otherwise, rely on the paths specified by the user. These

stdlib/public/stubs/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS})
2727
list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS)
2828
list(APPEND swift_stubs_c_compile_flags -I${SWIFT_SOURCE_DIR}/include)
2929

30+
set(swift_stubs_dependencies)
31+
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL "WASI")
32+
list(APPEND swift_stubs_dependencies ${WASI_ICU_DISTRIBUTION_TARGET})
33+
endif()
34+
3035
add_swift_target_library(swiftStdlibStubs
36+
DEPENDS
37+
${swift_stubs_dependencies}
3138
OBJECT_LIBRARY
3239
${swift_stubs_sources}
3340
${swift_stubs_objc_sources}

utils/build-script

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,9 @@ def validate_arguments(toolchain, args):
215215
"--android-icu-i18n-include, and --android-icu-data "
216216
"must be specified")
217217
if args.wasm:
218-
if args.wasi_sdk is None or \
219-
args.wasi_icu_uc is None or \
220-
args.wasi_icu_uc_include is None or \
221-
args.wasi_icu_i18n is None or \
222-
args.wasi_icu_i18n_include is None or \
223-
args.wasi_icu_data is None:
224-
diagnostics.fatal(
225-
"when building for WebAssembly, --wasi-sdk, "
226-
"--wasi-icu-uc, "
227-
"--wasi-icu-uc-include, --wasi-icu-i18n, "
228-
"--wasi-icu-i18n-include, and --wasi-icu-data "
229-
"must be specified")
218+
if args.wasi_sdk is None:
219+
fatal_error(
220+
"when building for WebAssembly, --wasi-sdk must be specified")
230221

231222
targets_needing_toolchain = [
232223
'build_indexstoredb',
@@ -708,11 +699,6 @@ class BuildScriptInvocation(object):
708699
if args.wasm:
709700
impl_args += [
710701
"--wasi-sdk", args.wasi_sdk,
711-
"--wasi-icu-uc", args.wasi_icu_uc,
712-
"--wasi-icu-uc-include", args.wasi_icu_uc_include,
713-
"--wasi-icu-i18n", args.wasi_icu_i18n,
714-
"--wasi-icu-i18n-include", args.wasi_icu_i18n_include,
715-
"--wasi-icu-data", args.wasi_icu_data,
716702
]
717703

718704
if platform.system() == 'Darwin':

utils/build-script-impl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ KNOWN_SETTINGS=(
118118

119119
## WebAssembly/WASI Options
120120
wasi-sdk "" "An absolute path to the WASI SDK that will be used as a libc implementation for Wasm builds"
121-
wasi-icu-uc "" "Path to libicuuc.so"
122-
wasi-icu-uc-include "" "Path to a directory containing headers for libicuuc"
123-
wasi-icu-i18n "" "Path to libicui18n.so"
124-
wasi-icu-i18n-include "" "Path to a directory containing headers libicui18n"
125-
wasi-icu-data "" "Path to libicudata.so"
126121

127122
## Build Types for Components
128123
swift-stdlib-build-type "Debug" "the CMake build variant for Swift"
@@ -1694,11 +1689,6 @@ for host in "${ALL_HOSTS[@]}"; do
16941689
cmake_options=(
16951690
"${cmake_options[@]}"
16961691
-DSWIFT_WASI_SDK_PATH:STRING="${WASI_SDK}"
1697-
-DSWIFT_WASI_wasm32_ICU_UC:STRING="${WASI_ICU_UC}"
1698-
-DSWIFT_WASI_wasm32_ICU_UC_INCLUDE:STRING="${WASI_ICU_UC_INCLUDE}"
1699-
-DSWIFT_WASI_wasm32_ICU_I18N:STRING="${WASI_ICU_I18N}"
1700-
-DSWIFT_WASI_wasm32_ICU_I18N_INCLUDE:STRING="${WASI_ICU_I18N_INCLUDE}"
1701-
-DSWIFT_WASI_wasm32_ICU_DATA:STRING="${WASI_ICU_DATA}"
17021692
)
17031693
fi
17041694

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,17 +1095,6 @@ def create_argument_parser():
10951095
help='An absolute path to WASI SDK that will be used as a libc '
10961096
'implementation for Wasm builds')
10971097

1098-
option('--wasi-icu-uc', store_path,
1099-
help='Path to libicuuc.so')
1100-
option('--wasi-icu-uc-include', store_path,
1101-
help='Path to a directory containing headers for libicuuc')
1102-
option('--wasi-icu-i18n', store_path,
1103-
help='Path to libicui18n.so')
1104-
option('--wasi-icu-i18n-include', store_path,
1105-
help='Path to a directory containing headers libicui18n')
1106-
option('--wasi-icu-data', store_path,
1107-
help='Path to libicudata.so')
1108-
11091098
# -------------------------------------------------------------------------
11101099
in_group('Experimental language features')
11111100

utils/webassembly/linux/install-dependencies.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ $SWIFT_PATH/utils/webassembly/install-wasi-sdk.sh linux ubuntu
4343
# with os and environment name `getMultiarchTriple`.
4444
ln -s wasm32-wasi wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi-unknown
4545

46-
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/0.5.0/icu4c-wasi.tar.xz"
47-
tar xf icu.tar.xz
48-
4946
# Install sccache
5047

5148
if [ -z $(which sccache) ]; then

utils/webassembly/macos/install-dependencies.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,3 @@ ln -s ../include wasi-sdk/share/wasi-sysroot/usr/include
2222
# Link wasm32-wasi-unknown to wasm32-wasi because clang finds crt1.o from sysroot
2323
# with os and environment name `getMultiarchTriple`.
2424
ln -s wasm32-wasi wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi-unknown
25-
26-
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/0.5.0/icu4c-wasi.tar.xz"
27-
tar xf icu.tar.xz

0 commit comments

Comments
 (0)