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