From b222872446f3fb4c135816625d73e5a071dec470 Mon Sep 17 00:00:00 2001 From: psi29a Date: Mon, 19 Oct 2020 08:27:38 +0000 Subject: [PATCH] Android build on gitlab --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ CI/before_install.android.sh | 4 ++++ CI/before_script.android.sh | 25 +++++++++++++++++++++++++ CMakeLists.txt | 6 +++++- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 CI/before_install.android.sh create mode 100755 CI/before_script.android.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65cfc7e092..5831a73b8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -268,3 +268,35 @@ Windows_MSBuild_CS_RelWithDebInfo: variables: <<: *cs-targets config: "RelWithDebInfo" + +Debian_AndroidNDK_arm64-v8a: + tags: + - linux + image: debian:bullseye + variables: + CCACHE_SIZE: 3G + cache: + key: Debian_AndroidNDK_arm64-v8a.v2 + paths: + - apt-cache/ + - ccache/ + before_script: + - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR + - echo "deb http://deb.debian.org/debian unstable main contrib" > /etc/apt/sources.list + - echo "google-android-ndk-installer google-android-installers/mirror select https://dl.google.com" | debconf-set-selections + - apt-get update -yq + - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y cmake ccache curl unzip git build-essential google-android-ndk-installer + stage: build + script: + - export CCACHE_BASEDIR="`pwd`" + - export CCACHE_DIR="`pwd`/ccache" && mkdir -pv "$CCACHE_DIR" + - ccache -z -M "${CCACHE_SIZE}" + - CI/before_install.android.sh + - CI/before_script.android.sh + - cd build + - cmake --build . -- -j $(nproc) + - cmake --install . + - ccache -s + artifacts: + paths: + - build/install/ \ No newline at end of file diff --git a/CI/before_install.android.sh b/CI/before_install.android.sh new file mode 100755 index 0000000000..791377dd96 --- /dev/null +++ b/CI/before_install.android.sh @@ -0,0 +1,4 @@ +#!/bin/sh -ex + +curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/android/openmw-android-deps-20201018.zip -o ~/openmw-android-deps.zip +unzip -o ~/openmw-android-deps -d /usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr > /dev/null diff --git a/CI/before_script.android.sh b/CI/before_script.android.sh new file mode 100755 index 0000000000..8f0ec77da0 --- /dev/null +++ b/CI/before_script.android.sh @@ -0,0 +1,25 @@ +#!/bin/sh -ex + +# hack to work around: FFmpeg version is too old, 3.2 is required +sed -i s/"NOT FFVER_OK"/"FALSE"/ CMakeLists.txt + +mkdir build +cd build + +cmake \ +-DCMAKE_TOOLCHAIN_FILE=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake \ +-DANDROID_ABI=arm64-v8a \ +-DANDROID_PLATFORM=android-21 \ +-DCMAKE_C_COMPILER_LAUNCHER=ccache \ +-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ +-DCMAKE_INSTALL_PREFIX=install \ +-DBUILD_BSATOOL=0 \ +-DBUILD_NIFTEST=0 \ +-DBUILD_ESMTOOL=0 \ +-DBUILD_LAUNCHER=0 \ +-DBUILD_MWINIIMPORTER=0 \ +-DBUILD_ESSIMPORTER=0 \ +-DBUILD_OPENCS=0 \ +-DBUILD_WIZARD=0 \ +-DMyGUI_LIBRARY="/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/libMyGUIEngineStatic.a" \ +.. diff --git a/CMakeLists.txt b/CMakeLists.txt index 15049548c9..829927de67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -837,7 +837,11 @@ elseif(NOT APPLE) # Install binaries IF(BUILD_OPENMW) - INSTALL(PROGRAMS "${INSTALL_SOURCE}/openmw" DESTINATION "${BINDIR}" ) + IF(ANDROID) + INSTALL(PROGRAMS "${INSTALL_SOURCE}/libopenmw.so" DESTINATION "${BINDIR}" ) + ELSE(ANDROID) + INSTALL(PROGRAMS "${INSTALL_SOURCE}/openmw" DESTINATION "${BINDIR}" ) + ENDIF(ANDROID) ENDIF(BUILD_OPENMW) IF(BUILD_LAUNCHER) INSTALL(PROGRAMS "${INSTALL_SOURCE}/openmw-launcher" DESTINATION "${BINDIR}" )