diff options
| author | Aaron Franke <arnfranke@yahoo.com> | 2022-07-27 17:48:34 -0500 | 
|---|---|---|
| committer | Aaron Franke <arnfranke@yahoo.com> | 2022-07-29 10:24:58 -0500 | 
| commit | 17c4cd6412e3491f33713c63e4d3cc80c959319f (patch) | |
| tree | 30cf01bbbbc12c6877150a6a9042bfcf85ab11ce | |
| parent | a0072ba39fb19158564322ae3f4595512a0c34dc (diff) | |
Update export dialog to handle many architectures
| -rw-r--r-- | editor/export/editor_export_platform_pc.cpp | 21 | ||||
| -rw-r--r-- | platform/android/export/export_plugin.cpp | 2 | ||||
| -rw-r--r-- | platform/linuxbsd/export/export.cpp | 2 | ||||
| -rw-r--r-- | platform/linuxbsd/export/export_plugin.cpp | 22 | ||||
| -rw-r--r-- | platform/linuxbsd/export/export_plugin.h | 2 | ||||
| -rw-r--r-- | platform/macos/export/export_plugin.cpp | 15 | ||||
| -rw-r--r-- | platform/uwp/export/export_plugin.cpp | 63 | ||||
| -rw-r--r-- | platform/uwp/export/export_plugin.h | 10 | ||||
| -rw-r--r-- | platform/windows/export/export_plugin.cpp | 1 | 
9 files changed, 50 insertions, 88 deletions
diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 665b618f18..5e0044f2ae 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -42,12 +42,9 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &  	if (p_preset->get("texture_format/etc2")) {  		r_features->push_back("etc2");  	} - -	if (p_preset->get("binary_format/64_bits")) { -		r_features->push_back("64"); -	} else { -		r_features->push_back("32"); -	} +	// PC platforms only have one architecture per export, since +	// we export a single executable instead of a bundle. +	r_features->push_back(p_preset->get("binary_format/architecture"));  }  void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { @@ -57,7 +54,6 @@ void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {  	r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); -	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));  	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false));  	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false)); @@ -84,10 +80,9 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,  	bool valid = false;  	// Look for export templates (first official, and if defined custom templates). - -	bool use64 = p_preset->get("binary_format/64_bits"); -	bool dvalid = exists_export_template(get_template_file_name("debug", use64 ? "x86_64" : "x86_32"), &err); -	bool rvalid = exists_export_template(get_template_file_name("release", use64 ? "x86_64" : "x86_32"), &err); +	String arch = p_preset->get("binary_format/architecture"); +	bool dvalid = exists_export_template(get_template_file_name("debug", arch), &err); +	bool rvalid = exists_export_template(get_template_file_name("release", arch), &err);  	if (p_preset->get("custom_template/debug") != "") {  		dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); @@ -139,7 +134,7 @@ Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_  	template_path = template_path.strip_edges();  	if (template_path.is_empty()) { -		template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/64_bits") ? "x86_64" : "x86_32")); +		template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/architecture")));  	}  	if (!template_path.is_empty() && !FileAccess::exists(template_path)) { @@ -171,7 +166,7 @@ Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset>  	int64_t embedded_size;  	Error err = save_pack(p_preset, p_debug, 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")) { +		if (embedded_size >= 0x100000000 && String(p_preset->get("binary_format/architecture")).contains("32")) {  			add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));  			return ERR_INVALID_PARAMETER;  		} diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index bdee68ef34..6f1b4bde40 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1705,6 +1705,8 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio  	}  	plugins_changed.clear(); +	// Android supports multiple architectures in an app bundle, so +	// we expose each option as a checkbox in the export dialog.  	const Vector<String> abis = get_abis();  	for (int i = 0; i < abis.size(); ++i) {  		const String abi = abis[i]; diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp index bc1235bcec..990351d13f 100644 --- a/platform/linuxbsd/export/export.cpp +++ b/platform/linuxbsd/export/export.cpp @@ -38,8 +38,6 @@ void register_linuxbsd_exporter() {  	platform.instantiate();  	platform->set_logo(ImageTexture::create_from_image(memnew(Image(_linuxbsd_logo))));  	platform->set_name("Linux/X11"); -	platform->set_extension("x86_32"); -	platform->set_extension("x86_64", "binary_format/64_bits");  	platform->set_os_name("Linux");  	platform->set_chmod_flags(0755); diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index d54e07d8a5..4d45d3ba12 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -79,31 +79,21 @@ Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset>  	return err;  } -void EditorExportPlatformLinuxBSD::set_extension(const String &p_extension, const String &p_feature_key) { -	extensions[p_feature_key] = p_extension; -} -  String EditorExportPlatformLinuxBSD::get_template_file_name(const String &p_target, const String &p_arch) const {  	return "linux_" + p_target + "." + p_arch;  }  List<String> EditorExportPlatformLinuxBSD::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {  	List<String> list; -	for (const KeyValue<String, String> &E : extensions) { -		if (p_preset->get(E.key)) { -			list.push_back(extensions[E.key]); -			return list; -		} -	} - -	if (extensions.has("default")) { -		list.push_back(extensions["default"]); -		return list; -	} - +	list.push_back(p_preset->get("binary_format/architecture"));  	return list;  } +void EditorExportPlatformLinuxBSD::get_export_options(List<ExportOption> *r_options) { +	EditorExportPlatformPC::get_export_options(r_options); +	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm64,arm32,rv64,ppc64,ppc32"), "x86_64")); +} +  Error EditorExportPlatformLinuxBSD::fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {  	// Patch the header of the "pck" section in the ELF file so that it corresponds to the embedded data diff --git a/platform/linuxbsd/export/export_plugin.h b/platform/linuxbsd/export/export_plugin.h index 98e4616035..4d6737498b 100644 --- a/platform/linuxbsd/export/export_plugin.h +++ b/platform/linuxbsd/export/export_plugin.h @@ -38,12 +38,12 @@  #include "scene/resources/texture.h"  class EditorExportPlatformLinuxBSD : public EditorExportPlatformPC { -	HashMap<String, String> extensions;  	Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);  public:  	void set_extension(const String &p_extension, const String &p_feature_key = "default");  	virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override; +	virtual void get_export_options(List<ExportOption> *r_options) override;  	virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;  	virtual String get_template_file_name(const String &p_target, const String &p_arch) const override;  	virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) override; diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 209a3dee5b..9fd0db4f18 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -47,8 +47,7 @@ void EditorExportPlatformMacOS::get_preset_features(const Ref<EditorExportPreset  	if (p_preset->get("texture_format/etc2")) {  		r_features->push_back("etc2");  	} - -	r_features->push_back("64"); +	r_features->push_back(p_preset->get("binary_format/architecture"));  }  bool EditorExportPlatformMacOS::get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { @@ -69,6 +68,7 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const String &p_opt  }  void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options) { +	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "universal,x86_64,arm64", PROPERTY_USAGE_STORAGE), "universal"));  	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));  	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); @@ -766,7 +766,8 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p  	int ret = unzGoToFirstFile(src_pkg_zip); -	String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + ".universal"; +	String architecture = p_preset->get("binary_format/architecture"); +	String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture;  	String pkg_name;  	if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") { @@ -1064,19 +1065,19 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p  		}  		if (data.size() > 0) { -			if (file.find("/data.mono.macos.release_debug.universal/") != -1) { +			if (file.find("/data.mono.macos.release_debug." + architecture + "/") != -1) {  				if (!p_debug) {  					ret = unzGoToNextFile(src_pkg_zip);  					continue; // skip  				} -				file = file.replace("/data.mono.macos.release_debug.universal/", "/GodotSharp/"); +				file = file.replace("/data.mono.macos.release_debug." + architecture + "/", "/GodotSharp/");  			} -			if (file.find("/data.mono.macos.release.universal/") != -1) { +			if (file.find("/data.mono.macos.release." + architecture + "/") != -1) {  				if (p_debug) {  					ret = unzGoToNextFile(src_pkg_zip);  					continue; // skip  				} -				file = file.replace("/data.mono.macos.release.universal/", "/GodotSharp/"); +				file = file.replace("/data.mono.macos.release." + architecture + "/", "/GodotSharp/");  			}  			if (file.ends_with(".dylib")) { diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index 7bf8a0f4c7..a99776497b 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -52,24 +52,14 @@ Ref<Texture2D> EditorExportPlatformUWP::get_logo() const {  void EditorExportPlatformUWP::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {  	r_features->push_back("s3tc");  	r_features->push_back("etc"); -	switch ((int)p_preset->get("architecture/target")) { -		case EditorExportPlatformUWP::ARM: { -			r_features->push_back("arm"); -		} break; -		case EditorExportPlatformUWP::X86: { -			r_features->push_back("32"); -		} break; -		case EditorExportPlatformUWP::X64: { -			r_features->push_back("64"); -		} break; -	} +	r_features->push_back(p_preset->get("binary_format/architecture"));  }  void EditorExportPlatformUWP::get_export_options(List<ExportOption> *r_options) {  	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));  	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); -	r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "architecture/target", PROPERTY_HINT_ENUM, "arm,x86,x64"), 1)); +	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm32"), "x86_64"));  	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); @@ -143,23 +133,18 @@ bool EditorExportPlatformUWP::can_export(const Ref<EditorExportPreset> &p_preset  	bool valid = false;  	// Look for export templates (first official, and if defined custom templates). - -	Platform arch = (Platform)(int)(p_preset->get("architecture/target")); -	String platform_infix; -	switch (arch) { -		case EditorExportPlatformUWP::ARM: { -			platform_infix = "arm"; -		} break; -		case EditorExportPlatformUWP::X86: { -			platform_infix = "x86"; -		} break; -		case EditorExportPlatformUWP::X64: { -			platform_infix = "x64"; -		} break; +	String arch = p_preset->get("binary_format/architecture"); +	String arch_infix; +	if (arch == "arm32") { +		arch_infix = "arm"; +	} else if (arch == "x86_32") { +		arch_infix = "x86"; +	} else if (arch == "x86_64") { +		arch_infix = "x64";  	} -	bool dvalid = exists_export_template("uwp_" + platform_infix + "_debug.zip", &err); -	bool rvalid = exists_export_template("uwp_" + platform_infix + "_release.zip", &err); +	bool dvalid = exists_export_template("uwp_" + arch_infix + "_debug.zip", &err); +	bool rvalid = exists_export_template("uwp_" + arch_infix + "_release.zip", &err);  	if (p_preset->get("custom_template/debug") != "") {  		dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); @@ -263,25 +248,21 @@ Error EditorExportPlatformUWP::export_project(const Ref<EditorExportPreset> &p_p  	src_appx = src_appx.strip_edges(); -	Platform arch = (Platform)(int)p_preset->get("architecture/target"); +	String arch = p_preset->get("binary_format/architecture");  	if (src_appx.is_empty()) { -		String err, infix; -		switch (arch) { -			case ARM: { -				infix = "_arm_"; -			} break; -			case X86: { -				infix = "_x86_"; -			} break; -			case X64: { -				infix = "_x64_"; -			} break; +		String err, arch_infix; +		if (arch == "arm32") { +			arch_infix = "arm"; +		} else if (arch == "x86_32") { +			arch_infix = "x86"; +		} else if (arch == "x86_64") { +			arch_infix = "x64";  		}  		if (p_debug) { -			src_appx = find_export_template("uwp" + infix + "debug.zip", &err); +			src_appx = find_export_template("uwp_" + arch_infix + "_debug.zip", &err);  		} else { -			src_appx = find_export_template("uwp" + infix + "release.zip", &err); +			src_appx = find_export_template("uwp_" + arch_infix + "_release.zip", &err);  		}  		if (src_appx.is_empty()) {  			EditorNode::add_io_error(err); diff --git a/platform/uwp/export/export_plugin.h b/platform/uwp/export/export_plugin.h index 5c50baf9c3..4a3c5db377 100644 --- a/platform/uwp/export/export_plugin.h +++ b/platform/uwp/export/export_plugin.h @@ -90,12 +90,6 @@ class EditorExportPlatformUWP : public EditorExportPlatform {  	Ref<ImageTexture> logo; -	enum Platform { -		ARM, -		X86, -		X64 -	}; -  	bool _valid_resource_name(const String &p_name) const {  		if (p_name.is_empty()) {  			return false; @@ -215,8 +209,8 @@ class EditorExportPlatformUWP : public EditorExportPlatform {  		String version = itos(p_preset->get("version/major")) + "." + itos(p_preset->get("version/minor")) + "." + itos(p_preset->get("version/build")) + "." + itos(p_preset->get("version/revision"));  		result = result.replace("$version_string$", version); -		Platform arch = (Platform)(int)p_preset->get("architecture/target"); -		String architecture = arch == ARM ? "arm" : (arch == X86 ? "x86" : "x64"); +		String arch = p_preset->get("binary_format/architecture"); +		String architecture = arch == "arm32" ? "arm" : (arch == "x86_32" ? "x86" : "x64");  		result = result.replace("$architecture$", architecture);  		result = result.replace("$display_name$", String(p_preset->get("package/display_name")).is_empty() ? (String)ProjectSettings::get_singleton()->get("application/config/name") : String(p_preset->get("package/display_name"))); diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index 45bfc761fe..375fddfa41 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -123,6 +123,7 @@ bool EditorExportPlatformWindows::get_export_option_visibility(const String &p_o  void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) {  	EditorExportPlatformPC::get_export_options(r_options); +	r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32"), "x86_64"));  	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/enable"), false));  	r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/identity_type", PROPERTY_HINT_ENUM, "Select automatically,Use PKCS12 file (specify *.PFX/*.P12 file),Use certificate store (specify SHA1 hash)"), 0));  |