Refactored Godot Official Demo Using GDNative
- CMake
- A C++ Toolchain (LLVM or GCC all OK) or Android NDK (If need to build to Android APP)
- Godot Engine >= 3.1
Generate api.json
of your Godot
verson
godot --gdnative-generate-json-api api.json
Make a build folder
mkdir cmake-build
cd cmake-build
Get ready to make. Choose a build option.
Example 0. Make with default toolchain
cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_CUSTOM_API_FILE=../api.json ..
Example 1. Make with Clang
CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_CUSTOM_API_FILE=../api.json ..
Example 2. Make with NDK (armeabi-v7a)
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=armeabi-v7a -DGODOT_CUSTOM_API_FILE=../api.json ..
Example 3. Make with NDK (arm64-v8a)
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DANDROID_TOOLCHAIN=aarch64-linux-android -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DGODOT_CUSTOM_API_FILE=../api.json ..
Then build.
cmake --build . -j5
Export. See Godot engine docs