From d82ed4d34b27b643735d44a82a99a45a92462833 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Mon, 6 Nov 2023 12:51:58 +0200 Subject: [PATCH] CI: add naive cross-compilation test Signed-off-by: Dmitry Baryshkov --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 709e878..b81dfe9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,10 @@ jobs: #- ubuntu:focal #- ubuntu:bionic #- ubuntu:xenial + target: + - native + - aarch64-linux-gnu + - arm-linux-gnueabihf container: image: ${{ matrix.container }} @@ -45,8 +49,40 @@ jobs: apt update apt -y install --no-install-recommends meson build-essential + - name: Install cross-compilers + if:${{ matrix.target }} != 'native' + run: | + apt -y install gcc-${{ matrix.target }} + FAMILY=$(echo ${{ matrix.target }} | cut -d- -f 1) + if [ "${FAMILY}" = "aarch64" ] ; then + CPU="arm64" + elif [ "${FAMILY}" = "arm" ] ; then + CPU="arm" + else + echo "Unknown CPU family ${FAMILY}" + exit 1 + fi + cat > cross.txt << EOF + [binaries] + c = '${{ matrix.target }}-gcc' + strip = '${{ matrix.target }}-strip' + pkgconfig = 'pkg-config' + [host_machine] + system = 'linux' + cpu_family = '${FAMILY}' + cpu = 'arm64' + endian = 'litle' + [properties] + pkg_config_libdir = '/usr/lib/${{ matrix.target }}/pkgconfig' + EOF + cat cross.txt + - name: Build run: | - meson setup . build --werror + if [ ${{ matrix.target }} = "native" ] ; then + meson setup . build --werror + else + meson setup --cross-file cross.txt . build --werror + fi ninja -C build ninja -C build install