1#!/usr/bin/env bash 2# shellcheck disable=SC1003 # works for us now... 3# shellcheck disable=SC2086 # we want word splitting 4 5section_switch meson-cross-file "meson: cross file generate" 6 7set -e 8set -o xtrace 9 10CROSS_FILE=/cross_file-"$CROSS".txt 11 12export PATH=$PATH:$PWD/.gitlab-ci/build 13 14touch native.file 15printf > native.file "%s\n" \ 16 "[binaries]" \ 17 "c = 'compiler-wrapper-${CC:-gcc}.sh'" \ 18 "cpp = 'compiler-wrapper-${CXX:-g++}.sh'" 19 20# We need to control the version of llvm-config we're using, so we'll 21# tweak the cross file or generate a native file to do so. 22if test -n "$LLVM_VERSION"; then 23 LLVM_CONFIG="llvm-config-${LLVM_VERSION}" 24 echo "llvm-config = '$(which "$LLVM_CONFIG")'" >> native.file 25 if [ -n "$CROSS" ]; then 26 sed -i -e '/\[binaries\]/a\' -e "llvm-config = '$(which "$LLVM_CONFIG")'" $CROSS_FILE 27 fi 28 $LLVM_CONFIG --version 29fi 30 31# cross-xfail-$CROSS, if it exists, contains a list of tests that are expected 32# to fail for the $CROSS configuration, one per line. you can then mark those 33# tests in their meson.build with: 34# 35# test(..., 36# should_fail: meson.get_external_property('xfail', '').contains(t), 37# ) 38# 39# where t is the name of the test, and the '' is the string to search when 40# not cross-compiling (which is empty, because for amd64 everything is 41# expected to pass). 42if [ -n "$CROSS" ]; then 43 CROSS_XFAIL=.gitlab-ci/cross-xfail-"$CROSS" 44 if [ -s "$CROSS_XFAIL" ]; then 45 sed -i \ 46 -e '/\[properties\]/a\' \ 47 -e "xfail = '$(tr '\n' , < $CROSS_XFAIL)'" \ 48 "$CROSS_FILE" 49 fi 50fi 51 52if [ -n "$HOST_BUILD_OPTIONS" ]; then 53 section_switch meson-host-configure "meson: host configure" 54 55 # Stash the PKG_CONFIG_LIBDIR so that we can use the base x86_64 image 56 # libraries. 57 tmp_pkg_config_libdir=$PKG_CONFIG_LIBDIR 58 unset PKG_CONFIG_LIBDIR 59 60 # Compile a host version for the few tools we need for a cross build (for 61 # now just intel-clc) 62 rm -rf _host_build 63 meson setup _host_build \ 64 --native-file=native.file \ 65 -D prefix=/usr \ 66 -D libdir=lib \ 67 ${HOST_BUILD_OPTIONS} 68 69 pushd _host_build 70 71 section_switch meson-host-build "meson: host build" 72 73 meson configure 74 ninja 75 ninja install 76 popd 77 78 # Restore PKG_CONFIG_LIBDIR 79 if [ -n "$tmp_pkg_config_libdir" ]; then 80 export PKG_CONFIG_LIBDIR=$tmp_pkg_config_libdir 81 fi 82fi 83 84# Only use GNU time if available, not any shell built-in command 85case $CI_JOB_NAME in 86 # ASAN leak detection is incompatible with strace 87 *-asan*) 88 if test -f /usr/bin/time; then 89 MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/time.sh 90 fi 91 Xvfb :0 -screen 0 1024x768x16 & 92 export DISPLAY=:0.0 93 ;; 94 *) 95 if test -f /usr/bin/time -a -f /usr/bin/strace; then 96 MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/time-strace.sh 97 fi 98 ;; 99esac 100 101section_switch meson-configure "meson: configure" 102 103rm -rf _build 104meson setup _build \ 105 --native-file=native.file \ 106 --wrap-mode=nofallback \ 107 --force-fallback-for perfetto,syn \ 108 ${CROSS+--cross "$CROSS_FILE"} \ 109 -D prefix=$PWD/install \ 110 -D libdir=lib \ 111 -D buildtype=${BUILDTYPE:?} \ 112 -D build-tests=true \ 113 -D c_args="$(echo -n $C_ARGS)" \ 114 -D c_link_args="$(echo -n $C_LINK_ARGS)" \ 115 -D cpp_args="$(echo -n $CPP_ARGS)" \ 116 -D cpp_link_args="$(echo -n $CPP_LINK_ARGS)" \ 117 -D enable-glcpp-tests=false \ 118 -D libunwind=${UNWIND} \ 119 ${DRI_LOADERS} \ 120 ${GALLIUM_ST} \ 121 -D gallium-opencl=disabled \ 122 -D gallium-drivers=${GALLIUM_DRIVERS:-[]} \ 123 -D vulkan-drivers=${VULKAN_DRIVERS:-[]} \ 124 -D video-codecs=all \ 125 -D werror=true \ 126 ${EXTRA_OPTION} 127cd _build 128meson configure 129 130uncollapsed_section_switch meson-build "meson: build" 131 132if command -V mold &> /dev/null ; then 133 mold --run ninja 134else 135 ninja 136fi 137 138 139uncollapsed_section_switch meson-test "meson: test" 140LC_ALL=C.UTF-8 meson test --num-processes "${FDO_CI_CONCURRENT:-4}" --print-errorlogs ${MESON_TEST_ARGS} 141section_switch meson-install "meson: install" 142if command -V mold &> /dev/null ; then 143 mold --run ninja install 144else 145 ninja install 146fi 147cd .. 148section_end meson-install 149