Use gdnative api to get constants only for javascript platform

When trying to load the library in a non-Mono Godot editor v3.3.2
an error is printed about godot_get_global_constants(). Furthermore,
the issue with using the GlobalConstants header to get constants is only
present on the javascript platform, so we can revert all other platforms
to the old way of getting constants.
This commit is contained in:
Leroy Hopson 2021-06-19 19:39:20 +07:00
parent 302bdf0714
commit 0743f2a97a
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA

View file

@ -8,7 +8,7 @@
#include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-keysyms.h>
// For _populate_key_list(), see below. // For _populate_key_list(), see below.
#if defined(__WIN32) #if !defined(__EMSCRIPTEN__)
#include <GlobalConstants.hpp> #include <GlobalConstants.hpp>
#endif #endif
@ -21,12 +21,11 @@ void Terminal::_populate_key_list() {
if (!_key_list.empty()) if (!_key_list.empty())
return; return;
// GitHub action for Windows throws the error: // The following error is thrown on the javascript platform when using
// `error LNK2019: unresolved external symbol godot_get_global_constants // GlobalConstants from the header: abort(Assertion failed: bad export type for
// referenced in function "private: static void __cdecl // `_ZN5godot15GlobalConstants8KEY_KP_0E`: undefined). Build with -s
// godot::Terminal::_populate_key_list(void)"` so use the old technique of // ASSERTIONS=1 for more info.
// getting KeyList values from GlobalConstants header for now. #if !defined(__EMSCRIPTEN__)
#if defined(__WIN32)
#define GLOBAL_CONSTANT(VAR) GlobalConstants::VAR #define GLOBAL_CONSTANT(VAR) GlobalConstants::VAR
#else #else
#define GLOBAL_CONSTANT(VAR) get_constant(#VAR) #define GLOBAL_CONSTANT(VAR) get_constant(#VAR)