[Export] Allow using ICU data from export templates instead of editor embedded data.

This commit is contained in:
Pāvels Nadtočajevs 2024-12-05 22:49:06 +02:00
parent 4cf02312f6
commit 3d60ce9389
9 changed files with 65 additions and 50 deletions

View file

@ -477,11 +477,9 @@ if env["builtin_icu4c"]:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
icu_data_name = "icudt76l.dat"
if env.editor_build:
env_icu.Depends("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/" + icu_data_name)
env_icu.Command("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/" + icu_data_name, make_icu_data)
env_icu.Depends("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/icudt_godot.dat")
env_icu.Command("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/icudt_godot.dat", make_icu_data)
env_text_server_adv.Prepend(CPPPATH=["#thirdparty/icu4c/"])
else:
thirdparty_sources += ["icu_data/icudata_stub.cpp"]
@ -503,7 +501,6 @@ if env["builtin_icu4c"]:
"-DU_ENABLE_DYLOAD=0",
"-DU_HAVE_LIB_SUFFIX=1",
"-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
env_text_server_adv.Append(
@ -511,7 +508,6 @@ if env["builtin_icu4c"]:
"-DU_STATIC_IMPLEMENTATION",
"-DU_HAVE_LIB_SUFFIX=1",
"-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
if env.editor_build:

View file

@ -701,12 +701,10 @@ thirdparty_icu_sources = [
]
thirdparty_icu_sources = [thirdparty_icu_dir + file for file in thirdparty_icu_sources]
icu_data_name = "icudt76l.dat"
if env["static_icu_data"]:
env_icu.Depends("../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name)
env_icu.Depends("../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/icudt_godot.dat")
env_icu.Command(
"../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name, methods.make_icu_data
"../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/icudt_godot.dat", methods.make_icu_data
)
env.Append(CXXFLAGS=["-DICU_STATIC_DATA"])
env.Append(CPPPATH=["../../../thirdparty/icu4c/"])
@ -729,7 +727,6 @@ env_icu.Append(
"-DU_ENABLE_DYLOAD=0",
"-DU_HAVE_LIB_SUFFIX=1",
"-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
env.Append(
@ -737,7 +734,6 @@ env.Append(
"-DU_STATIC_IMPLEMENTATION",
"-DU_HAVE_LIB_SUFFIX=1",
"-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
env.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])

View file

@ -442,23 +442,23 @@ bool TextServerAdvanced::_load_support_data(const String &p_filename) {
#else
if (!icu_data_loaded) {
UErrorCode err = U_ZERO_ERROR;
#ifdef ICU_DATA_NAME
String filename = (p_filename.is_empty()) ? String("res://") + _MKSTR(ICU_DATA_NAME) : p_filename;
String filename = (p_filename.is_empty()) ? String("res://icudt_godot.dat") : p_filename;
if (FileAccess::exists(filename)) {
Ref<FileAccess> f = FileAccess::open(filename, FileAccess::READ);
if (f.is_null()) {
return false;
}
uint64_t len = f->get_length();
icu_data = f->get_buffer(len);
Ref<FileAccess> f = FileAccess::open(filename, FileAccess::READ);
if (f.is_null()) {
return false;
}
uint64_t len = f->get_length();
icu_data = f->get_buffer(len);
udata_setCommonData(icu_data.ptr(), &err);
if (U_FAILURE(err)) {
ERR_FAIL_V_MSG(false, u_errorName(err));
}
udata_setCommonData(icu_data.ptr(), &err);
if (U_FAILURE(err)) {
ERR_FAIL_V_MSG(false, u_errorName(err));
err = U_ZERO_ERROR;
}
err = U_ZERO_ERROR;
#endif
u_init(&err);
if (U_FAILURE(err)) {
ERR_FAIL_V_MSG(false, u_errorName(err));
@ -470,11 +470,11 @@ bool TextServerAdvanced::_load_support_data(const String &p_filename) {
}
String TextServerAdvanced::_get_support_data_filename() const {
return _MKSTR(ICU_DATA_NAME);
return String("icudt_godot.dat");
}
String TextServerAdvanced::_get_support_data_info() const {
return String("ICU break iteration data (") + _MKSTR(ICU_DATA_NAME) + String(").");
return String("ICU break iteration data (\"icudt_godot.dat\").");
}
bool TextServerAdvanced::_save_support_data(const String &p_filename) const {