summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2022-07-20 19:05:49 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2022-08-08 19:30:34 +0200
commit27a072c8845c3919b49426d161f83c360c0bfe6f (patch)
tree4d07aa3b0de32633f47666f6547d8148d42e5c97 /core
parent862dedcefee5d22449eca711aa9af33c4377d31a (diff)
Print expected `os.arch` tuple for current platform in GDExtension error
This also adds `Engine.get_architecture_name()` to get the name of the CPU architecture the Godot binary was built for.
Diffstat (limited to 'core')
-rw-r--r--core/config/engine.cpp36
-rw-r--r--core/config/engine.h2
-rw-r--r--core/core_bind.cpp6
-rw-r--r--core/core_bind.h2
-rw-r--r--core/extension/native_extension.cpp7
5 files changed, 50 insertions, 3 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index 1a6093869f..e1da9eb44e 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -181,6 +181,42 @@ String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}
+String Engine::get_architecture_name() const {
+#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
+ return "x86_64";
+
+#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
+ return "x86_32";
+
+#elif defined(__aarch64__) || defined(_M_ARM64)
+ return "arm64";
+
+#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7S__)
+ return "armv7";
+
+#elif defined(__riscv)
+#if __riscv_xlen == 8
+ return "rv64";
+#else
+ return "riscv";
+#endif
+
+#elif defined(__powerpc__)
+#if defined(__powerpc64__)
+ return "ppc64";
+#else
+ return "ppc";
+#endif
+
+#elif defined(__wasm__)
+#if defined(__wasm64__)
+ return "wasm64";
+#elif defined(__wasm32__)
+ return "wasm32";
+#endif
+#endif
+}
+
bool Engine::is_abort_on_gpu_errors_enabled() const {
return abort_on_gpu_errors;
}
diff --git a/core/config/engine.h b/core/config/engine.h
index 68562643e7..649be23717 100644
--- a/core/config/engine.h
+++ b/core/config/engine.h
@@ -142,6 +142,8 @@ public:
void set_write_movie_path(const String &p_path);
String get_write_movie_path() const;
+ String get_architecture_name() const;
+
void set_shader_cache_path(const String &p_path);
String get_shader_cache_path() const;
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 56130134a0..630bd68e65 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -2270,6 +2270,10 @@ String Engine::get_license_text() const {
return ::Engine::get_singleton()->get_license_text();
}
+String Engine::get_architecture_name() const {
+ return ::Engine::get_singleton()->get_architecture_name();
+}
+
bool Engine::is_in_physics_frame() const {
return ::Engine::get_singleton()->is_in_physics_frame();
}
@@ -2367,6 +2371,8 @@ void Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_license_info"), &Engine::get_license_info);
ClassDB::bind_method(D_METHOD("get_license_text"), &Engine::get_license_text);
+ ClassDB::bind_method(D_METHOD("get_architecture_name"), &Engine::get_architecture_name);
+
ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &Engine::is_in_physics_frame);
ClassDB::bind_method(D_METHOD("has_singleton", "name"), &Engine::has_singleton);
diff --git a/core/core_bind.h b/core/core_bind.h
index 98bf34e07d..79230bd685 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -666,6 +666,8 @@ public:
Dictionary get_license_info() const;
String get_license_text() const;
+ String get_architecture_name() const;
+
bool is_in_physics_frame() const;
bool has_singleton(const StringName &p_name) const;
diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp
index b69859b441..a085df874e 100644
--- a/core/extension/native_extension.cpp
+++ b/core/extension/native_extension.cpp
@@ -372,7 +372,7 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St
}
if (err != OK) {
- ERR_PRINT("Error loading GDExtension config file: " + p_path);
+ ERR_PRINT("Error loading GDExtension configuration file: " + p_path);
return Ref<Resource>();
}
@@ -380,7 +380,7 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St
if (r_error) {
*r_error = ERR_INVALID_DATA;
}
- ERR_PRINT("GDExtension config file must contain 'configuration.entry_symbol' key: " + p_path);
+ ERR_PRINT("GDExtension configuration file must contain a \"configuration/entry_symbol\" key: " + p_path);
return Ref<Resource>();
}
@@ -413,7 +413,8 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St
if (r_error) {
*r_error = ERR_FILE_NOT_FOUND;
}
- ERR_PRINT("No GDExtension library found for current architecture; in config file " + p_path);
+ const String os_arch = OS::get_singleton()->get_name().to_lower() + "." + Engine::get_singleton()->get_architecture_name();
+ ERR_PRINT(vformat("No GDExtension library found for current OS and architecture (%s) in configuration file: %s", os_arch, p_path));
return Ref<Resource>();
}