From 27a072c8845c3919b49426d161f83c360c0bfe6f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 20 Jul 2022 19:05:49 +0200 Subject: 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. --- core/config/engine.cpp | 36 ++++++++++++++++++++++++++++++++++++ core/config/engine.h | 2 ++ 2 files changed, 38 insertions(+) (limited to 'core/config') 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; -- cgit v1.2.3