gitlab CI: rename FREEBSD_PKGS to FREEBSD_PACKAGES for consistency
[platform/upstream/libinput.git] / .gitlab-ci / meson-build.sh
1 #!/bin/bash
2
3 if [[ -f .meson_environment ]]; then
4         . .meson_environment
5 fi
6
7 if [[ -z "$MESON_BUILDDIR" ]]; then
8         echo "\$MESON_BUILDDIR undefined."
9         exit 1
10 fi
11
12 # emulate a few gitlab variables to make it easier to
13 # run and debug locally.
14 if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then
15         echo "Missing \$CI_JOB_ID or \$CI_JOB_NAME".
16         CI_JOB_ID=$(date +%s)
17         CI_JOB_NAME='libinput-job-local'
18         echo "Simulating gitlab environment: "
19         echo " CI_JOB_ID=$CI_JOB_ID"
20         echo " CI_JOB_NAME=$CI_JOB_NAME"
21 fi
22
23
24 echo "*************************************************"
25 echo "builddir: $MESON_BUILDDIR"
26 echo "meson args: $MESON_ARGS"
27 echo "ninja args: $NINJA_ARGS"
28 echo "meson test args: $MESON_TEST_ARGS"
29 echo "*************************************************"
30
31 set -e
32
33 rm -rf "$MESON_BUILDDIR"
34 meson "$MESON_BUILDDIR" $MESON_ARGS
35 meson configure "$MESON_BUILDDIR"
36 ninja -C "$MESON_BUILDDIR" $NINJA_ARGS
37
38 if [[ -z "$MESON_TEST_ARGS" ]]; then
39     exit 0
40 fi
41
42 # we still want to generate the reports, even if meson test fails
43 set +e
44 meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS --print-errorlogs
45 exit_code=$?
46 set -e
47
48 # We need the glob for the testlog so that it picks up those suffixed by a
49 # suite (e.g. testlog-valgrind.json)
50 ./.gitlab-ci/meson-junit-report.py \
51         --project-name=libinput \
52         --job-id="$CI_JOB_ID" \
53         --output="$MESON_BUILDDIR/junit-$CI_JOB_NAME-report.xml" \
54         "$MESON_BUILDDIR"/meson-logs/testlog*.json; \
55
56 exit $exit_code