summaryrefslogtreecommitdiffstats
path: root/modules/gdnative/gdnative.cpp
diff options
context:
space:
mode:
authorRuslan Mustakov <r.mustakov@gmail.com>2017-08-18 21:17:35 +0700
committerRuslan Mustakov <r.mustakov@gmail.com>2017-08-30 18:14:19 +0700
commit5ccdeccb6ed6b8480a86b0db36f192526cba1274 (patch)
treeeafb890997ee985210b66272957aa22ad00df125 /modules/gdnative/gdnative.cpp
parent8b9026c05e9982a7bc0c7f52776ad74276b90252 (diff)
downloadredot-engine-5ccdeccb6ed6b8480a86b0db36f192526cba1274.tar.gz
Make GDNative work on Android
The changes include work done to ensure that GDNative apps and Nim integration specifically can run on Android. The changes have been tested on our WIP game, which uses godot-nim and depends on several third-party .so libs, and Platformer demo to ensure nothing got broken. - .so libraries are exported to lib/ folder in .apk, instead of assets/, because that's where Android expects them to be and it resolves the library name into "lib/<ABI>/<name>", where <ABI> is the ABI matching the current device. So we establish the convention that Android .so files in the project must be located in the folder corresponding to the ABI they were compiled for. - Godot callbacks (event handlers) are now called from the same thread from which Main::iteration is called. It is also what Godot now considers to be the main thread, because Main::setup is also called from there. This makes threading on Android more consistent with other platforms, making the code that depends on Thread::get_main_id more portable (GDNative has such code). - Sizes of GDNative API types have been fixed to work on 32-bit platforms.
Diffstat (limited to 'modules/gdnative/gdnative.cpp')
-rw-r--r--modules/gdnative/gdnative.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 7faf21c5a1..ded987557c 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -40,7 +40,7 @@
const String init_symbol = "godot_gdnative_init";
const String terminate_symbol = "godot_gdnative_terminate";
-String GDNativeLibrary::platform_names[NUM_PLATFORMS] = {
+String GDNativeLibrary::platform_names[NUM_PLATFORMS + 1] = {
"X11_32bit",
"X11_64bit",
"Windows_32bit",
@@ -48,11 +48,15 @@ String GDNativeLibrary::platform_names[NUM_PLATFORMS] = {
"OSX",
"Android",
- "iOS",
- "WebAssembly"
+ "iOS_32bit",
+ "iOS_64bit",
+
+ "WebAssembly",
+
+ ""
};
-String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS] = {
+String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS + 1] = {
"so",
"so",
"dll",
@@ -60,21 +64,30 @@ String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS] = {
"dylib",
"so",
+
"dylib",
+ "dylib",
+
+ "wasm",
- "wasm"
+ ""
};
-// TODO(karroffel): make this actually do the right thing.
GDNativeLibrary::Platform GDNativeLibrary::current_platform =
#if defined(X11_ENABLED)
- X11_64BIT;
+ (sizeof(void *) == 8 ? X11_64BIT : X11_32BIT);
#elif defined(WINDOWS_ENABLED)
- WINDOWS_64BIT;
+ (sizeof(void *) == 8 ? WINDOWS_64BIT : WINDOWS_32BIT);
#elif defined(OSX_ENABLED)
OSX;
+#elif defined(IPHONE_ENABLED)
+ (sizeof(void *) == 8 ? IOS_64BIT : IOS_32BIT);
+#elif defined(ANDROID_ENABLED)
+ ANDROID;
+#elif defined(JAVASCRIPT_ENABLED)
+ WASM;
#else
- X11_64BIT; // need a sensible default..
+ NUM_PLATFORMS;
#endif
GDNativeLibrary::GDNativeLibrary()
@@ -151,7 +164,10 @@ String GDNativeLibrary::get_library_path(StringName p_platform) const {
}
String GDNativeLibrary::get_active_library_path() const {
- return library_paths[GDNativeLibrary::current_platform];
+ if (GDNativeLibrary::current_platform != NUM_PLATFORMS) {
+ return library_paths[GDNativeLibrary::current_platform];
+ }
+ return "";
}
GDNative::GDNative() {