From 3a8622c9e1b3767bd011bff8cfb014ff72eb48a6 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 26 Apr 2022 10:50:36 -0400 Subject: [PATCH] ci: Update to latest Android NDK Move the NDK in the common Fedora image, better have 1 bigger image that gets cached into runners. It is also less images to maintain. Fixes: #2605 --- .gitlab-ci.yml | 9 +- .gitlab-ci/android-ndk.Dockerfile | 87 ------------------- ...android-download-ndk.sh => android-ndk.sh} | 15 ++-- .gitlab-ci/android-setup-env.sh | 87 ------------------- .gitlab-ci/cross_file_android_arm64_31.txt | 20 +++++ .gitlab-ci/fedora.Dockerfile | 3 + 6 files changed, 35 insertions(+), 186 deletions(-) delete mode 100644 .gitlab-ci/android-ndk.Dockerfile rename .gitlab-ci/{android-download-ndk.sh => android-ndk.sh} (70%) delete mode 100755 .gitlab-ci/android-setup-env.sh create mode 100644 .gitlab-ci/cross_file_android_arm64_31.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5db361d9..8488d2b8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,10 +10,9 @@ cache: - _ccache/ variables: - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v14" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v15" COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v4" DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v10" - ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v7" MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v6" MESON_TEST_TIMEOUT_MULTIPLIER: 2 G_MESSAGES_DEBUG: all @@ -255,14 +254,14 @@ valgrind: paths: - "_build/meson-logs" -cross-android_api28_arm64: +cross-android_arm64: extends: - .cross-build-linux - .only-default - image: $ANDROID_IMAGE + image: $FEDORA_IMAGE script: # FIXME: add --werror - - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt _build + - meson ${MESON_COMMON_OPTIONS} --cross-file=.gitlab-ci/cross_file_android_arm64_31.txt _build - ninja -C _build cross-mingw64: diff --git a/.gitlab-ci/android-ndk.Dockerfile b/.gitlab-ci/android-ndk.Dockerfile deleted file mode 100644 index 0b410d42d..000000000 --- a/.gitlab-ci/android-ndk.Dockerfile +++ /dev/null @@ -1,87 +0,0 @@ -FROM fedora:34 - -RUN dnf -y install \ - autoconf \ - automake \ - bindfs \ - clang \ - clang-analyzer \ - desktop-file-utils \ - elfutils-libelf-devel \ - findutils \ - fuse \ - gcc \ - gcc-c++ \ - gettext \ - git \ - glibc-devel \ - glibc-headers \ - glibc-langpack-de \ - glibc-langpack-el \ - glibc-langpack-el \ - glibc-langpack-en \ - glibc-langpack-es \ - glibc-langpack-es \ - glibc-langpack-fa \ - glibc-langpack-fr \ - glibc-langpack-hr \ - glibc-langpack-ja \ - glibc-langpack-lt \ - glibc-langpack-pl \ - glibc-langpack-ru \ - glibc-langpack-tr \ - gtk-doc \ - itstool \ - lcov \ - libattr-devel \ - libffi-devel \ - libmount-devel \ - libselinux-devel \ - libtool \ - libxslt \ - make \ - ncurses-compat-libs \ - ninja-build \ - pcre-devel \ - python-unversioned-command \ - python3 \ - python3-pip \ - python3-wheel \ - systemtap-sdt-devel \ - unzip \ - wget \ - xz \ - zlib-devel \ - && dnf clean all - -WORKDIR /opt -ENV ANDROID_NDK_PATH /opt/android-ndk -COPY android-download-ndk.sh . -RUN ./android-download-ndk.sh -COPY android-setup-env.sh . -RUN ./android-setup-env.sh arm64 28 -# Explicitly remove some directories first to fix symlink traversal problems -RUN rm -rf \ - $ANDROID_NDK_PATH/sources/third_party/vulkan/src/tests/layers \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/containers/unord/unord.multimap/unord.multimap.modifiers \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/containers/unord/unord.multiset/unord.multiset.cnstr \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory_symlink \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/experimental/filesystem/fs.op.funcs/fs.op.is_directory \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_hard_link \ - $ANDROID_NDK_PATH/sources/cxx-stl/llvm-libc++/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory \ - $ANDROID_NDK_PATH - -RUN pip3 install meson==0.60.3 - -ARG HOST_USER_ID=5555 -ENV HOST_USER_ID ${HOST_USER_ID} -RUN useradd -u $HOST_USER_ID -ms /bin/bash user - -USER user -WORKDIR /home/user - -COPY cache-subprojects.sh . -RUN ./cache-subprojects.sh - -ENV LANG C.UTF-8 diff --git a/.gitlab-ci/android-download-ndk.sh b/.gitlab-ci/android-ndk.sh similarity index 70% rename from .gitlab-ci/android-download-ndk.sh rename to .gitlab-ci/android-ndk.sh index 7739e39d5..8357fd959 100755 --- a/.gitlab-ci/android-download-ndk.sh +++ b/.gitlab-ci/android-ndk.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright 2018 Collabora ltd. +# Copyright 2022 Collabora ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -22,10 +22,11 @@ set -e # Download Android NDK -ANDROID_NDK_VERSION="r17b" -ANDROID_NDK_SHA512="062fac12f747730f5563995089a8b4abab683fbbc621aa8582fdf35fe327daee5d69ed2437af257c10ec4ef54ecd3805a8f134a1400eb8f34ee76f55c8dc9ae9" -wget --quiet "https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" -echo "${ANDROID_NDK_SHA512} android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" | sha512sum -c -unzip "android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" -rm "android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" +ANDROID_NDK_PATH=/opt/android-ndk +ANDROID_NDK_VERSION="r23b" +ANDROID_NDK_SHA512="5f2b58e605fc99d4fd3e9d2210e7f5e76e89245fa9428ce0d890e2e03b598c62c48ebd528fcb76556f04b46b87afea52e1e8d280f32cd1232f290e074bfa56fa" +wget --quiet "https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux.zip" +echo "${ANDROID_NDK_SHA512} android-ndk-${ANDROID_NDK_VERSION}-linux.zip" | sha512sum -c +unzip "android-ndk-${ANDROID_NDK_VERSION}-linux.zip" +rm "android-ndk-${ANDROID_NDK_VERSION}-linux.zip" mv "android-ndk-${ANDROID_NDK_VERSION}" "${ANDROID_NDK_PATH}" diff --git a/.gitlab-ci/android-setup-env.sh b/.gitlab-ci/android-setup-env.sh deleted file mode 100755 index f6b26e563..000000000 --- a/.gitlab-ci/android-setup-env.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -# -# Copyright 2018 Collabora ltd. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, see . -# -# Author: Xavier Claessens -# - -set -e - -arch=$1 -api=$2 -toolchain_path=$(pwd)/android-toolchain-$arch-$api -prefix_path=$(pwd)/android-$arch-$api - -# Create standalone toolchains -"${ANDROID_NDK_PATH}/build/tools/make_standalone_toolchain.py" --arch "${arch}" --api "${api}" --install-dir "${toolchain_path}" - -target_host=aarch64-linux-android -export AR=$target_host-ar -export AS=$target_host-clang -export CC=$target_host-clang -export CXX=$target_host-clang++ -export LD=$target_host-ld -export STRIP=$target_host-strip -export PATH=$PATH:$toolchain_path/bin - -# Cross build libffi -wget --quiet https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz -echo "e6e695d32cd6eb7d65983f32986fccdfc786a593d2ea18af30ce741f58cfa1eb264b1a8d09df5084cb916001aea15187b005c2149a0620a44397a4453b6137d4 libffi-3.3-rc0.tar.gz" | sha512sum -c -tar xzf libffi-3.3-rc0.tar.gz -pushd libffi-3.3-rc0 -./configure --host="${target_host}" --prefix="${prefix_path}" --libdir="${prefix_path}/lib64" -make -make install -popd -rm libffi-3.3-rc0.tar.gz -rm -r libffi-3.3-rc0 - -# Create a pkg-config wrapper that won't pick fedora libraries -mkdir -p "${prefix_path}/bin" -export PKG_CONFIG=$prefix_path/bin/pkg-config -cat > "${PKG_CONFIG}" <<- EOM -#!/bin/sh -SYSROOT=${prefix_path} -export PKG_CONFIG_DIR= -export PKG_CONFIG_LIBDIR=\${SYSROOT}/lib64/pkgconfig -export PKG_CONFIG_SYSROOT_DIR=\${SYSROOT} -exec pkg-config "\$@" -EOM -chmod +x "${PKG_CONFIG}" - -# Create a cross file that can be passed to meson -cat > "cross_file_android_${arch}_${api}.txt" <<- EOM -[host_machine] -system = 'android' -cpu_family = 'aarch64' -cpu = 'aarch64' -endian = 'little' - -[properties] -c_args = ['-I${prefix_path}/include'] -c_link_args = ['-L${prefix_path}/lib64', - '-fuse-ld=gold'] -growing_stack = true - -[binaries] -c = '${toolchain_path}/bin/${CC}' -cpp = '${toolchain_path}/bin/${CXX}' -ar = '${toolchain_path}/bin/${AR}' -ld = '${toolchain_path}/bin/${LD}' -strip = '${toolchain_path}/bin/${STRIP}' -pkgconfig = '${PKG_CONFIG}' -EOM diff --git a/.gitlab-ci/cross_file_android_arm64_31.txt b/.gitlab-ci/cross_file_android_arm64_31.txt new file mode 100644 index 000000000..f65af2905 --- /dev/null +++ b/.gitlab-ci/cross_file_android_arm64_31.txt @@ -0,0 +1,20 @@ +[constants] +ndk_path = '/opt/android-ndk' +toolchain = ndk_path / 'toolchains/llvm/prebuilt/linux-x86_64' + +[host_machine] +system = 'android' +cpu_family = 'aarch64' +cpu = 'aarch64' +endian = 'little' + +[properties] +sys_root = toolchain / 'sysroot' +c_ld = 'gold' +cpp_ld = 'gold' + +[binaries] +c = toolchain / 'bin/aarch64-linux-android31-clang' +cpp = toolchain / 'bin/aarch64-linux-android31-clang++' +ar = toolchain / 'bin/llvm-ar' +strip = toolchain / 'bin/llvm-strip' diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index f00751879..d67cd3511 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -85,6 +85,9 @@ ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} RUN useradd -u $HOST_USER_ID -G wheel -ms /bin/bash user +COPY android-ndk.sh . +RUN ./android-ndk.sh + USER user WORKDIR /home/user