Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

[export] Linux, Windows: Warn if debug symbols weren't found

hogoww634f29769ad9
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index 57d470ad30c..a30e49e1df0 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -594,23 +594,27 @@ Ref<Texture2D> EditorExportPlatform::get_option_icon(int p_index) const {
return theme->get_icon(SNAME("Play"), EditorStringName(EditorIcons));
}
-String EditorExportPlatform::find_export_template(const String &template_file_name, String *err) const {
+String EditorExportPlatform::get_official_debugsymbols_file_name(const String &p_template_file_name) const {
+ return vformat("Godot_v%s-%s_debugsymbols_%s%s", GODOT_VERSION_NUMBER, GODOT_VERSION_STATUS, p_template_file_name, ".zip");
+}
+
+String EditorExportPlatform::find_export_template(const String &p_template_file_name, String *r_err) const {
String current_version = GODOT_VERSION_FULL_CONFIG;
- String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version).path_join(template_file_name);
+ String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version).path_join(p_template_file_name);
if (FileAccess::exists(template_path)) {
return template_path;
}
- // Not found
- if (err) {
- *err += TTR("No export template found at the expected path:") + "\n" + template_path + "\n";
+ // Not found.
+ if (r_err) {
+ *r_err += TTR("No export template found at the expected path:") + "\n" + template_path + "\n";
}
return String();
}
-bool EditorExportPlatform::exists_export_template(const String &template_file_name, String *err) const {
- return find_export_template(template_file_name, err) != "";
+bool EditorExportPlatform::exists_export_template(const String &p_template_file_name, String *r_err) const {
+ return find_export_template(p_template_file_name, r_err) != "";
}
Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h
index ed7a78b27ae..cb6f0e421cd 100644
--- a/editor/export/editor_export_platform.h
+++ b/editor/export/editor_export_platform.h
@@ -197,6 +197,7 @@ protected:
return ret;
}
+ String get_official_debugsymbols_file_name(const String &p_template_file_name) const;
bool exists_export_template(const String &p_template_file_name, String *r_err) const;
String find_export_template(const String &p_template_file_name, String *r_err = nullptr) const;
Vector<String> gen_export_flags(BitField<EditorExportPlatform::DebugFlags> p_flags);
diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp
index 399daf74e44..1b777f6030e 100644
--- a/editor/export/editor_export_platform_pc.cpp
+++ b/editor/export/editor_export_platform_pc.cpp
@@ -36,7 +36,6 @@
#include "core/io/zip_io.h"
#include "core/os/os.h"
#include "core/os/shared_object.h"
-#include "core/version.h"
#include "scene/resources/image_texture.h" // IWYU pragma: keep. Misdetection of `logo`.
void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
@@ -98,28 +97,67 @@ Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
return logo;
}
+void EditorExportPlatformPC::check_export_template_debugsymbols(const String &p_template_path, String *r_err) const {
+ if (FileAccess::exists(p_template_path + ".debugsymbols")) {
+ return;
+ }
+
+ if (FileAccess::exists(p_template_path + ".debugsymbols.zip")) {
+ return;
+ }
+
+ if (FileAccess::exists(p_template_path.get_base_dir().path_join(get_official_debugsymbols_file_name(p_template_path.get_file())))) {
+ return;
+ }
+
+ // Not found.
+ if (r_err) {
+ *r_err += vformat(TTR("Export Debug Symbols is set, but no export template .debugsymbols nor .debugsymbols.zip found for: %s"), p_template_path.get_file()) + "\n";
+ }
+}
+
bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;
// Look for export templates (first official, and if defined custom templates).
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"));
+ String dtemplate_path = find_export_template(get_template_file_name("debug", arch), &err);
+ String rtemplate_path = find_export_template(get_template_file_name("release", arch), &err);
+ bool dvalid = dtemplate_path != "";
+ bool rvalid = rtemplate_path != "";
+
+ String dcustom_template_path = p_preset->get("custom_template/debug");
+ dcustom_template_path = dcustom_template_path.strip_edges();
+ if (dcustom_template_path != "") {
+ dtemplate_path = dcustom_template_path;
+ dvalid = FileAccess::exists(dcustom_template_path);
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"));
+
+ String rcustom_template_path = p_preset->get("custom_template/release");
+ rcustom_template_path = rcustom_template_path.strip_edges();
+ if (rcustom_template_path != "") {
+ rtemplate_path = rcustom_template_path;
+ rvalid = FileAccess::exists(rcustom_template_path);
if (!rvalid) {
err += TTR("Custom release template not found.") + "\n";
}
}
+ // Warn if the debug symbols for the effectively used files are not found.
+ int debug_symbol_mode = p_preset->get("debug/export_debug_symbols");
+ if (debug_symbol_mode > 0) {
+ if (dvalid) {
+ check_export_template_debugsymbols(dtemplate_path, &err);
+ }
+ if (rvalid && debug_symbol_mode == 2) {
+ check_export_template_debugsymbols(rtemplate_path, &err);
+ }
+ }
+
valid = dvalid || rvalid;
r_missing_templates = !valid;
@@ -235,7 +273,7 @@ bool EditorExportPlatformPC::_copy_debugsymbols(Ref<DirAccess> &p_da, const Stri
String sym_path = p_symbols_path + ".debugsymbols";
String zip_path = p_symbols_path + ".debugsymbols.zip";
- String zip_path_full = p_symbols_path.get_base_dir().simplify_path().path_join(vformat("Godot_v%s-%s_debugsymbols_%s", GODOT_VERSION_NUMBER, GODOT_VERSION_STATUS, p_symbols_path.get_file())) + ".zip";
+ String zip_path_full = p_symbols_path.simplify_path().path_join(get_official_debugsymbols_file_name(p_symbols_path.get_file()));
if (FileAccess::exists(sym_path)) {
r_err = p_da->copy(sym_path, p_path + ".debugsymbols");
diff --git a/editor/export/editor_export_platform_pc.h b/editor/export/editor_export_platform_pc.h
index a4b4112e240..9fd3528aaa0 100644
--- a/editor/export/editor_export_platform_pc.h
+++ b/editor/export/editor_export_platform_pc.h
@@ -56,6 +56,7 @@ public:
virtual String get_os_name() const override;
virtual Ref<Texture2D> get_logo() const override;
+ void check_export_template_debugsymbols(const String &p_template_path, String *r_err) const;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags = 0, bool p_notify = true) override;
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 51963abf738..c9121becc98 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -40,7 +40,6 @@
#include "core/object/class_db.h"
#include "core/os/os.h"
#include "core/string/translation_server.h"
-#include "core/version.h"
#include "drivers/png/png_driver_common.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
@@ -390,6 +389,10 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportP
return true;
}
+String EditorExportPlatformMacOS::get_template_file_name(const String &p_target, const String &p_arch) const {
+ return "macos_" + p_target + "." + p_arch;
+}
+
List<String> EditorExportPlatformMacOS::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
@@ -1816,7 +1819,7 @@ Error EditorExportPlatformMacOS::_unzip_debugsymbols(Ref<DirAccess> &p_da, const
print_verbose(vformat("Exporting debug symbols from %s, for architecture %s.", p_zip_path, p_arch));
- String template_name = p_debug ? "debug" : "release";
+ String template_file_name = get_template_file_name(p_debug ? "debug" : "release", p_arch);
int ret = unzGoToFirstFile(src_pkg_zip);
while (ret == UNZ_OK) {
// Get filename.
@@ -1827,9 +1830,9 @@ Error EditorExportPlatformMacOS::_unzip_debugsymbols(Ref<DirAccess> &p_da, const
break;
}
String file = String::utf8(fname);
- if (file.begins_with(vformat("godot_macos_%s.%s.dSYM/", template_name, p_arch))) {
- file = file.trim_prefix(vformat("godot_macos_%s.%s.dSYM/", template_name, p_arch));
- file = file.replace(vformat("godot_macos_%s.%s", template_name, p_arch), p_app_name);
+ if (file.begins_with(vformat("godot_%s.dSYM/", template_file_name))) {
+ file = file.trim_prefix(vformat("godot_%s.dSYM/", template_file_name));
+ file = file.replace("godot_" + template_file_name, p_app_name);
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -1911,7 +1914,7 @@ Error EditorExportPlatformMacOS::_copy_debugsymbols_recursively(Ref<DirAccess> &
return err;
}
- String template_name = p_debug ? "debug" : "release";
+ String template_file_name = get_template_file_name(p_debug ? "debug" : "release", p_arch);
src_da->list_dir_begin();
String n = src_da->get_next();
while (!n.is_empty()) {
@@ -1919,7 +1922,7 @@ Error EditorExportPlatformMacOS::_copy_debugsymbols_recursively(Ref<DirAccess> &
if (src_da->current_is_dir()) {
dirs.push_back(n);
} else {
- const String &rel_path = n.replace(vformat("godot_macos_%s.%s", template_name, p_arch), p_app_name);
+ const String &rel_path = n.replace("godot_" + template_file_name, p_app_name);
if (!n.is_relative_path()) {
src_da->list_dir_end();
if (err != OK) {
@@ -1956,13 +1959,14 @@ Error EditorExportPlatformMacOS::_copy_debugsymbols_recursively(Ref<DirAccess> &
}
bool EditorExportPlatformMacOS::_copy_debugsymbols(Ref<DirAccess> &p_da, const String &p_path, const String &p_symbols_path, const String &p_app_name, const String &p_arch, bool p_debug, const Vector<String> &p_exec_ids, Vector<String> *r_symb_ids, Error &r_err) {
- String sym_path = p_symbols_path.simplify_path().path_join(vformat("godot_macos_%s.%s", p_debug ? "debug" : "release", p_arch)) + ".dSYM";
- String zip_path = p_symbols_path.simplify_path().path_join(vformat("macos_%s.%s", p_debug ? "debug" : "release", p_arch)) + ".debugsymbols.zip";
- String zip_path_full = p_symbols_path.simplify_path().path_join(vformat("Godot_v%s-%s_debugsymbols_macos_%s.%s", GODOT_VERSION_NUMBER, GODOT_VERSION_STATUS, p_debug ? "debug" : "release", p_arch)) + ".zip";
+ String template_file_name = get_template_file_name(p_debug ? "debug" : "release", p_arch);
+ String sym_path = p_symbols_path.simplify_path().path_join(vformat("godot_%s.dSYM", template_file_name));
+ String zip_path = p_symbols_path.simplify_path().path_join(template_file_name) + ".debugsymbols.zip";
+ String zip_path_full = p_symbols_path.simplify_path().path_join(get_official_debugsymbols_file_name(template_file_name));
if (DirAccess::exists(sym_path)) {
print_verbose(vformat("Exporting debug symbols from %s, for architecture %s.", sym_path, p_arch));
- Vector<String> symb_debug_ids = OS::get_singleton()->get_debug_build_id(sym_path.path_join("Contents").path_join("Resources").path_join("DWARF").path_join(vformat("godot_macos_%s.%s", p_debug ? "debug" : "release", p_arch)));
+ Vector<String> symb_debug_ids = OS::get_singleton()->get_debug_build_id(sym_path.path_join("Contents").path_join("Resources").path_join("DWARF").path_join("godot_" + template_file_name));
if (!symb_debug_ids.is_empty()) {
int id_match = 0;
for (const String &E : symb_debug_ids) {
@@ -2929,17 +2933,24 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
// Look for export templates (official templates first, then custom).
- bool dvalid = exists_export_template("macos.zip", &err);
+ String dtemplate_path = find_export_template("macos.zip", &err);
+ String rtemplate_path = dtemplate_path;
+ bool dvalid = dtemplate_path != "";
bool rvalid = dvalid; // Both in the same ZIP.
- if (p_preset->get("custom_template/debug") != "") {
- dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
+ String dcustom_template_path = p_preset->get("custom_template/debug");
+ dcustom_template_path = dcustom_template_path.strip_edges();
+ if (dcustom_template_path != "") {
+ dtemplate_path = dcustom_template_path;
+ dvalid = FileAccess::exists(dcustom_template_path);
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"));
+ String rcustom_template_path = p_preset->get("custom_template/release");
+ if (rcustom_template_path != "") {
+ rtemplate_path = rcustom_template_path;
+ rvalid = FileAccess::exists(rcustom_template_path);
if (!rvalid) {
err += TTR("Custom release template not found.") + "\n";
}
@@ -2969,12 +2980,69 @@ bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorE
ERR_PRINT("Invalid architecture");
}
+ // Warn if the debug symbols for the effectively used files are not found.
+ int debug_symbol_mode = p_preset->get("debug/export_debug_symbols");
+ if (debug_symbol_mode > 0) {
+ if (dvalid) {
+ bool sym_found = false;
+ if (architecture == "universal") {
+ sym_found = check_export_template_debugsymbols(dtemplate_path.get_base_dir(), "universal", false);
+ if (!sym_found) {
+ sym_found = check_export_template_debugsymbols(dtemplate_path.get_base_dir(), "arm64", false);
+ sym_found = sym_found && check_export_template_debugsymbols(dtemplate_path.get_base_dir(), "x86_64", false);
+ }
+ } else {
+ sym_found = check_export_template_debugsymbols(dtemplate_path.get_base_dir(), architecture, false);
+ if (!sym_found) {
+ sym_found = check_export_template_debugsymbols(dtemplate_path.get_base_dir(), "universal", false);
+ }
+ }
+ if (!sym_found) {
+ r_error += TTR("Export Debug Symbols is set, but no debug export template .dSYM nor .debugsymbols.zip found.") + "\n";
+ }
+ }
+ if (rvalid && debug_symbol_mode == 2) {
+ bool sym_found = false;
+ if (architecture == "universal") {
+ sym_found = check_export_template_debugsymbols(rtemplate_path.get_base_dir(), "universal", true);
+ if (!sym_found) {
+ sym_found = check_export_template_debugsymbols(rtemplate_path.get_base_dir(), "arm64", true);
+ sym_found = sym_found && check_export_template_debugsymbols(rtemplate_path.get_base_dir(), "x86_64", true);
+ }
+ } else {
+ sym_found = check_export_template_debugsymbols(rtemplate_path.get_base_dir(), architecture, true);
+ if (!sym_found) {
+ sym_found = check_export_template_debugsymbols(rtemplate_path.get_base_dir(), "universal", true);
+ }
+ }
+ if (!sym_found) {
+ r_error += TTR("Export Debug Symbols is set, but no release export template .dSYM nor .debugsymbols.zip found.") + "\n";
+ }
+ }
+ }
+
if (!err.is_empty()) {
r_error = err;
}
return valid;
}
+bool EditorExportPlatformMacOS::check_export_template_debugsymbols(const String &p_symbols_path, const String &p_arch, bool p_debug) const {
+ String template_file_name = get_template_file_name(p_debug ? "debug" : "release", p_arch);
+ String sym_path = p_symbols_path.simplify_path().path_join(vformat("godot_%s.dSYM", template_file_name));
+ String zip_path = p_symbols_path.simplify_path().path_join(template_file_name) + ".debugsymbols.zip";
+ String zip_path_full = p_symbols_path.simplify_path().path_join(get_official_debugsymbols_file_name(template_file_name));
+ if (DirAccess::exists(sym_path)) {
+ return true;
+ } else if (FileAccess::exists(zip_path)) {
+ return true;
+ } else if (FileAccess::exists(zip_path_full)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
String err;
bool valid = true;
diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h
index c6619c029c4..dc6e1bb6e5c 100644
--- a/platform/macos/export/export_plugin.h
+++ b/platform/macos/export/export_plugin.h
@@ -136,6 +136,7 @@ protected:
virtual void get_export_options(List<ExportOption> *r_options) const override;
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override;
virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const override;
+ bool check_export_template_debugsymbols(const String &p_symbols_path, const String &p_arch, bool p_debug) const;
public:
virtual String get_name() const override {
@@ -151,6 +152,7 @@ public:
virtual bool is_executable(const String &p_path) const override;
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags = 0, bool p_notify = true) override;
+ String get_template_file_name(const String &p_target, const String &p_arch) const;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;