1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Export: Improve usability of command line interface

I'm barely scratching the surface of the changes needed to make the
--export command line interface easy to use, but this should already
improve things somewhat.

- Streamline `can_export()` templates check in all platforms, checking
  first for the presence of official templates, then of any defined
  custom template, and reporting on the absence of any.
  Shouldn't change the actual return value much which is still true if
  either release or debug is usable - we might want to change that
  eventually and better validate against the requested target.

- Fix discrepancy between platforms using `custom_package/debug` and
  `custom_template/debug` (resp. `release`).
  All now use `custom_template`, which will break compatibility for
  `export_presets.cfg` with earlier projects (but is easy to fix).

- Use `can_export()` when attempting a command line export and report
  the same errors that would be shown in the editor.

- Improve error reporting after a failed export attempt, handling
  missing template and invalid path more gracefully.

- Cleanup of unused stuff in EditorNode around the export workflow.

- Improve --export documentation in --help a bit.

Fixes #16949 (at least many of the misunderstandings listed there).
Fixes #18470.
This commit is contained in:
Rémi Verschelde
2020-01-07 13:29:02 +01:00
parent 96fdb48edd
commit 5011afcb6a
9 changed files with 160 additions and 177 deletions

View File

@@ -1090,15 +1090,14 @@ public:
}
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
String err;
bool valid = true;
bool valid = false;
// Look for export templates (first official, and if defined custom templates).
Platform arch = (Platform)(int)(p_preset->get("architecture/target"));
String custom_debug_binary = p_preset->get("custom_template/debug");
String custom_release_binary = p_preset->get("custom_template/release");
String platform_infix;
switch (arch) {
case EditorExportPlatformUWP::ARM: {
platform_infix = "arm";
@@ -1111,38 +1110,26 @@ public:
} break;
}
if (!exists_export_template("uwp_" + platform_infix + "_debug.zip", &err) || !exists_export_template("uwp_" + platform_infix + "_release.zip", &err)) {
valid = false;
r_missing_templates = true;
}
bool dvalid = exists_export_template("uwp_" + platform_infix + "_debug.zip", &err);
bool rvalid = exists_export_template("uwp_" + platform_infix + "_release.zip", &err);
if (!valid && custom_debug_binary == "" && custom_release_binary == "") {
if (!err.empty()) {
r_error = err;
if (p_preset->get("custom_template/debug") != "") {
dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
if (!dvalid) {
err += TTR("Custom debug template not found.") + "\n";
}
}
if (p_preset->get("custom_template/release") != "") {
rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
if (!rvalid) {
err += TTR("Custom release template not found.") + "\n";
}
return valid;
}
bool dvalid = true;
bool rvalid = true;
valid = dvalid || rvalid;
r_missing_templates = !valid;
if (!FileAccess::exists(custom_debug_binary)) {
dvalid = false;
err += TTR("Custom debug template not found.") + "\n";
}
if (!FileAccess::exists(custom_release_binary)) {
rvalid = false;
err += TTR("Custom release template not found.") + "\n";
}
if (dvalid || rvalid)
valid = true;
if (!valid) {
r_error = err;
return valid;
}
// Validate the rest of the configuration.
if (!_valid_resource_name(p_preset->get("package/short_name"))) {
valid = false;