]> git.ipfire.org Git - thirdparty/systemd.git/blame - tools/find-build-dir.sh
test: suppress logs generated by journal tests
[thirdparty/systemd.git] / tools / find-build-dir.sh
CommitLineData
7629744a 1#!/bin/sh
9ee03516 2# SPDX-License-Identifier: LGPL-2.1-or-later
3b6fd3c1 3set -eu
ded65775
ZJS
4
5# Try to guess the build directory:
6# we look for subdirectories of the parent directory that look like ninja build dirs.
7
3b6fd3c1
FS
8if [ -n "${BUILD_DIR:=}" ]; then
9 realpath "$BUILD_DIR"
cc5549ca 10 exit 0
ded65775
ZJS
11fi
12
13root="$(dirname "$(realpath "$0")")"
14
15found=
16for i in "$root"/../*/build.ninja; do
3b6fd3c1 17 c="$(dirname "$i")"
cc5549ca
ZJS
18 [ -d "$c" ] || continue
19 [ "$(basename "$c")" != mkosi.builddir ] || continue
ded65775 20
cc5549ca 21 if [ -n "$found" ]; then
3b6fd3c1 22 echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2
cc5549ca
ZJS
23 exit 2
24 fi
25 found="$c"
ded65775
ZJS
26done
27
28if [ -z "$found" ]; then
3b6fd3c1 29 echo "Specify build directory with \$BUILD_DIR" >&2
cc5549ca 30 exit 1
ded65775
ZJS
31fi
32
3b6fd3c1 33realpath "$found"