From 5b0f5196d4b7523997e9a755471d8e1459999466 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 27 Apr 2020 17:50:56 -0500 Subject: [PATCH] ci: Add 32-bit builds --- .gitlab-ci.yml | 22 ++++++++- .gitlab-ci/debian:container_prep.sh | 4 ++ .gitlab-ci/i386-cross.txt | 17 +++++++ .gitlab-ci/i386.cmake | 37 ++++++++++++++++ .gitlab-ci/install-cross.sh | 69 +++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci/i386-cross.txt create mode 100644 .gitlab-ci/i386.cmake create mode 100644 .gitlab-ci/install-cross.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60a9ca491..c0ff2c369 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ variables: .monado.debian:buster: variables: FDO_DISTRIBUTION_VERSION: buster - FDO_DISTRIBUTION_TAG: "2019-04-28.0" + FDO_DISTRIBUTION_TAG: "2019-04-28.1" # Variables for build and usage of Debian 10 (Buster) + Android NDK image .monado.debian:buster-ndk: @@ -50,7 +50,7 @@ stages: # Each most-derived job has a script to set up stuff for it. FDO_DISTRIBUTION_EXEC: "bash .gitlab-ci/${CI_JOB_NAME}.sh" -# Debian Buster (x64) +# Debian Buster (x64 + i386) debian:container_prep: stage: container_prep extends: @@ -176,6 +176,24 @@ arch:meson: variables: MESON_ARGS: -Ddocs=disabled +# Cross-compiling +debian:meson:32bit: + extends: + - .monado.debian:buster # local + - .fdo.distribution-image@debian # from ci-templates + - .monado.build-meson # local + variables: + MESON_ARGS: --prefix /usr --libdir /usr/lib/i386-linux-gnu --cross-file ../.gitlab-ci/i386-cross.txt + +debian:cmake:32bit: + extends: + - .monado.debian:buster # local + - .fdo.distribution-image@debian # from ci-templates + - .monado.build-cmake # local + variables: + # OpenCV and local OpenHMD doesn't play nicely with us in multi-arch. + CMAKE_ARGS: -DCMAKE_TOOLCHAIN_FILE=../.gitlab-ci/i386.cmake -DBUILD_WITH_OPENCV=off -DBUILD_WITH_OPENHMD=off + # Base of Android NDK builds. # Takes the last :-delimited part of the name as the ABI to build for, # so you don't need to do anything other than "extends" in the job diff --git a/.gitlab-ci/debian:container_prep.sh b/.gitlab-ci/debian:container_prep.sh index 7cacc72dc..5824bcb8e 100644 --- a/.gitlab-ci/debian:container_prep.sh +++ b/.gitlab-ci/debian:container_prep.sh @@ -1,5 +1,9 @@ #!/bin/bash +( + cd $(dirname $0) + bash ./install-cross.sh +) ( cd $(dirname $0) bash ./build-openxr-openhmd.sh diff --git a/.gitlab-ci/i386-cross.txt b/.gitlab-ci/i386-cross.txt new file mode 100644 index 000000000..78e3322e8 --- /dev/null +++ b/.gitlab-ci/i386-cross.txt @@ -0,0 +1,17 @@ +[binaries] +c = '/usr/bin/i686-linux-gnu-gcc' +cpp = '/usr/bin/i686-linux-gnu-g++' +ar = '/usr/bin/i686-linux-gnu-ar' +strip = '/usr/bin/i686-linux-gnu-strip' +objcopy = '/usr/bin/i686-linux-gnu-objcopy' +ld= '/usr/bin/i686-linux-gnu-ld' +pkgconfig = '/usr/bin/i686-linux-gnu-pkg-config' + +[properties] +needs_exe_wrapper = False + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'i386' +endian = 'little' diff --git a/.gitlab-ci/i386.cmake b/.gitlab-ci/i386.cmake new file mode 100644 index 000000000..80d768937 --- /dev/null +++ b/.gitlab-ci/i386.cmake @@ -0,0 +1,37 @@ +# Toolchain file for 32-bit x86 linux build on 64-bit x86 linux +# Developed for use with Debian and its derivatives +# +# Copyright 2019-2020 Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + +set(CMAKE_SYSTEM_NAME Linux) + +set(TARGET i686-linux-gnu) +set(PREFIX ${TARGET}-) +set(SUFFIX) # required for +set(CMAKE_C_COMPILER ${PREFIX}gcc${SUFFIX}) +set(CMAKE_CXX_COMPILER ${PREFIX}g++${SUFFIX}) + +set(CMAKE_C_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX}) +set(CMAKE_CXX_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX}) +set(CMAKE_C_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX}) +set(CMAKE_CXX_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX}) +set(CMAKE_NM ${PREFIX}gcc-nm${SUFFIX}) +set(CMAKE_OBJCOPY ${PREFIX}objcopy) +set(CMAKE_OBJDUMP ${PREFIX}objdump) +set(CMAKE_RANLIB ${PREFIX}ranlib) +set(CMAKE_STRIP ${PREFIX}strip) + +set(PKG_CONFIG_EXECUTABLE ${PREFIX}pkg-config) + +if(NOT CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX /usr/${TARGET}) +endif() + +set(CMAKE_SYSTEM_LIBRARY_PATH /usr/lib/i386-linux-gnu;/usr/lib32;/usr/${TARGET}/lib) + +set(CMAKE_FIND_ROOT_PATH /usr/${TARGET}) + +# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/.gitlab-ci/install-cross.sh b/.gitlab-ci/install-cross.sh new file mode 100644 index 000000000..fd2265824 --- /dev/null +++ b/.gitlab-ci/install-cross.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/.gitlab-ci/container/x86_build.sh + +set -e +set -o xtrace + +export DEBIAN_FRONTEND=noninteractive + +CROSS_ARCHITECTURES="i386" +for arch in $CROSS_ARCHITECTURES; do + dpkg --add-architecture $arch +done + +apt-get update + +for arch in $CROSS_ARCHITECTURES; do + # OpenCV and libuvc aren't on this list because + # they apparently can't be installed in both architectures at once + apt-get install -y --no-install-recommends --no-remove \ + crossbuild-essential-${arch} \ + libelf-dev:${arch} \ + libavcodec-dev:${arch} \ + libegl1-mesa-dev:${arch} \ + libgl1-mesa-dev:${arch} \ + libglvnd-dev:${arch} \ + libhidapi-dev:${arch} \ + libudev-dev:${arch} \ + libusb-1.0-0-dev:${arch} \ + libv4l-dev:${arch} \ + libvulkan-dev:${arch} \ + libwayland-dev:${arch} \ + libx11-dev:${arch} \ + libxcb-randr0-dev:${arch} \ + libxrandr-dev:${arch} \ + libxxf86vm-dev:${arch} + + if [ "$arch" != "i386" ]; then + mkdir /var/cache/apt/archives/${arch} + apt-get install -y --no-remove \ + libstdc++6:${arch} + fi +done + + +# for 64bit windows cross-builds +# apt-get install -y --no-remove \ +# libz-mingw-w64-dev \ +# mingw-w64 \ +# wine \ +# wine32 \ +# wine64 + + +apt-get autoremove -y --purge +apt-get clean + +# Generate cross build files for Meson +for arch in $CROSS_ARCHITECTURES; do + cross_file="/cross_file-$arch.txt" + /usr/share/meson/debcrossgen --arch "$arch" -o "$cross_file" + if [ "$arch" = "i386" ]; then + # Work around a bug in debcrossgen that should be fixed in the next release + sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" "$cross_file" + fi + + # Rely on qemu-user being configured in binfmt_misc on the host + sed -i -e '/\[properties\]/a\' -e "needs_exe_wrapper = False" "$cross_file" +done