]> git.ipfire.org Git - thirdparty/systemd.git/blame - tools/find-build-dir.sh
busctl: modernize code a bit
[thirdparty/systemd.git] / tools / find-build-dir.sh
CommitLineData
ded65775
ZJS
1#!/bin/sh -e
2
3# Try to guess the build directory:
4# we look for subdirectories of the parent directory that look like ninja build dirs.
5
6if [ -n "$BUILD_DIR" ]; then
7 echo "$(realpath "$BUILD_DIR")"
8 exit 0
9fi
10
11root="$(dirname "$(realpath "$0")")"
12
13found=
14for i in "$root"/../*/build.ninja; do
15 c="$(dirname $i)"
16 [ -d "$c" ] || continue
17 [ "$(basename "$c")" != mkosi.builddir ] || continue
18
19 if [ -n "$found" ]; then
20 echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
21 exit 2
22 fi
23 found="$c"
24done
25
26if [ -z "$found" ]; then
27 echo 'Specify build directory with $BUILD_DIR' >&2
28 exit 1
29fi
30
31echo "$(realpath $found)"