From 7e6a57e407b1510b372aa318b4fc6581e684988b Mon Sep 17 00:00:00 2001 From: Holden Warriner Date: Tue, 9 Jul 2024 15:40:25 -0400 Subject: [PATCH] Clean up ICU initialization (#3797) Now that ICU data is linked into the Cobalt binary, ICU no longer loads the data package from the file system. b/209049814 --- starboard/client_porting/icu_init/icu_init.cc | 20 ++++--------------- starboard/client_porting/icu_init/icu_init.h | 2 +- third_party/icu/source/common/udata.cpp | 5 +++++ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/starboard/client_porting/icu_init/icu_init.cc b/starboard/client_porting/icu_init/icu_init.cc index 35cf08ddd0eb..d2fca9df3bc1 100644 --- a/starboard/client_porting/icu_init/icu_init.cc +++ b/starboard/client_porting/icu_init/icu_init.cc @@ -33,24 +33,12 @@ namespace { // Once control for initializing ICU. pthread_once_t g_initialization_once = PTHREAD_ONCE_INIT; -// Initializes ICU and TimeZones so the rest of the functions will work. Should -// only be called once. +// Should only be called once. void Initialize() { - // Minimal Initialization of ICU. - std::vector base_path(kSbFileMaxPath); - bool result = SbSystemGetPath(kSbSystemPathContentDirectory, base_path.data(), - base_path.size()); - SB_DCHECK(result); - - std::string data_path(base_path.data()); - data_path += kSbFileSepString; - data_path += "icu"; - - // set this as the data directory. - u_setDataDirectory(data_path.c_str()); - UErrorCode err = U_ZERO_ERROR; - udata_setFileAccess(UDATA_PACKAGES_FIRST, &err); + + // ICU data is linked into the binary. + udata_setFileAccess(UDATA_NO_FILES, &err); SB_DCHECK(err <= U_ZERO_ERROR); } diff --git a/starboard/client_porting/icu_init/icu_init.h b/starboard/client_porting/icu_init/icu_init.h index 40553a19435a..bdc7856c162b 100644 --- a/starboard/client_porting/icu_init/icu_init.h +++ b/starboard/client_porting/icu_init/icu_init.h @@ -17,7 +17,7 @@ #if defined(STARBOARD) -// Initializes ICU using a standard path based on the Starboard content path. +// Does minimal initialization of ICU. // This function must be threadsafe and idempotent. Applications that wish to // initialize ICU differently may define their own IcuInit function rather // than using the implementation here. diff --git a/third_party/icu/source/common/udata.cpp b/third_party/icu/source/common/udata.cpp index e7cea1b7f8a0..f2bd38c81081 100644 --- a/third_party/icu/source/common/udata.cpp +++ b/third_party/icu/source/common/udata.cpp @@ -1367,6 +1367,11 @@ doOpenChoice(const char *path, const char *type, const char *name, /* Load from DLL. If we haven't attempted package load, we also haven't had any chance to try a DLL (static or setCommonData/etc) load. If we ever have a "UDATA_ONLY_FILES", add it to the or list here. */ +#if defined(STARBOARD) + /* To clarify, Cobalt links the common ICU package into the Cobalt binary. + So while this code path is followed, the data is not really loaded from + a DLL. */ +#endif // defined(STARBOARD) if(gDataFileAccess==UDATA_NO_FILES) { #ifdef UDATA_DEBUG fprintf(stderr, "Trying common data (UDATA_NO_FILES)\n");