ci/android: move sdk version and ndk to a job variable

make it easier to update sdk version and ndk without the need to make
changes all over the code.

Suggested-by: David Heidelberg <david.heidelberg@collabora.com>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Sergi Blanch Torné <sergi.blanch.torne@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20019>
This commit is contained in:
Helen Koike 2022-12-02 11:30:44 -03:00
parent bdcbf7dcf8
commit d66cfe6a3e
4 changed files with 22 additions and 18 deletions

View file

@ -5,9 +5,10 @@ arch=$2
cpu_family=$3 cpu_family=$3
cpu=$4 cpu=$4
cross_file="/cross_file-$arch.txt" cross_file="/cross_file-$arch.txt"
sdk_version=$5
# armv7 has the toolchain split between two names. # armv7 has the toolchain split between two names.
arch2=${5:-$2} arch2=${6:-$2}
# Note that we disable C++ exceptions, because Mesa doesn't use exceptions, # 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 # and allowing it in code generation means we get unwind symbols that break
@ -16,8 +17,8 @@ arch2=${5:-$2}
cat > "$cross_file" <<EOF cat > "$cross_file" <<EOF
[binaries] [binaries]
ar = '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$arch-ar' ar = '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$arch-ar'
c = ['ccache', '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch2}29-clang', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables'] c = ['ccache', '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch2}${sdk_version}-clang', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables']
cpp = ['ccache', '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch2}29-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables'] cpp = ['ccache', '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch2}${sdk_version}-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables']
c_ld = 'lld' c_ld = 'lld'
cpp_ld = 'lld' cpp_ld = 'lld'
strip = '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$arch-strip' strip = '$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$arch-strip'

View file

@ -10,6 +10,7 @@ pc="$2"
cflags="$3" cflags="$3"
libs="$4" libs="$4"
version="$5" version="$5"
sdk_version="$6"
sysroot=$ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot sysroot=$ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot
@ -24,7 +25,7 @@ for arch in \
cat >$pcdir/$pc <<EOF cat >$pcdir/$pc <<EOF
prefix=$sysroot prefix=$sysroot
exec_prefix=$sysroot exec_prefix=$sysroot
libdir=$sysroot/usr/lib/$arch/29 libdir=$sysroot/usr/lib/$arch/$sdk_version
sharedlibdir=$sysroot/usr/lib/$arch sharedlibdir=$sysroot/usr/lib/$arch
includedir=$sysroot/usr/include includedir=$sysroot/usr/include
@ -33,7 +34,7 @@ Description: zlib compression library
Version: $version Version: $version
Requires: Requires:
Libs: -L$sysroot/usr/lib/$arch/29 $libs Libs: -L$sysroot/usr/lib/$arch/$sdk_version $libs
Cflags: -I$sysroot/usr/include $cflags Cflags: -I$sysroot/usr/include $cflags
EOF EOF
done done

View file

@ -12,23 +12,23 @@ EPHEMERAL="\
apt-get install -y --no-remove $EPHEMERAL apt-get install -y --no-remove $EPHEMERAL
# Fetch the NDK and extract just the toolchain we want. # Fetch the NDK and extract just the toolchain we want.
ndk=android-ndk-r21d ndk=$ANDROID_NDK
curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
-o $ndk.zip https://dl.google.com/android/repository/$ndk-linux-x86_64.zip -o $ndk.zip https://dl.google.com/android/repository/$ndk-linux-x86_64.zip
unzip -d / $ndk.zip "$ndk/toolchains/llvm/*" unzip -d / $ndk.zip "$ndk/toolchains/llvm/*"
rm $ndk.zip rm $ndk.zip
# Since it was packed as a zip file, symlinks/hardlinks got turned into # Since it was packed as a zip file, symlinks/hardlinks got turned into
# duplicate files. Turn them into hardlinks to save on container space. # duplicate files. Turn them into hardlinks to save on container space.
rdfind -makehardlinks true -makeresultsfile false /android-ndk-r21d/ rdfind -makehardlinks true -makeresultsfile false /${ndk}/
# Drop some large tools we won't use in this build. # Drop some large tools we won't use in this build.
find /android-ndk-r21d/ -type f | grep -E -i "clang-check|clang-tidy|lldb" | xargs rm -f find /${ndk}/ -type f | grep -E -i "clang-check|clang-tidy|lldb" | xargs rm -f
sh .gitlab-ci/container/create-android-ndk-pc.sh /$ndk zlib.pc "" "-lz" "1.2.3" sh .gitlab-ci/container/create-android-ndk-pc.sh /$ndk zlib.pc "" "-lz" "1.2.3" $ANDROID_SDK_VERSION
sh .gitlab-ci/container/create-android-cross-file.sh /$ndk x86_64-linux-android x86_64 x86_64 sh .gitlab-ci/container/create-android-cross-file.sh /$ndk x86_64-linux-android x86_64 x86_64 $ANDROID_SDK_VERSION
sh .gitlab-ci/container/create-android-cross-file.sh /$ndk i686-linux-android x86 x86 sh .gitlab-ci/container/create-android-cross-file.sh /$ndk i686-linux-android x86 x86 $ANDROID_SDK_VERSION
sh .gitlab-ci/container/create-android-cross-file.sh /$ndk aarch64-linux-android arm armv8 sh .gitlab-ci/container/create-android-cross-file.sh /$ndk aarch64-linux-android arm armv8 $ANDROID_SDK_VERSION
sh .gitlab-ci/container/create-android-cross-file.sh /$ndk arm-linux-androideabi arm armv7hl armv7a-linux-androideabi sh .gitlab-ci/container/create-android-cross-file.sh /$ndk arm-linux-androideabi arm armv7hl $ANDROID_SDK_VERSION armv7a-linux-androideabi
# Not using build-libdrm.sh because we don't want its cleanup after building # Not using build-libdrm.sh because we don't want its cleanup after building
# each arch. Fetch and extract now. # each arch. Fetch and extract now.
@ -90,11 +90,11 @@ for arch in \
ccarch=armv7a-linux-androideabi ccarch=armv7a-linux-androideabi
fi fi
export CC=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ar export CC=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ar
export CC=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}29-clang export CC=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}${ANDROID_SDK_VERSION}-clang
export CXX=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}29-clang++ export CXX=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${ccarch}${ANDROID_SDK_VERSION}-clang++
export LD=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ld export LD=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ld
export RANLIB=/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ranlib export RANLIB=/${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${arch}-ranlib
# The configure script doesn't know about android, but doesn't really use the host anyway it # The configure script doesn't know about android, but doesn't really use the host anyway it
# seems # seems

View file

@ -174,6 +174,8 @@ debian/android_build:
- .use-debian/x86_build-base - .use-debian/x86_build-base
variables: variables:
MESA_IMAGE_TAG: &debian-android_build ${DEBIAN_BUILD_TAG} MESA_IMAGE_TAG: &debian-android_build ${DEBIAN_BUILD_TAG}
ANDROID_SDK_VERSION: 29
ANDROID_NDK: android-ndk-r21d
.use-debian/android_build: .use-debian/android_build:
extends: extends: