Fusion setup

NOTE: This guide is currently outdated. Android and iOS support is coming.

1. What is the Fusion Sphere for?

2. Supporting the Android platform

Android support requires Android NDK and SDK. Please download them and move them to a folder permanently. We need to define the following environment variables: ANDROID_NDK_DIR (the Android NDK root directory) and ANDROID_SDK_DIR (the Android SDK root directory). In Linux, this would setup these variables in current Bash session:

export ANDROID_NDK_DIR="/data/sources/android-ndk-r8b/"
export ANDROID_SDK_DIR="/data/sources/android-sdk-linux/"

placing this in .bashrc will export this environment variables for each new Bash session. Also, adding SDK and NDK programs to the System path is recommended if you plan on developing for Android

export PATH=$PATH:/data/sources/android/android-sdk-linux/tools:/data/sources/android/android-ndk-r8b/:/data/sources/android/android-sdk-linux/platform-tools

Finally, we will need to cross-compile Gambit runtime library for the ARM architecture. We need to export the following variables and run ./configure and make with the proper flags in a clean tree (run make clean in case you've built Gambit before for your any other platform in the same directory).

export PATH=$PATH:$ANDROID_NDK_DIR/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar
export STRIP=arm-linux-androideabi-strip
export RANLIB=arm-linux-androideabi-ranlib
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export PREFIX=$ANDROID_NDK_DIR/../gambc

./configure --enable-single-host --prefix=$PREFIX --host=arm-eabi CC=arm-linux-androideabi-gcc CPPFLAGS="-DANDROID -I$ANDROID_NDK_DIR/platforms/android-14/arch-arm/usr/include/ -fno-short-enums" CFLAGS="-DANDROID -fno-short-enums -I$ANDROID_NDK_DIR/platforms/android-14/arch-arm/usr/include/ -nostdlib" LDFLAGS="-Wl,-rpath-link=$ANDROID_NDK_DIR/platforms/android-14/arch-arm/usr/lib/ -L$ANDROID_NDK_DIR/platforms/android-14/arch-arm/usr/lib" LIBS="-lc -ldl"
make -j

It will break when trying to compile gsi, but you don't need it. You only need libgambc.a. Once compilation is done, follow these two steps:

  1. Copy lib/libgambc.a from Gambit sources to android/jni/gambit in Fusion directory (create it if necessary)
  2. Copy include/gambit.h and include/gambit-not{gambit-version}.h from Gambit sources to android/jni/gambit in Fusion directory

Updating Gambit

Gambit updates will require updating Gambit runtime for all platforms, so we need to repeat this whole process for Android. If you get a segmentation fault with Gambit when loading a module that is precompiled, probably it was compiled with a different Gambit version, so Spheres must be recompiled as well·

3. Support for iOS

4. Cross-compilation