]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # SPDX-License-Identifier: LGPL-2.1-or-later | |
3 | set -eu | |
4 | ||
5 | # Try to guess the build directory: | |
6 | # we look for subdirectories of the parent directory that look like ninja build dirs. | |
7 | ||
8 | if [ -n "${BUILD_DIR:=}" ]; then | |
9 | realpath "$BUILD_DIR" | |
10 | exit 0 | |
11 | fi | |
12 | ||
13 | root="$(dirname "$(realpath "$0")")" | |
14 | ||
15 | found= | |
16 | for i in "$root"/../*/build.ninja; do | |
17 | c="$(dirname "$i")" | |
18 | [ -d "$c" ] || continue | |
19 | [ "$(basename "$c")" != mkosi.builddir ] || continue | |
20 | ||
21 | if [ -n "$found" ]; then | |
22 | echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2 | |
23 | exit 2 | |
24 | fi | |
25 | found="$c" | |
26 | done | |
27 | ||
28 | if [ -z "$found" ]; then | |
29 | echo "Specify build directory with \$BUILD_DIR" >&2 | |
30 | exit 1 | |
31 | fi | |
32 | ||
33 | realpath "$found" |