1#!/usr/bin/env bash 2# shellcheck disable=SC2086 # we want word splitting 3 4# When changing this file, you need to bump the following 5# .gitlab-ci/image-tags.yml tags: 6# DEBIAN_BUILD_TAG 7 8set -ex 9 10EPHEMERAL=( 11 autoconf 12 rdfind 13 unzip 14) 15 16apt-get install -y --no-remove "${EPHEMERAL[@]}" 17 18# Fetch the NDK and extract just the toolchain we want. 19ndk=$ANDROID_NDK 20curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 21 -o $ndk.zip https://dl.google.com/android/repository/$ndk-linux.zip 22unzip -d / $ndk.zip "$ndk/toolchains/llvm/*" 23rm $ndk.zip 24# Since it was packed as a zip file, symlinks/hardlinks got turned into 25# duplicate files. Turn them into hardlinks to save on container space. 26rdfind -makehardlinks true -makeresultsfile false /${ndk}/ 27# Drop some large tools we won't use in this build. 28find /${ndk}/ -type f \( -iname '*clang-check*' -o -iname '*clang-tidy*' -o -iname '*lldb*' \) -exec rm -f {} \; 29 30sh .gitlab-ci/container/create-android-ndk-pc.sh /$ndk zlib.pc "" "-lz" "1.2.3" $ANDROID_SDK_VERSION 31 32sh .gitlab-ci/container/create-android-cross-file.sh /$ndk x86_64-linux-android x86_64 x86_64 $ANDROID_SDK_VERSION 33sh .gitlab-ci/container/create-android-cross-file.sh /$ndk i686-linux-android x86 x86 $ANDROID_SDK_VERSION 34sh .gitlab-ci/container/create-android-cross-file.sh /$ndk aarch64-linux-android aarch64 armv8 $ANDROID_SDK_VERSION 35sh .gitlab-ci/container/create-android-cross-file.sh /$ndk arm-linux-androideabi arm armv7hl $ANDROID_SDK_VERSION armv7a-linux-androideabi 36 37for arch in \ 38 x86_64-linux-android \ 39 i686-linux-android \ 40 aarch64-linux-android \ 41 arm-linux-androideabi ; do 42 EXTRA_MESON_ARGS="--cross-file=/cross_file-$arch.txt --libdir=lib/$arch -Dnouveau=disabled -Dintel=disabled" \ 43 . .gitlab-ci/container/build-libdrm.sh 44done 45 46rm -rf $LIBDRM_VERSION 47 48export LIBELF_VERSION=libelf-0.8.13 49curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 50 -O https://fossies.org/linux/misc/old/$LIBELF_VERSION.tar.gz 51 52# Not 100% sure who runs the mirror above so be extra careful 53if ! echo "4136d7b4c04df68b686570afa26988ac ${LIBELF_VERSION}.tar.gz" | md5sum -c -; then 54 echo "Checksum failed" 55 exit 1 56fi 57 58tar -xf ${LIBELF_VERSION}.tar.gz 59cd $LIBELF_VERSION 60 61# Work around a bug in the original configure not enabling __LIBELF64. 62autoreconf 63 64for arch in \ 65 x86_64-linux-android \ 66 i686-linux-android \ 67 aarch64-linux-android \ 68 arm-linux-androideabi ; do 69 70 ccarch=${arch} 71 if [ "${arch}" == 'arm-linux-androideabi' ] 72 then 73 ccarch=armv7a-linux-androideabi 74 fi 75 76 export CC=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar 77 export CC=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}${ANDROID_SDK_VERSION}-clang 78 export CXX=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}${ANDROID_SDK_VERSION}-clang++ 79 export LD=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ld 80 export RANLIB=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib 81 82 # The configure script doesn't know about android, but doesn't really use the host anyway it 83 # seems 84 ./configure --host=x86_64-linux-gnu --disable-nls --disable-shared \ 85 --libdir=/usr/local/lib/${arch} 86 make install 87 make distclean 88done 89 90cd .. 91rm -rf $LIBELF_VERSION 92 93apt-get purge -y "${EPHEMERAL[@]}" 94