Skip to content

Commit

Permalink
Merge pull request #74684 from clayjohn/export-tex
Browse files Browse the repository at this point in the history
Delete unused compression formats from .import files when exporting
  • Loading branch information
akien-mga authored Mar 19, 2023
2 parents a7d0e18 + dec8616 commit 7752b52
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions editor/export/editor_export_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,13 +1026,13 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
String type = ResourceLoader::get_resource_type(path);

if (FileAccess::exists(path + ".import")) {
// Before doing this, try to see if it can be customized
// Before doing this, try to see if it can be customized.

String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false);

if (export_path != path) {
// It was actually customized..
// Since the original file is likely not recognized, just use the import system
// It was actually customized.
// Since the original file is likely not recognized, just use the import system.

Ref<ConfigFile> config;
config.instantiate();
Expand All @@ -1043,18 +1043,18 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
config->set_value("remap", "type", ResourceLoader::get_resource_type(export_path));

// Erase all PAths
// Erase all Paths.
List<String> keys;
config->get_section_keys("remap", &keys);
for (const String &K : keys) {
if (E.begins_with("path")) {
if (K.begins_with("path")) {
config->erase_section_key("remap", K);
}
}
// Set actual converted path.
config->set_value("remap", "path", export_path);

// erase useless sections
// Erase useless sections.
config->erase_section("deps");
config->erase_section("params");

Expand All @@ -1075,7 +1075,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
return err;
}
} else {
// file is imported and not customized, replace by what it imports
// File is imported and not customized, replace by what it imports.
Ref<ConfigFile> config;
config.instantiate();
err = config->load(path + ".import");
Expand All @@ -1087,7 +1087,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
String importer_type = config->get_value("remap", "importer");

if (importer_type == "keep") {
//just keep file as-is
// Just keep file as-is.
Vector<uint8_t> array = FileAccess::get_file_as_bytes(path);
err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key);

Expand Down Expand Up @@ -1130,6 +1130,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
String remapped_path = config->get_value("remap", remap);
Vector<uint8_t> array = FileAccess::get_file_as_bytes(remapped_path);
err = p_func(p_udata, remapped_path, array, idx, total, enc_in_filters, enc_ex_filters, key);
} else {
// Remove paths if feature not enabled.
config->erase_section_key("remap", remap);
}
}
}
Expand All @@ -1138,17 +1141,25 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
return err;
}

//also save the .import file
Vector<uint8_t> array = FileAccess::get_file_as_bytes(path + ".import");
err = p_func(p_udata, path + ".import", array, idx, total, enc_in_filters, enc_ex_filters, key);
// Erase useless sections.
config->erase_section("deps");
config->erase_section("params");

String import_text = config->encode_to_text();
CharString cs = import_text.utf8();
Vector<uint8_t> sarr;
sarr.resize(cs.size());
memcpy(sarr.ptrw(), cs.ptr(), sarr.size());

err = p_func(p_udata, path + ".import", sarr, idx, total, enc_in_filters, enc_ex_filters, key);

if (err != OK) {
return err;
}
}

} else {
// Customize
// Customize.

bool do_export = true;
for (int i = 0; i < export_plugins.size(); i++) {
Expand Down

0 comments on commit 7752b52

Please sign in to comment.