From 0c50394a6620db917e0285bd9e03ddcf33a3d716 Mon Sep 17 00:00:00 2001 From: rodolpheh Date: Sun, 5 Nov 2023 15:07:10 +0000 Subject: [PATCH] Update instructions and build script for Android --- README.md | 28 +++++++++++++++++++++++++--- SConstruct | 13 +++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ffcb6c..169121f 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ A GDExtension plugin to use Ultraleap hand tracking in your project. See GIF bel - [:hammer\_and\_wrench: Build](#hammer-and-wrench-build) - [🍎 Mac extra instructions](#mac-extra-instructions) - [:wine\_glass: Windows extra instructions](#wine-glass-windows-extra-instructions) + - [:robot: Android instructions](#robot-android-instructions) - [:fast\_forward: Quick start](#fast-forward-quick-start) ![GIF of Ultraleap hand tracking in Godot](res/ul-godot.gif) @@ -38,9 +39,7 @@ The other important scene is an obvious rip-off of Ultraleap's Blocks demo used ## :hammer_and_wrench: Build -To build you'll need to have Python and SCons installed. On Linux and Mac it can be installed using your favourite package manager (homebrew for Mac). On Windows you probably want to install it with [pip](https://pypi.org/project/SCons/). You'll also need a compiler, GCC on Linux, XCode Command Line Tools on Mac, and MSBuild on Windows. - -Use git to clone this repository and the submodules: +First thing first, pull all the sources and submodules: ```bash git clone https://forge.lunai.re/rodolphe/godot-ultraleap-plugin @@ -48,6 +47,10 @@ cd godot-ultraleap-plugin git submodule update --init ``` +**If you want to build the plugin for Android, follow [the specific instructions](#robot-android-instructions)** + +To build you'll need to have Python and SCons installed. On Linux and Mac it can be installed using your favourite package manager (homebrew for Mac). On Windows you probably want to install it with [pip](https://pypi.org/project/SCons/). You'll also need a compiler, GCC on Linux, XCode Command Line Tools on Mac, and MSBuild on Windows. + From there, just launch scons: ```bash @@ -64,6 +67,25 @@ After building the extension, copy `/Applications/Ultraleap Hand Tracking Servic After building the extension, copy `C:/Program Files/Ultraleap/LeapSDK/lib/x64/LeapC.dll` in the `demo/addons/godot_ultraleap_plugin/bin` folder. +### :robot: Android instructions + +There are a lot of extra-steps to build for Android. We'll start by assuming you already have installed the Android SDK and the NDK, plus the build tools and all the things required (you can refer to the [Godot documentation](https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_android.html#download-the-android-sdk)). We'll also assume that all the submodules have been pulled and are up-to-date. + +On top of that, you'll need to download and copy some files around by yourself: + +* [`godot-lib.4.1.2.stable.template_release.aar`](https://github.com/godotengine/godot-builds/releases/download/4.1.2-stable/godot-lib.4.1.2.stable.template_release.aar): put it in `godot-ultraleap-binder/ultraleap-binder/libs` +* [`libLeapC.so` (Android version from Ultraleap's repository)](https://github.com/ultraleap/UnityPlugin/raw/develop/Packages/Tracking/Core/Runtime/Plugins/Android/libs/libLeapC.so): put it in `android` +* [`UltraleapTrackingServiceBinder.aar` (from Ultraleap's repository)](https://github.com/ultraleap/UnityPlugin/raw/develop/Packages/Tracking/Core/Runtime/Plugins/Android/libs/UltraleapTrackingServiceBinder.aar): put it in `godot-ultraleap-binder/ultraleap-binder/libs` + +You'll also need to find the file `LeapC.h` which should be wherever your SDK is installed, and place it in `android`. Now we can go on with building: + +* Go into `godot-ultraleap-plugin` +* Build the service binder with `./gradlew build` +* Go into the root of the project +* Build the plugin with `ANDROID_NDK_ROOT= scons platform=android architecture=arm64` + +If everything went well, all files should have been copied in their respective folders. + ## :fast_forward: Quick start **These are very simple instructions and barely covers all the possibilities but it shows my willingness to try and document things to help people who want to adopt this plugin** diff --git a/SConstruct b/SConstruct index 5b0f2b1..f628680 100644 --- a/SConstruct +++ b/SConstruct @@ -59,6 +59,19 @@ elif env["platform"] == "android": env.Append(LIBS=['LeapC']) env.Append(LIBPATH = ['./android']) env.Append(CPPPATH = ["./android"]) + + post_actions = [ + Mkdir("demo/android"), + Mkdir("demo/android/plugins"), + Mkdir("demo/android/plugins/ultraleap_binder"), + Copy("demo/android/plugins/UltraleapBinder.gdap", "godot-ultraleap-binder/UltraleapBinder.gdap"), + Copy("demo/android/plugins/ultraleap_binder/UltraleapTrackingServiceBinder.aar", "godot-ultraleap-binder/ultraleap-binder/libs/UltraleapTrackingServiceBinder.aar"), + Copy("demo/android/plugins/ultraleap_binder/ultraleap-binder-debug.aar", "godot-ultraleap-binder/ultraleap-binder/build/outputs/aar/ultraleap-binder-debug.aar"), + Copy("demo/addons/godot_ultraleap_plugin/bin/libLeapC.so", "android/libLeapC.so") + ] + + for post_action in post_actions: + AddPostAction(library, post_action) else: library = env.SharedLibrary( "demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),