mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
[3.x] Improve embedded PCK loading and exporting.
This commit is contained in:
@@ -1625,6 +1625,19 @@ List<String> EditorExportPlatformPC::get_binary_extensions(const Ref<EditorExpor
|
||||
Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
|
||||
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
|
||||
|
||||
Error err = prepare_template(p_preset, p_debug, p_path, p_flags);
|
||||
if (err == OK) {
|
||||
err = export_project_data(p_preset, p_debug, p_path, p_flags);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
|
||||
if (!DirAccess::exists(p_path.get_base_dir())) {
|
||||
return ERR_FILE_BAD_PATH;
|
||||
}
|
||||
|
||||
String custom_debug = p_preset->get("custom_template/debug");
|
||||
String custom_release = p_preset->get("custom_template/release");
|
||||
|
||||
@@ -1657,38 +1670,41 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
|
||||
da->make_dir_recursive(p_path.get_base_dir());
|
||||
Error err = da->copy(template_path, p_path, get_chmod_flags());
|
||||
|
||||
if (err == OK) {
|
||||
String pck_path;
|
||||
if (p_preset->get("binary_format/embed_pck")) {
|
||||
pck_path = p_path;
|
||||
} else {
|
||||
pck_path = p_path.get_basename() + ".pck";
|
||||
return err;
|
||||
}
|
||||
|
||||
Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
|
||||
String pck_path;
|
||||
if (p_preset->get("binary_format/embed_pck")) {
|
||||
pck_path = p_path;
|
||||
} else {
|
||||
pck_path = p_path.get_basename() + ".pck";
|
||||
}
|
||||
|
||||
Vector<SharedObject> so_files;
|
||||
|
||||
int64_t embedded_pos;
|
||||
int64_t embedded_size;
|
||||
Error err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
|
||||
if (err == OK && p_preset->get("binary_format/embed_pck")) {
|
||||
if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Vector<SharedObject> so_files;
|
||||
|
||||
int64_t embedded_pos;
|
||||
int64_t embedded_size;
|
||||
err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
|
||||
if (err == OK && p_preset->get("binary_format/embed_pck")) {
|
||||
if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FixUpEmbeddedPckFunc fixup_func = get_fixup_embedded_pck_func();
|
||||
if (fixup_func) {
|
||||
err = fixup_func(p_path, embedded_pos, embedded_size);
|
||||
}
|
||||
FixUpEmbeddedPckFunc fixup_func = get_fixup_embedded_pck_func();
|
||||
if (fixup_func) {
|
||||
err = fixup_func(p_path, embedded_pos, embedded_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (err == OK && !so_files.empty()) {
|
||||
// If shared object files, copy them.
|
||||
for (int i = 0; i < so_files.size() && err == OK; i++) {
|
||||
err = da->copy(so_files[i].path, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
|
||||
if (err == OK) {
|
||||
err = sign_shared_object(p_preset, p_debug, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
|
||||
}
|
||||
if (err == OK && !so_files.empty()) {
|
||||
// If shared object files, copy them.
|
||||
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
for (int i = 0; i < so_files.size() && err == OK; i++) {
|
||||
err = da->copy(so_files[i].path, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
|
||||
if (err == OK) {
|
||||
err = sign_shared_object(p_preset, p_debug, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user