]>
Commit | Line | Data |
---|---|---|
7629744a | 1 | #!/bin/sh |
9ee03516 | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
3b6fd3c1 | 3 | set -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 |
8 | if [ -n "${BUILD_DIR:=}" ]; then |
9 | realpath "$BUILD_DIR" | |
cc5549ca | 10 | exit 0 |
ded65775 ZJS |
11 | fi |
12 | ||
13 | root="$(dirname "$(realpath "$0")")" | |
14 | ||
15 | found= | |
16 | for 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 |
26 | done |
27 | ||
28 | if [ -z "$found" ]; then | |
3b6fd3c1 | 29 | echo "Specify build directory with \$BUILD_DIR" >&2 |
cc5549ca | 30 | exit 1 |
ded65775 ZJS |
31 | fi |
32 | ||
3b6fd3c1 | 33 | realpath "$found" |