CI: add prefix 'ci_' to env var 'builddir'

This customization simplifies their use, e.g. when outputting the command
line used. Because of FreeBSD, 'awk' is used instead of 'gawk' to make
sure that the tool is available.
This commit is contained in:
Ralf Habacker 2023-08-04 11:56:12 +02:00
parent 8cd3ebabf6
commit 5ddb3b67bf
3 changed files with 23 additions and 22 deletions

View file

@ -40,7 +40,7 @@ stages:
- build
variables:
builddir: "build"
ci_builddir: "build"
ci_in_docker: "yes"
ci_local_packages: "yes"
ci_parallel: "2"
@ -439,12 +439,11 @@ freebsd image:
# Variables are not forwarded to the vm automatically so we forward the
# ones starting with ci_ to ci-build.sh manually. This works because
# $(env | grep "ci_.*=") is evaluated on the current host not in the VM.
# We also have to forward builddir since this is required by ci-build.sh.
- /app/vmctl exec "cd $CI_PROJECT_NAME && env make=gmake builddir=$builddir $(echo $(env | grep "ci_.*=")) bash -x ./tools/ci-build.sh $CI_BUILD_ARGS"
- /app/vmctl exec "cd $CI_PROJECT_NAME && env make=gmake $(echo $(env | grep "ci_.*=")) bash -x ./tools/ci-build.sh $CI_BUILD_ARGS"
# Copy build artifacts from the VM for archiving/JUnit XML display
- mkdir -p "$builddir"
- rsync -av "vm:$CI_PROJECT_NAME/$builddir/meson-logs" "$builddir/" || true
- scp -v "vm:$CI_PROJECT_NAME/$builddir/config.h" . || true
- mkdir -p "$ci_builddir"
- rsync -av "vm:$CI_PROJECT_NAME/$ci_builddir/meson-logs" "$ci_builddir/" || true
- scp -v "vm:$CI_PROJECT_NAME/$ci_builddir/config.h" . || true
- scp -v "vm:$ci_cmake_junit_output" "$ci_cmake_junit_output" || true
# Finally, shut down the VM.
- /app/vmctl stop

View file

@ -129,7 +129,8 @@ init_wine() {
# One of static, shared; used for windows cross builds
: "${ci_runtime:=static}"
echo "ci_buildsys=$ci_buildsys ci_distro=$ci_distro ci_host=$ci_host ci_local_packages=$ci_local_packages ci_parallel=$ci_parallel ci_suite=$ci_suite ci_test=$ci_test ci_test_fatal=$ci_test_fatal ci_variant=$ci_variant ci_runtime=$ci_runtime $0"
# print used command line
set +x; env | awk 'BEGIN { s = "" } $1 ~ /^ci_/ { s=s " " $0} END { print s " " SCRIPT }' SCRIPT=$0; set -x
# choose distribution
if [ "$ci_distro" = "auto" ]; then
@ -155,11 +156,11 @@ maybe_fail_tests () {
NOCONFIGURE=1 ./autogen.sh
# clean up directories from possible previous builds
if [ -z "$builddir" ]; then
echo "ERROR: builddir environment variable must be set!"
if [ -z "$ci_builddir" ]; then
echo "ERROR: ci_builddir environment variable must be set!"
exit 1
fi
rm -rf "$builddir"
rm -rf "$ci_builddir"
rm -rf ci-build-dist
rm -rf src-from-dist
@ -180,8 +181,8 @@ case "$ci_buildsys" in
;;
esac
mkdir -p "$builddir"
builddir="$(realpath "$builddir")"
mkdir -p "$ci_builddir"
ci_builddir="$(realpath "$ci_builddir")"
#
# cross compile setup
@ -212,7 +213,7 @@ case "$ci_host" in
;;
esac
cd "$builddir"
cd "$ci_builddir"
case "$ci_host" in
(*-w64-mingw32)
@ -226,13 +227,13 @@ case "$ci_host" in
libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)")
fi
init_wine \
"${builddir}/bin" \
"${builddir}/subprojects/expat-2.4.8" \
"${builddir}/subprojects/glib-2.72.2/gio" \
"${builddir}/subprojects/glib-2.72.2/glib" \
"${builddir}/subprojects/glib-2.72.2/gmodule" \
"${builddir}/subprojects/glib-2.72.2/gobject" \
"${builddir}/subprojects/glib-2.72.2/gthread" \
"${ci_builddir}/bin" \
"${ci_builddir}/subprojects/expat-2.4.8" \
"${ci_builddir}/subprojects/glib-2.72.2/gio" \
"${ci_builddir}/subprojects/glib-2.72.2/glib" \
"${ci_builddir}/subprojects/glib-2.72.2/gmodule" \
"${ci_builddir}/subprojects/glib-2.72.2/gobject" \
"${ci_builddir}/subprojects/glib-2.72.2/gthread" \
"${dep_prefix}/bin" \
${libgcc_path:+"$libgcc_path"}
fi
@ -437,7 +438,7 @@ case "$ci_buildsys" in
;;
esac
$cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_WERROR=ON -S "$srcdir" -B "$builddir" "$@"
$cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_WERROR=ON -S "$srcdir" -B "$ci_builddir" "$@"
${make}
# The test coverage for OOM-safety is too verbose to be useful on

View file

@ -54,7 +54,8 @@ NULL=
# One of debug, reduced, legacy, production
: "${ci_variant:=production}"
echo "ci_distro=$ci_distro ci_in_docker=$ci_in_docker ci_host=$ci_host ci_local_packages=$ci_local_packages ci_suite=$ci_suite ci_variant=$ci_variant $0"
# print used command line
set +x; env | awk 'BEGIN { s = "" } $1 ~ /^ci_/ { s=s " " $0} END { print s " " SCRIPT }' SCRIPT=$0; set -x
if [ $(id -u) = 0 ]; then
sudo=