diff --git a/doc/classes/EditorExportPlatform.xml b/doc/classes/EditorExportPlatform.xml index 250a03f895f..54bad2db360 100644 --- a/doc/classes/EditorExportPlatform.xml +++ b/doc/classes/EditorExportPlatform.xml @@ -125,8 +125,10 @@ Returns array of core file names that always should be exported regardless of preset config. - + + + Returns additional files that should always be exported regardless of preset configuration, and are not part of the project source. The returned [Dictionary] contains filename keys ([String]) and their corresponding raw data ([PackedByteArray]). diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index cb496fc9f09..f5723ed6cb3 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -900,19 +900,49 @@ String EditorExportPlatform::_get_script_encryption_key(const Refget_script_encryption_key().to_lower(); } -Dictionary EditorExportPlatform::get_internal_export_files() { +Dictionary EditorExportPlatform::get_internal_export_files(const Ref &p_preset, bool p_debug) { Dictionary files; // Text server support data. if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)GLOBAL_GET("internationalization/locale/include_text_server_data")) { String ts_name = TS->get_support_data_filename(); + String ts_target = "res://" + ts_name; if (!ts_name.is_empty()) { - ts_name = "res://" + ts_name; - if (!FileAccess::exists(ts_name)) { // Do not include if user supplied data file exist. - const PackedByteArray &ts_data = TS->get_support_data(); + bool export_ok = false; + if (FileAccess::exists(ts_target)) { // Include user supplied data file. + const PackedByteArray &ts_data = FileAccess::get_file_as_bytes(ts_target); if (!ts_data.is_empty()) { - files[ts_name] = ts_data; + add_message(EXPORT_MESSAGE_INFO, TTR("Export"), TTR("Using user provided text server data, text display in the exported project might be broken if export template was built with different ICU version!")); + files[ts_target] = ts_data; + export_ok = true; } + } else { + String current_version = VERSION_FULL_CONFIG; + String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version); + if (p_debug && p_preset->has("custom_template/debug") && p_preset->get("custom_template/debug") != "") { + template_path = p_preset->get("custom_template/debug").operator String().get_base_dir(); + } else if (!p_debug && p_preset->has("custom_template/release") && p_preset->get("custom_template/release") != "") { + template_path = p_preset->get("custom_template/release").operator String().get_base_dir(); + } + String data_file_name = template_path.path_join(ts_name); + if (FileAccess::exists(data_file_name)) { + const PackedByteArray &ts_data = FileAccess::get_file_as_bytes(data_file_name); + if (!ts_data.is_empty()) { + print_line("Using text server data from export templates."); + files[ts_target] = ts_data; + export_ok = true; + } + } else { + const PackedByteArray &ts_data = TS->get_support_data(); + if (!ts_data.is_empty()) { + add_message(EXPORT_MESSAGE_INFO, TTR("Export"), TTR("Using editor embedded text server data, text display in the exported project might be broken if export template was built with different ICU version!")); + files[ts_target] = ts_data; + export_ok = true; + } + } + } + if (!export_ok) { + add_message(EXPORT_MESSAGE_WARNING, TTR("Export"), TTR("Missing text server data, text display in the exported project might be broken!")); } } } @@ -943,17 +973,6 @@ Vector EditorExportPlatform::get_forced_export_files() { files.push_back(extension_list_config_file); } - // Text server support data. - if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)GLOBAL_GET("internationalization/locale/include_text_server_data")) { - String ts_name = TS->get_support_data_filename(); - if (!ts_name.is_empty()) { - ts_name = "res://" + ts_name; - if (FileAccess::exists(ts_name)) { // Include user supplied data file. - files.push_back(ts_name); - } - } - } - return files; } @@ -1518,7 +1537,7 @@ Error EditorExportPlatform::export_project_files(const Ref & } } - Dictionary int_export = get_internal_export_files(); + Dictionary int_export = get_internal_export_files(p_preset, p_debug); for (const Variant &int_name : int_export.keys()) { const PackedByteArray &array = int_export[int_name]; err = p_save_func(p_udata, int_name, array, idx, total, enc_in_filters, enc_ex_filters, key, seed); @@ -2443,8 +2462,9 @@ void EditorExportPlatform::_bind_methods() { ClassDB::bind_method(D_METHOD("ssh_run_on_remote_no_wait", "host", "port", "ssh_args", "cmd_args", "port_fwd"), &EditorExportPlatform::_ssh_run_on_remote_no_wait, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("ssh_push_to_remote", "host", "port", "scp_args", "src_file", "dst_file"), &EditorExportPlatform::ssh_push_to_remote); + ClassDB::bind_method(D_METHOD("get_internal_export_files", "preset", "debug"), &EditorExportPlatform::get_internal_export_files); + ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::get_forced_export_files); - ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_internal_export_files"), &EditorExportPlatform::get_internal_export_files); BIND_ENUM_CONSTANT(EXPORT_MESSAGE_NONE); BIND_ENUM_CONSTANT(EXPORT_MESSAGE_INFO); diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 6b55ecd4b66..a79cd4fb528 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -277,7 +277,8 @@ public: return worst_type; } - static Dictionary get_internal_export_files(); + Dictionary get_internal_export_files(const Ref &p_preset, bool p_debug); + static Vector get_forced_export_files(); virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err); diff --git a/main/main.cpp b/main/main.cpp index b5853cd8173..4a911af0942 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2528,7 +2528,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } - GLOBAL_DEF("internationalization/locale/include_text_server_data", false); + GLOBAL_DEF_BASIC("internationalization/locale/include_text_server_data", false); OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", true); OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false); diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index f6aa2426985..7589032a9f0 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -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: diff --git a/modules/text_server_adv/gdextension_build/SConstruct b/modules/text_server_adv/gdextension_build/SConstruct index 0d6ac4b7b24..51caa4e6e55 100644 --- a/modules/text_server_adv/gdextension_build/SConstruct +++ b/modules/text_server_adv/gdextension_build/SConstruct @@ -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/"]) diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 00f303d80ff..57d649139fd 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -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 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 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 { diff --git a/thirdparty/README.md b/thirdparty/README.md index 0998aa773a7..dc7eee4a0d6 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -420,7 +420,7 @@ Files extracted from upstream source: Files generated from upstream source: -- The `icudt76l.dat` built with the provided `godot_data.json` config file (see +- The `icudt_godot.dat` built with the provided `godot_data.json` config file (see https://github.com/unicode-org/icu/blob/master/docs/userguide/icu_data/buildtool.md for instructions). @@ -430,7 +430,7 @@ Files generated from upstream source: 3. Reconfigure ICU with custom data config: `ICU_DATA_FILTER_FILE={GODOT_SOURCE}/thirdparty/icu4c/godot_data.json ./runConfigureICU {PLATFORM} --with-data-packaging=common` 4. Delete `data/out` folder and rebuild data: `cd data && rm -rf ./out && make` -5. Copy `source/data/out/icudt76l.dat` to the `{GODOT_SOURCE}/thirdparty/icu4c/icudt76l.dat` +5. Copy `source/data/out/icudt{ICU_VERSION}l.dat` to the `{GODOT_SOURCE}/thirdparty/icu4c/icudt_godot.dat` ## jolt_physics diff --git a/thirdparty/icu4c/icudt76l.dat b/thirdparty/icu4c/icudt_godot.dat similarity index 100% rename from thirdparty/icu4c/icudt76l.dat rename to thirdparty/icu4c/icudt_godot.dat