From 5d0a99105d0f1972b05410d1388ec942bceaf483 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 20 May 2018 00:08:19 -0400 Subject: [PATCH 1/2] Meson: Always fallback to proxy-libintl subproject An implementation of gettext is required, but it's not always needed e.g. for CI builds. https://bugzilla.gnome.org/show_bug.cgi?id=796264 --- meson.build | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index d25dff3f2..ab2fcc8e5 100644 --- a/meson.build +++ b/meson.build @@ -1687,17 +1687,23 @@ else endif endif -# Only used on non-glibc targets -libintl = cc.find_library('intl', required : false) -if host_system == 'windows' and not libintl.found() - # Used only when the gettext library is not available (MSVC, not MinGW) - libintl = subproject('proxy-libintl').get_variable('intl_dep') - glib_conf.set('HAVE_DCGETTEXT', 1) +# First check in libc, fallback to libintl, and as last chance build +# proxy-libintl subproject. +# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible +# implementations. This could be extended if issues are found in some platforms. +if cc.has_function('ngettext') + libintl = [] else - glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext')) + libintl = cc.find_library('intl', required : false) + if not libintl.found() + libintl = subproject('proxy-libintl').get_variable('intl_dep') + endif endif + # We require gettext to always be present +glib_conf.set('HAVE_DCGETTEXT', 1) glib_conf.set('HAVE_GETTEXT', 1) + glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale')) # xgettext is optional (on Windows for instance) xgettext = find_program('xgettext', required : false) From f83493f83d247e2c7a3f10f4361282b09aa1bd7e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 20 May 2018 00:14:56 -0400 Subject: [PATCH 2/2] Add Android CI This adds to the CI a cross build for Android NDK r16 API 21 (because thats what GStreamer currently use) for arm64. GNU iconv must be built manually into our docker image because Android NDK doesn't seems to ship it. The latest NDK r17 API 28 has iconv.h but iconv_open() symbol isn't found by the linker. Looks like broken NDK. libffi also needs to be built manually because the meson subproject doesn't support building for Android platform. It needs a recent RC release because latest stable release is 4 years old and fails to build. Fixes #1385. --- .gitlab-ci.yml | 14 ++++- .gitlab-ci/Dockerfile | 6 ++ .gitlab-ci/setup-android-ndk.sh | 106 ++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100755 .gitlab-ci/setup-android-ndk.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ccee2ed0c..7df974b3b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: registry.gitlab.gnome.org/gnome/glib/master:v1 +image: registry.gitlab.gnome.org/gnome/glib/master:v2 stages: - build @@ -32,6 +32,18 @@ fedora-meson-x86_64: - "${CI_PROJECT_DIR}/_build/meson-logs" - "${CI_PROJECT_DIR}/_coverage" +fedora-meson-android_ndk_r16_api21_arm64: + stage: build + except: + - tags + script: + # FIXME: add --werror + - meson --cross-file=/opt/cross-file-android_ndk_r16_api21_arm64.txt -Diconv=gnu -Dinternal_pcre=true --buildtype debug _build + - ninja -C _build + artifacts: + paths: + - "${CI_PROJECT_DIR}/_build/meson-logs" + msys2-mingw32: stage: build tags: diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile index dab235166..713cf095a 100644 --- a/.gitlab-ci/Dockerfile +++ b/.gitlab-ci/Dockerfile @@ -25,10 +25,16 @@ RUN dnf -y install \ python3-wheel \ systemtap-sdt-devel \ zlib-devel \ + wget \ + unzip \ + make \ && dnf clean all RUN pip3 install meson +COPY setup-android-ndk.sh . +RUN ./setup-android-ndk.sh + ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} RUN useradd -u $HOST_USER_ID -ms /bin/bash user diff --git a/.gitlab-ci/setup-android-ndk.sh b/.gitlab-ci/setup-android-ndk.sh new file mode 100755 index 000000000..0bce26b80 --- /dev/null +++ b/.gitlab-ci/setup-android-ndk.sh @@ -0,0 +1,106 @@ +#!/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 + +cd /opt + +# Download Android NDK +wget --quiet https://dl.google.com/android/repository/android-ndk-r16-linux-x86_64.zip +echo "5b9ec70eac78f6cef8572dff9a133c9b18c83155dc6d980237a6925df4ae65b7b2adb3d8ea55b3ce9f3f75868f20eefdb8c87da110683c2dd1a1a27c44dc5b91 android-ndk-r16-linux-x86_64.zip" | sha512sum -c +unzip android-ndk-r16-linux-x86_64.zip +rm android-ndk-r16-linux-x86_64.zip + +# Setup cross build env +export ANDROID_HOST=aarch64-linux-android +export ANDROID_BUILD=linux-x86_64 +export ANDROID_ARCH=arm64 +export ANDROID_NDK=/opt/android-ndk-r16 +export ANDROID_VERSION=21 +export ANDROID_TOOLCHAIN_VERSION=4.9 +export ANDROID_SYSROOT=$ANDROID_NDK/platforms/android-$ANDROID_VERSION/arch-$ANDROID_ARCH +export ANDROID_PREBUILT=$ANDROID_NDK/toolchains/$ANDROID_HOST-$ANDROID_TOOLCHAIN_VERSION/prebuilt/$ANDROID_BUILD/bin +export CPPFLAGS="--sysroot=$ANDROID_SYSROOT -isystem $ANDROID_NDK/sysroot/usr/include/ -isystem $ANDROID_NDK/sysroot/usr/include/$ANDROID_HOST" +export CFLAGS="$CPPFLAGS -D__ANDROID_API__=$ANDROID_VERSION" +export AR=$ANDROID_HOST-ar +export RANLIB=$ANDROID_HOST-ranlib +export CPP=$ANDROID_HOST-cpp +export PATH=$ANDROID_PREBUILT:$PATH + +# Cross build libiconv +wget --quiet http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz +echo "1233fe3ca09341b53354fd4bfe342a7589181145a1232c9919583a8c9979636855839049f3406f253a9d9829908816bb71fd6d34dd544ba290d6f04251376b1a libiconv-1.15.tar.gz" | sha512sum -c +tar xzf libiconv-1.15.tar.gz +rm libiconv-1.15.tar.gz +pushd libiconv-1.15 +./configure --host=$ANDROID_HOST --prefix=/opt/$ANDROID_HOST --libdir=/opt/$ANDROID_HOST/lib64 +make +make install +popd + +# 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 +rm libffi-3.3-rc0.tar.gz +pushd libffi-3.3-rc0 +./configure --host=$ANDROID_HOST --prefix=/opt/$ANDROID_HOST --libdir=/opt/$ANDROID_HOST/lib64 +make +make install +popd + +# Create a pkg-config wrapper that won't pick fedora libraries +export PKG_CONFIG=/opt/${ANDROID_HOST}/bin/pkg-config +cat > $PKG_CONFIG <<- EOM +#!/bin/sh +SYSROOT=/opt/${ANDROID_HOST} +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 > /opt/cross-file-android_ndk_r16_api21_arm64.txt <<- EOM +[host_machine] +system = 'android' +cpu_family = 'arm64' +cpu = 'arm64' +endian = 'little' + +[properties] +c_args = ['--sysroot=${ANDROID_SYSROOT}', + '-isystem', '/opt/${ANDROID_HOST}/include', + '-isystem', '${ANDROID_NDK}/sysroot/usr/include/', + '-isystem', '${ANDROID_NDK}/sysroot/usr/include/${ANDROID_HOST}', + '-D__ANDROID_API__=${ANDROID_VERSION}'] +c_link_args = ['--sysroot=${ANDROID_SYSROOT}', + '-L/opt/${ANDROID_HOST}/lib64', + '-fuse-ld=gold'] + +[binaries] +c = '${ANDROID_PREBUILT}/${ANDROID_HOST}-gcc' +cpp = '${ANDROID_PREBUILT}/${ANDROID_HOST}-g++' +ar = '${ANDROID_PREBUILT}/${ANDROID_HOST}-ar' +strip = '${ANDROID_PREBUILT}/${ANDROID_HOST}-strip' +pkgconfig = '${PKG_CONFIG}' +EOM