From b31c6da70c7f672dfaf40bdffa61d51195d41cdd Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Sun, 30 Mar 2025 17:12:40 -0400 Subject: [PATCH 1/3] Disable embedded package data for Android --- Package.swift | 28 +++++++++++++++------------- icuSources/common/udata.cpp | 4 ++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index 06d305f..6d464dc 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,18 @@ import PackageDescription +let allPlatforms: [Platform] = [ + .iOS, + .macOS, + .tvOS, + .watchOS, + .macCatalyst, + .driverKit, + .android, + .linux, + .windows, + ] + var buildSettings: [CXXSetting] = [ .define("DEBUG", to: "1", .when(configuration: .debug)), .define("U_ATTRIBUTE_DEPRECATED", to: ""), @@ -10,18 +22,7 @@ var buildSettings: [CXXSetting] = [ .define("U_SHOW_INTERNAL_API", to: "1"), .define("U_STATIC_IMPLEMENTATION"), .define("U_TIMEZONE", to: "_timezone", .when(platforms: [.windows])), - .define( - "U_TIMEZONE", to: "timezone", - .when(platforms: [ - .iOS, - .macOS, - .tvOS, - .watchOS, - .macCatalyst, - .driverKit, - .android, - .linux, - ])), + .define("U_TIMEZONE", to: "timezone", .when(platforms: allPlatforms.filter({ $0 != .windows }))), .define("U_TIMEZONE_PACKAGE", to: "\"icutz44l\""), .define("U_HAVE_TZSET", to: "0", .when(platforms: [.wasi])), .define("U_HAVE_TZNAME", to: "0", .when(platforms: [.wasi])), @@ -45,7 +46,8 @@ var buildSettings: [CXXSetting] = [ // Where data are stored .define("ICU_DATA_DIR", to: "\"/usr/share/icu/\""), - .define("USE_PACKAGE_DATA", to: "1"), + .define("ICU_DATA_DIR_PREFIX_ENV_VAR", to: "\"ICU_DATA_DIR_PREFIX\""), + .define("USE_PACKAGE_DATA", to: "1", .when(platforms: allPlatforms.filter({ $0 != .android }))), .define("APPLE_ICU_CHANGES", to: "1"), .headerSearchPath("common"), diff --git a/icuSources/common/udata.cpp b/icuSources/common/udata.cpp index 3357e18..51bf835 100644 --- a/icuSources/common/udata.cpp +++ b/icuSources/common/udata.cpp @@ -703,6 +703,7 @@ openCommonData(const char *path, /* Path from OpenChoice? */ } #if !defined(ICU_DATA_DIR_WINDOWS) // When using the Windows system data, we expect only a single data file. +#if defined(USE_PACKAGE_DATA) int32_t i; for(i = 0; i < commonDataIndex; ++i) { if(gCommonICUDataArray[i]->pHeader == &U_ICUDATA_ENTRY_POINT) { @@ -710,6 +711,7 @@ openCommonData(const char *path, /* Path from OpenChoice? */ return nullptr; } } +#endif #endif } @@ -728,11 +730,13 @@ openCommonData(const char *path, /* Path from OpenChoice? */ */ #if !defined(ICU_DATA_DIR_WINDOWS) // When using the Windows system data, we expect only a single data file. +#if defined(USE_PACKAGE_DATA) setCommonICUDataPointer(&U_ICUDATA_ENTRY_POINT, false, pErrorCode); { Mutex lock; return gCommonICUDataArray[commonDataIndex]; } +#endif #endif } From 49fb42fd155a792c607773152b9f13a4de7ca512 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Mon, 31 Mar 2025 09:19:26 -0400 Subject: [PATCH 2/3] Combine nested #if defined blocks into one --- icuSources/common/udata.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/icuSources/common/udata.cpp b/icuSources/common/udata.cpp index 51bf835..346cae1 100644 --- a/icuSources/common/udata.cpp +++ b/icuSources/common/udata.cpp @@ -701,9 +701,8 @@ openCommonData(const char *path, /* Path from OpenChoice? */ if(gCommonICUDataArray[commonDataIndex] != nullptr) { return gCommonICUDataArray[commonDataIndex]; } -#if !defined(ICU_DATA_DIR_WINDOWS) +#if defined(USE_PACKAGE_DATA) && !defined(ICU_DATA_DIR_WINDOWS) // When using the Windows system data, we expect only a single data file. -#if defined(USE_PACKAGE_DATA) int32_t i; for(i = 0; i < commonDataIndex; ++i) { if(gCommonICUDataArray[i]->pHeader == &U_ICUDATA_ENTRY_POINT) { @@ -728,15 +727,13 @@ openCommonData(const char *path, /* Path from OpenChoice? */ setCommonICUDataPointer(uprv_getICUData_conversion(), false, pErrorCode); } */ -#if !defined(ICU_DATA_DIR_WINDOWS) +#if defined(USE_PACKAGE_DATA) && !defined(ICU_DATA_DIR_WINDOWS) // When using the Windows system data, we expect only a single data file. -#if defined(USE_PACKAGE_DATA) setCommonICUDataPointer(&U_ICUDATA_ENTRY_POINT, false, pErrorCode); { Mutex lock; return gCommonICUDataArray[commonDataIndex]; } -#endif #endif } From ccd192aba2afd2db324982c666b3a741c585ceaf Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Mon, 31 Mar 2025 19:18:12 -0400 Subject: [PATCH 3/3] Fix lack of closing #endif --- icuSources/common/udata.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/icuSources/common/udata.cpp b/icuSources/common/udata.cpp index 346cae1..aa508a3 100644 --- a/icuSources/common/udata.cpp +++ b/icuSources/common/udata.cpp @@ -710,7 +710,6 @@ openCommonData(const char *path, /* Path from OpenChoice? */ return nullptr; } } -#endif #endif }