diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23f03e4897f..d123d0e6a8b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -309,6 +309,20 @@ s390x_build: needs: - s390x_build +# Android NDK cross-build image +android_build: + extends: + - .use-x86_build-base + variables: + FDO_DISTRIBUTION_TAG: &android_build "2020-10-05-shrink" + +.use-android_build: + variables: + TAG: *android_build + image: "$CI_REGISTRY_IMAGE/debian/android_build:$TAG" + needs: + - android_build + # Debian 10 based x86 test image base x86_test-base: extends: x86_build-base @@ -662,7 +676,9 @@ meson-classic: -D werror=true meson-android: - extends: .meson-build + extends: + - .meson-cross + - .use-android_build variables: UNWIND: "disabled" DRI_LOADERS: > @@ -670,11 +686,9 @@ meson-android: -D gbm=disabled -D egl=enabled -D platforms=android - GALLIUM_DRIVERS: freedreno - VULKAN_DRIVERS: freedreno,intel,amd EXTRA_OPTION: > -D android-stub=true - -D werror=true + -D llvm=disabled GALLIUM_ST: > -D dri3=disabled -D gallium-vdpau=disabled @@ -684,6 +698,15 @@ meson-android: -D gallium-xa=disabled -D gallium-nine=false -D gallium-opencl=disabled + LLVM_VERSION: "" + script: + # arm64 build: Can't build v3d/vc4 because they require expat for v3d_decode. + - PKG_CONFIG_PATH=/usr/local/lib/aarch64-linux-android/pkgconfig/:/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/pkgconfig/ CROSS=aarch64-linux-android GALLIUM_DRIVERS=etnaviv,freedreno,lima,panfrost VULKAN_DRIVERS=freedreno .gitlab-ci/meson-build.sh + # x86_64 build: + # Can't do Intel because gen_decoder.c currently requires libexpat, which + # is not a dependency that AOSP wants to accept. Can't do Radeon because + # it requires LLVM, which we don't have an Android build of. + # - PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-android/pkgconfig/ CROSS=x86_64-linux-android GALLIUM_DRIVERS=iris VULKAN_DRIVERS=intel .gitlab-ci/meson-build.sh .meson-cross: extends: diff --git a/.gitlab-ci/container/android_build.sh b/.gitlab-ci/container/android_build.sh new file mode 100644 index 00000000000..ffc42fff149 --- /dev/null +++ b/.gitlab-ci/container/android_build.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -ex + +EPHEMERAL="\ + rdfind \ + unzip \ + " + +apt-get install -y --no-remove $EPHEMERAL + +# Fetch the NDK and extract just the toolchain we want. +ndk=android-ndk-r21d +wget -O $ndk.zip https://dl.google.com/android/repository/$ndk-linux-x86_64.zip +unzip -d / $ndk.zip "$ndk/toolchains/llvm/*" +rm $ndk.zip +# Since it was packed as a zip file, symlinks/hardlinks got turned into +# duplicate files. Turn them into hardlinks to save on container space. +rdfind -makehardlinks true -makeresultsfile false /android-ndk-r21d/ +# Drop some large tools we won't use in this build. +find /android-ndk-r21d/ -type f | egrep -i "clang-check|clang-tidy|lldb" | xargs rm -f + +sh .gitlab-ci/create-android-ndk-pc.sh /$ndk zlib.pc "" "-lz" "1.2.3" + +sh .gitlab-ci/create-android-cross-file.sh /$ndk x86_64-linux-android x86_64 x86_64 +sh .gitlab-ci/create-android-cross-file.sh /$ndk i686-linux-android x86 x86 +sh .gitlab-ci/create-android-cross-file.sh /$ndk aarch64-linux-android arm armv8 +sh .gitlab-ci/create-android-cross-file.sh /$ndk arm-linux-androideabi arm armv7hl armv7a-linux-androideabi + +# Not using build-libdrm.sh because we don't want its cleanup after building +# each arch. Fetch and extract now. +export LIBDRM_VERSION=libdrm-2.4.102 +wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.xz +tar -xf $LIBDRM_VERSION.tar.xz && rm $LIBDRM_VERSION.tar.xz + +for arch in \ + x86_64-linux-android \ + i686-linux-android \ + aarch64-linux-android \ + arm-linux-androideabi ; do + + cd $LIBDRM_VERSION + rm -rf build-$arch + meson build-$arch \ + --cross-file=/cross_file-$arch.txt \ + --libdir=lib/$arch \ + -Dlibkms=false \ + -Dnouveau=false \ + -Dvc4=false \ + -Detnaviv=false \ + -Dfreedreno=false \ + -Dintel=false \ + -Dcairo-tests=false + ninja -C build-$arch install + cd .. +done + +rm -rf $LIBDRM_VERSION + +apt-get purge -y $EPHEMERAL diff --git a/.gitlab-ci/create-android-cross-file.sh b/.gitlab-ci/create-android-cross-file.sh new file mode 100644 index 00000000000..4590ce172a9 --- /dev/null +++ b/.gitlab-ci/create-android-cross-file.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +ndk=$1 +arch=$2 +cpu_family=$3 +cpu=$4 +cross_file="/cross_file-$arch.txt" + +# armv7 has the toolchain split between two names. +arch2=${5:-$2} + +# Note that we disable C++ exceptions, because Mesa doesn't use exceptions, +# and allowing it in code generation means we get unwind symbols that break +# the libEGL and driver symbol tests. + +cat >$cross_file <$pcdir/$pc <