ada-game-framework / sdlada

Ada 2022 bindings to SDL 2
zlib License
116 stars 37 forks source link

Add Android support #22

Open Lucretia opened 6 years ago

Lucretia commented 4 years ago

Android no longer supports GCC. I've attempted to build GCC but it doesn't build complaining about missing asm/types.h and then even when I create a custom sysroot and link in the asm directory into the include directory, it fails again.

The script I used to build is this:

#!/bin/bash

TOP=$(pwd)

#API="28"
ARCH="x86_64"
TARGET="${ARCH}-linux-android"
INSTALL_DIR="${HOME}/opt/android-gnat"
SDK_DIR="${HOME}/opt/android-sdk"
NDK_DIR="${SDK_DIR}/ndk/21.1.6352462"
SYSROOT="${NDK_DIR}/sysroot"
#SYSROOT="${TOP}/sysroot/android-${ARCH}"
TARGET_INC_DIR="${SYSROOT}/usr/include/${TARGET}"

SHARED_OPTS="--enable-multilib --enable-threads=posix --disable-nls --enable-libgomp --disable-shared --disable-tls --disable-tls --disable-libitm --disable-libstdc__-v3 --disable-sjlj-exceptions --with-sysroot=${SYSROOT} --disable-libssp --with-arch=x86-64 --with-tune=intel --with-fpmath=sse --with-multilib-list=m32,m64 --enable-bionic-libs --disable-bootstrap --enable-plugins --disable-libcilkrts --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-libatomic-ifuncs=no --enable-initfini-array --enable-gnu-indirect-function"

function check_error_exit()
{
    if [ $? != 0 ]; then
        echo "  ERROR: Something went wrong!"
        exit 2;
    fi
}

mkdir -p {gcc,binutils}

cd binutils

${SHARED_OPTS} --with-sysroot=${NDK_DIR}/sysroot --includedir=${TARGET_INC_DIR} 2>&1|tee log.config.txt
${TOP}/../binutils-gdb/configure --target=${TARGET} --prefix=${INSTALL_DIR} --with-python=/usr/bin/python2 ${SHARED_OPTS} 2>&1|tee log.config.txt

make -j6 2>&1|tee log.make.txt

check_error_exit

make install

check_error_exit

cd ../gcc

${TOP}/../gcc/configure --target=${TARGET} --prefix=${INSTALL_DIR} --enable-languages=c,c++,ada ${SHARED_OPTS} --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' 2>&1|tee log.config.txt

make -j6 2>&1|tee log.make.txt

check_error_exit

make install

check_error_exit

We need an LLVM Android compiler to enable this.