Update export dialog to handle many architectures

This commit is contained in:
Aaron Franke 2022-07-27 17:48:34 -05:00
parent a0072ba39f
commit 17c4cd6412
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
9 changed files with 50 additions and 88 deletions

View file

@ -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;
}

View file

@ -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];

View file

@ -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);

View file

@ -79,29 +79,19 @@ 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"]);
list.push_back(p_preset->get("binary_format/architecture"));
return list;
}
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) {

View file

@ -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;

View file

@ -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")) {

View file

@ -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);

View file

@ -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")));

View file

@ -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));