mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Android timezone data load for adb-shell
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
a130b108a5
commit
e44005a1d2
4 changed files with 49 additions and 0 deletions
|
|
@ -293,6 +293,7 @@ extern "C" {
|
|||
#if defined(OS_WINDOWS)
|
||||
#include <icu.h>
|
||||
#else
|
||||
#include <unicode/utypes.h>
|
||||
#include <unicode/locid.h>
|
||||
#include <unicode/uchar.h>
|
||||
#include <unicode/ustring.h>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,41 @@
|
|||
#include "runtime/ScriptFunctionObject.h"
|
||||
#include "runtime/ScriptSimpleFunctionObject.h"
|
||||
|
||||
// https://cs.android.com/android/platform/superproject/main/+/main:external/icu/libandroidicuinit/IcuRegistration.cpp
|
||||
#if defined(OS_ANDROID) && defined(ENABLE_ICU) && defined(ESCARGOT_ENABLE_TEST)
|
||||
#include <sys/stat.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
static bool directoryExists(const char* path)
|
||||
{
|
||||
struct stat info;
|
||||
if (stat(path, &info) != 0)
|
||||
return false;
|
||||
else
|
||||
return (info.st_mode & S_IFDIR) != 0;
|
||||
}
|
||||
|
||||
static std::string getTimeZoneModulePath()
|
||||
{
|
||||
const char* tzdataModulePathPrefix = getenv("ANDROID_TZDATA_ROOT");
|
||||
if (tzdataModulePathPrefix == NULL) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ret;
|
||||
|
||||
for (int version = 1; version < 128; version++) {
|
||||
std::string tzdataModulePath = tzdataModulePathPrefix;
|
||||
tzdataModulePath += "/etc/tz/versioned/" + std::to_string(version) + "/icu";
|
||||
if (directoryExists(tzdataModulePath.data())) {
|
||||
ret = tzdataModulePath;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Escargot {
|
||||
|
||||
bool Global::inited;
|
||||
|
|
@ -60,6 +95,15 @@ void Global::initialize(Platform* platform)
|
|||
DECLARE_SCRIPTSIMPLEFUNCTION_LIST(INIT_SCRIPTSIMPLEFUNCTION_TAGS);
|
||||
#undef INIT_SCRIPTSIMPLEFUNCTION_TAGS
|
||||
|
||||
#if defined(OS_ANDROID) && defined(ENABLE_ICU) && defined(ESCARGOT_ENABLE_TEST)
|
||||
// android timezone data load for adb-shell
|
||||
std::string tzPath = getTimeZoneModulePath();
|
||||
if (tzPath.size()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
u_setTimeZoneFilesDirectory(tzPath.data(), &status);
|
||||
}
|
||||
#endif
|
||||
|
||||
inited = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
third_party/runtime_icu_binder/ICUPolyfill.h
vendored
2
third_party/runtime_icu_binder/ICUPolyfill.h
vendored
|
|
@ -20,6 +20,8 @@
|
|||
#include "RuntimeICUBinder.h"
|
||||
|
||||
#define u_getVersion RuntimeICUBinder::ICU::instance().u_getVersion
|
||||
#define u_setDataDirectory RuntimeICUBinder::ICU::instance().u_setDataDirectory
|
||||
#define u_setTimeZoneFilesDirectory RuntimeICUBinder::ICU::instance().u_setTimeZoneFilesDirectory
|
||||
|
||||
#define u_tolower RuntimeICUBinder::ICU::instance().u_tolower
|
||||
#define u_toupper RuntimeICUBinder::ICU::instance().u_toupper
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ namespace RuntimeICUBinder {
|
|||
|
||||
#define FOR_EACH_UC_VOID_OP(F) \
|
||||
F(u_getVersion, void(CALLCONV*)(UVersionInfo versionArray), void) \
|
||||
F(u_setDataDirectory, void(CALLCONV*)(const char*), void) \
|
||||
F(u_setTimeZoneFilesDirectory, void(CALLCONV*)(const char*, UErrorCode*), void) \
|
||||
F(uiter_setString, void(CALLCONV*)(UCharIterator * iter, const UChar* s, int32_t length), void) \
|
||||
F(ucnv_close, void(CALLCONV*)(UConverter * converter), void) \
|
||||
F(ucnv_toUnicode, void(CALLCONV*)(UConverter * converter, UChar * *target, const UChar* targetLimit, const char** source, const char* sourceLimit, int32_t* offsets, UBool flush, UErrorCode* err), void) \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue