mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-24 18:17:21 +01:00
Ported: Refactor the export checking logic to improve separation of concerns - m4gr3d
d2213f76a9
This commit is contained in:
parent
0438da9841
commit
56f71c7275
@ -30,19 +30,19 @@
|
||||
|
||||
#include "editor_export.h"
|
||||
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/crypto/crypto_core.h"
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/io/config_file.h"
|
||||
#include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/zip_io.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/version.h"
|
||||
#include "core/version_generated.gen.h"
|
||||
#include "editor/editor_file_system.h"
|
||||
@ -1668,7 +1668,7 @@ Ref<Texture> EditorExportPlatformPC::get_logo() const {
|
||||
return logo;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err;
|
||||
bool valid = false;
|
||||
|
||||
@ -1700,6 +1700,28 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformPC::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorExportPlatform::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String templates_error;
|
||||
bool valid_export_configuration = has_valid_export_configuration(p_preset, templates_error, r_missing_templates);
|
||||
|
||||
String project_configuration_error;
|
||||
bool valid_project_configuration = has_valid_project_configuration(p_preset, project_configuration_error);
|
||||
|
||||
if (!templates_error.empty()) {
|
||||
r_error += templates_error;
|
||||
}
|
||||
|
||||
if (!project_configuration_error.empty()) {
|
||||
r_error += project_configuration_error;
|
||||
}
|
||||
|
||||
return valid_export_configuration && valid_project_configuration;
|
||||
}
|
||||
|
||||
List<String> EditorExportPlatformPC::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
|
||||
List<String> list;
|
||||
for (Map<String, String>::Element *E = extensions.front(); E; E = E->next()) {
|
||||
|
@ -37,18 +37,18 @@
|
||||
#include "scene/main/timer.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/containers/list.h"
|
||||
#include "core/containers/map.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/containers/pool_vector.h"
|
||||
#include "core/containers/set.h"
|
||||
#include "core/string/string_name.h"
|
||||
#include "core/typedefs.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/variant/variant.h"
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/string/string_name.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/typedefs.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
class FileAccess;
|
||||
class EditorExportPlatform;
|
||||
@ -326,7 +326,9 @@ public:
|
||||
|
||||
String test_etc2() const; //generic test for etc2 since most platforms use it
|
||||
String test_etc2_or_pvrtc() const; // test for etc2 or pvrtc support for iOS
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
|
||||
bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const = 0;
|
||||
|
||||
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0;
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
|
||||
@ -496,7 +498,8 @@ public:
|
||||
virtual String get_os_name() const;
|
||||
virtual Ref<Texture> get_logo() const;
|
||||
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||
virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
|
||||
|
@ -1983,7 +1983,7 @@ String EditorExportPlatformAndroid::get_apksigner_path() {
|
||||
return apksigner_path;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err;
|
||||
bool valid = false;
|
||||
const bool custom_build_enabled = p_preset->get("custom_template/use_custom_build");
|
||||
@ -2031,7 +2031,7 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||
valid = installed_android_build_template && !r_missing_templates;
|
||||
}
|
||||
|
||||
// Validate the rest of the configuration.
|
||||
// Validate the rest of the export configuration.
|
||||
|
||||
String dk = p_preset->get("keystore/debug");
|
||||
String dk_user = p_preset->get("keystore/debug_user");
|
||||
@ -2107,6 +2107,19 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||
}
|
||||
}
|
||||
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
String err;
|
||||
bool valid = true;
|
||||
const bool custom_build_enabled = p_preset->get("custom_build/use_custom_build");
|
||||
|
||||
// Validate the project configuration.
|
||||
bool apk_expansion = p_preset->get("apk_expansion/enable");
|
||||
|
||||
if (apk_expansion) {
|
||||
@ -2153,8 +2166,7 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||
err += "\n";
|
||||
}
|
||||
|
||||
if (int(p_preset->get("custom_template/export_format")) == EXPORT_FORMAT_AAB &&
|
||||
!custom_build_enabled) {
|
||||
if (int(p_preset->get("custom_build/export_format")) == EXPORT_FORMAT_AAB && !custom_build_enabled) {
|
||||
valid = false;
|
||||
err += TTR("\"Export AAB\" is only valid when \"Use Custom Build\" is enabled.");
|
||||
err += "\n";
|
||||
@ -2182,7 +2194,10 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||
err += "\n";
|
||||
}
|
||||
|
||||
r_error = err;
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,8 @@ public:
|
||||
|
||||
static String get_apksigner_path();
|
||||
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
|
||||
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
|
||||
|
||||
|
@ -213,7 +213,8 @@ public:
|
||||
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
|
||||
virtual void get_platform_features(List<String> *r_features) {
|
||||
r_features->push_back("mobile");
|
||||
@ -2076,7 +2077,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err;
|
||||
bool valid = false;
|
||||
|
||||
@ -2101,7 +2102,18 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset
|
||||
valid = dvalid || rvalid;
|
||||
r_missing_templates = !valid;
|
||||
|
||||
// Validate the rest of the configuration.
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformIOS::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
String err;
|
||||
bool valid = true;
|
||||
|
||||
// Validate the project configuration.
|
||||
|
||||
String team_id = p_preset->get("application/app_store_team_id");
|
||||
if (team_id.length() == 0) {
|
||||
|
@ -334,7 +334,8 @@ public:
|
||||
virtual String get_os_name() const;
|
||||
virtual Ref<Texture> get_logo() const;
|
||||
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||
|
||||
@ -692,7 +693,7 @@ Ref<Texture> EditorExportPlatformJavaScript::get_logo() const {
|
||||
return logo;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformJavaScript::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err;
|
||||
bool valid = false;
|
||||
ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
|
||||
@ -717,7 +718,18 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p
|
||||
valid = dvalid || rvalid;
|
||||
r_missing_templates = !valid;
|
||||
|
||||
// Validate the rest of the configuration.
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformJavaScript::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
String err;
|
||||
bool valid = true;
|
||||
|
||||
// Validate the project configuration.
|
||||
|
||||
if (p_preset->get("vram_texture_compression/for_mobile")) {
|
||||
String etc_error = test_etc2();
|
||||
|
@ -31,13 +31,13 @@
|
||||
#include "export.h"
|
||||
#include "codesign.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/io/zip_io.h"
|
||||
#include "core/os/dir_access.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/version.h"
|
||||
#include "editor/editor_export.h"
|
||||
#include "editor/editor_node.h"
|
||||
@ -130,7 +130,8 @@ public:
|
||||
}
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
|
||||
virtual void get_platform_features(List<String> *r_features) {
|
||||
r_features->push_back("pc");
|
||||
@ -1304,7 +1305,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
|
||||
f = da->get_next();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (da->is_link(f)) {
|
||||
OS::Time time = OS::get_singleton()->get_time();
|
||||
OS::Date date = OS::get_singleton()->get_date();
|
||||
@ -1407,7 +1408,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
|
||||
|
||||
zipCloseFileInZip(p_zip);
|
||||
}
|
||||
|
||||
|
||||
f = da->get_next();
|
||||
}
|
||||
|
||||
@ -1415,7 +1416,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
|
||||
memdelete(da);
|
||||
}
|
||||
|
||||
bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformOSX::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err;
|
||||
bool valid = false;
|
||||
|
||||
@ -1445,6 +1446,17 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
|
||||
valid = dvalid || rvalid;
|
||||
r_missing_templates = !valid;
|
||||
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformOSX::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
String err;
|
||||
bool valid = true;
|
||||
|
||||
String identifier = p_preset->get("application/identifier");
|
||||
String pn_err;
|
||||
if (!is_package_name_valid(identifier, &pn_err)) {
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size);
|
||||
virtual void get_export_options(List<ExportOption> *r_options);
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
|
||||
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
||||
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const;
|
||||
};
|
||||
|
||||
Error EditorExportPlatformWindows::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
|
||||
@ -389,15 +390,26 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformWindows::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||
String err = "";
|
||||
bool valid = EditorExportPlatformPC::can_export(p_preset, err, r_missing_templates);
|
||||
bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates);
|
||||
|
||||
String rcedit_path = EditorSettings::get_singleton()->get("export/windows/rcedit");
|
||||
if (p_preset->get("application/modify_resources") && rcedit_path.empty()) {
|
||||
err += TTR("The rcedit tool must be configured in the Editor Settings (Export > Windows > Rcedit) to change the icon or app information data.") + "\n";
|
||||
}
|
||||
|
||||
if (!err.empty()) {
|
||||
r_error = err;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformWindows::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
|
||||
String err = "";
|
||||
bool valid = true;
|
||||
|
||||
String icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/icon"));
|
||||
if (!icon_path.empty() && !FileAccess::exists(icon_path)) {
|
||||
err += TTR("Invalid icon path:") + " " + icon_path + "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user