Remove duplicate data structure for export features

This commit is contained in:
Aaron Franke 2022-07-01 09:47:35 -05:00
parent c2eaaef149
commit 28d1bc34d7
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
2 changed files with 20 additions and 23 deletions

View File

@ -429,24 +429,21 @@ void EditorExportPlatform::_edit_filter_list(HashSet<String> &r_list, const Stri
_edit_files_with_filter(da, filters, r_list, exclude);
}
EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const {
HashSet<String> EditorExportPlatform::get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const {
Ref<EditorExportPlatform> platform = p_preset->get_platform();
List<String> feature_list;
platform->get_platform_features(&feature_list);
platform->get_preset_features(p_preset, &feature_list);
FeatureContainers result;
HashSet<String> result;
for (const String &E : feature_list) {
result.features.insert(E);
result.features_pv.push_back(E);
result.insert(E);
}
if (p_debug) {
result.features.insert("debug");
result.features_pv.push_back("debug");
result.insert("debug");
} else {
result.features.insert("release");
result.features_pv.push_back("release");
result.insert("release");
}
if (!p_preset->get_custom_features().is_empty()) {
@ -455,8 +452,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai
for (int i = 0; i < tmp_custom_list.size(); i++) {
String f = tmp_custom_list[i].strip_edges();
if (!f.is_empty()) {
result.features.insert(f);
result.features_pv.push_back(f);
result.insert(f);
}
}
}
@ -465,14 +461,18 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai
}
EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
FeatureContainers features = p_platform.get_feature_containers(p_preset, p_debug);
HashSet<String> features = p_platform.get_features(p_preset, p_debug);
Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
//initial export plugin callback
for (int i = 0; i < export_plugins.size(); i++) {
if (export_plugins[i]->get_script_instance()) { //script based
export_plugins.write[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags);
PackedStringArray features_psa;
for (const String &feature : features) {
features_psa.push_back(feature);
}
export_plugins.write[i]->_export_begin_script(features_psa, p_debug, p_path, p_flags);
} else {
export_plugins.write[i]->_export_begin(features.features, p_debug, p_path, p_flags);
export_plugins.write[i]->_export_begin(features, p_debug, p_path, p_flags);
}
}
}
@ -621,9 +621,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
export_plugins.write[i]->_clear();
}
FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug);
HashSet<String> &features = feature_containers.features;
Vector<String> &features_pv = feature_containers.features_pv;
HashSet<String> features = get_features(p_preset, p_debug);
//store everything in the export medium
int idx = 0;
@ -709,7 +707,11 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
bool do_export = true;
for (int i = 0; i < export_plugins.size(); i++) {
if (export_plugins[i]->get_script_instance()) { //script based
export_plugins.write[i]->_export_file_script(path, type, features_pv);
PackedStringArray features_psa;
for (const String &feature : features) {
features_psa.push_back(feature);
}
export_plugins.write[i]->_export_file_script(path, type, features_psa);
} else {
export_plugins.write[i]->_export_file(path, type, features);
}

View File

@ -85,11 +85,6 @@ private:
EditorProgress *ep = nullptr;
};
struct FeatureContainers {
HashSet<String> features;
Vector<String> features_pv;
};
Vector<ExportMessage> messages;
void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths);
@ -110,7 +105,7 @@ protected:
~ExportNotifier();
};
FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const;
HashSet<String> get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const;
bool exists_export_template(String template_file_name, String *err) const;
String find_export_template(String template_file_name, String *err = nullptr) const;