Skip to content

Commit

Permalink
[Build] Update compile definitions for WASI target
Browse files Browse the repository at this point in the history
`U_TIMEZONE` must not be defined and dynamic loading features must be
disabled for WASI target.
  • Loading branch information
kateinoigakukun committed Aug 2, 2024
1 parent a36358f commit 7a2d6bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,22 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
$<$<COMPILE_LANGUAGE:C,CXX>:U_TIMEZONE=_timezone>
$<$<COMPILE_LANGUAGE:C,CXX>:_CRT_SECURE_NO_DEPRECATE>
$<$<COMPILE_LANGUAGE:C,CXX>:U_PLATFORM_USES_ONLY_WIN32_API>)
else()
add_compile_definitions(
$<$<COMPILE_LANGUAGE:C,CXX>:U_TIMEZONE=timezone>)
endif()
# WASI specific settings
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
elseif(CMAKE_SYSTEM_NAME STREQUAL WASI)
# WASI specific settings
add_compile_definitions(
$<$<COMPILE_LANGUAGE:C,CXX>:U_HAVE_TZSET=0>
$<$<COMPILE_LANGUAGE:C,CXX>:U_HAVE_TZNAME=0>
$<$<COMPILE_LANGUAGE:C,CXX>:U_HAVE_TIMEZONE=0>
$<$<COMPILE_LANGUAGE:C,CXX>:HAVE_DLFCN_H=0>
$<$<COMPILE_LANGUAGE:C,CXX>:HAVE_DLOPEN=0>
$<$<COMPILE_LANGUAGE:C,CXX>:U_ENABLE_DYLOAD=0>
$<$<COMPILE_LANGUAGE:C,CXX>:_WASI_EMULATED_SIGNAL>
$<$<COMPILE_LANGUAGE:C,CXX>:_WASI_EMULATED_MMAN>)
add_link_options("-Lwasi-emulated-signal")
add_link_options("-Lwasi-emulated-mman")
else()
add_compile_definitions(
$<$<COMPILE_LANGUAGE:C,CXX>:U_TIMEZONE=timezone>)
endif()

if(BUILD_SHARED_LIBS)
Expand Down
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var buildSettings: [CXXSetting] = [
.define("U_COMMON_IMPLEMENTATION"),
.define("U_I18N_IMPLEMENTATION"),
.define("U_IO_IMPLEMENTATION"),
.define("HAVE_DLFCN_H", to: "0", .when(platforms: [.wasi])),
.define("HAVE_DLOPEN", to: "0", .when(platforms: [.wasi])),
.define("U_ENABLE_DYLOAD", to: "0", .when(platforms: [.wasi])),

// Where data are stored
.define("ICU_DATA_DIR", to: "\"/usr/share/icu/\""),
.define("USE_PACKAGE_DATA", to: "1"),
Expand Down

0 comments on commit 7a2d6bd

Please sign in to comment.