st/mesa: deduplicate st_common_program code in st_program_string_notify
[mesa.git] / .gitlab-ci / meson-build.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 # We need to control the version of llvm-config we're using, so we'll
7 # generate a native file to do so. This requires meson >=0.49
8 if test -n "$LLVM_VERSION"; then
9 LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
10 echo -e "[binaries]\nllvm-config = '`which $LLVM_CONFIG`'" > native.file
11 $LLVM_CONFIG --version
12 else
13 rm -f native.file
14 touch native.file
15 fi
16
17 CROSS_FILE=/cross_file-"$CROSS".txt
18
19 # cross-xfail-$CROSS, if it exists, contains a list of tests that are expected
20 # to fail for the $CROSS configuration, one per line. you can then mark those
21 # tests in their meson.build with:
22 #
23 # test(...,
24 # should_fail: meson.get_cross_property('xfail', '').contains(t),
25 # )
26 #
27 # where t is the name of the test, and the '' is the string to search when
28 # not cross-compiling (which is empty, because for amd64 everything is
29 # expected to pass).
30 if [ -n "$CROSS" ]; then
31 CROSS_XFAIL=.gitlab-ci/cross-xfail-"$CROSS"
32 if [ -s "$CROSS_XFAIL" ]; then
33 sed -i \
34 -e '/\[properties\]/a\' \
35 -e "xfail = '$(tr '\n' , < $CROSS_XFAIL)'" \
36 "$CROSS_FILE"
37 fi
38 fi
39
40 rm -rf _build
41 meson _build --native-file=native.file \
42 --wrap-mode=nofallback \
43 ${CROSS+--cross "$CROSS_FILE"} \
44 -D prefix=`pwd`/install \
45 -D libdir=lib \
46 -D buildtype=${BUILDTYPE:-debug} \
47 -D build-tests=true \
48 -D libunwind=${UNWIND} \
49 ${DRI_LOADERS} \
50 -D dri-drivers=${DRI_DRIVERS:-[]} \
51 ${GALLIUM_ST} \
52 -D gallium-drivers=${GALLIUM_DRIVERS:-[]} \
53 -D vulkan-drivers=${VULKAN_DRIVERS:-[]} \
54 -D I-love-half-baked-turnips=true \
55 ${EXTRA_OPTION}
56 cd _build
57 meson configure
58 ninja -j4
59 LC_ALL=C.UTF-8 ninja test
60 ninja install
61 cd ..
62
63 if test -n "$MESON_SHADERDB"; then
64 ./.gitlab-ci/run-shader-db.sh;
65 fi
66
67 # Delete 2MB of includes from artifacts.
68 rm -rf install/include
69
70 # Strip the drivers in the artifacts to cut 80% of the artifacts size.
71 if [ -n "$CROSS" ]; then
72 STRIP=`sed -n -E "s/strip\s*=\s*'(.*)'/\1/p" "$CROSS_FILE"`
73 if [ -z "$STRIP" ]; then
74 echo "Failed to find strip command in cross file"
75 exit 1
76 fi
77 else
78 STRIP="strip"
79 fi
80 find install -name \*.so -exec $STRIP {} \;
81
82 # Test runs don't pull down the git tree, so put the dEQP helper
83 # script and associated bits there.
84 mkdir -p artifacts/
85 cp -Rp .gitlab-ci/deqp* artifacts/
86 # cp -Rp src/freedreno/ci/expected* artifacts/