]>
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 | |
cc5549ca ZJS |
8 | echo "$(realpath "$BUILD_DIR")" |
9 | exit 0 | |
ded65775 ZJS |
10 | fi |
11 | ||
12 | root="$(dirname "$(realpath "$0")")" | |
13 | ||
14 | found= | |
15 | for i in "$root"/../*/build.ninja; do | |
cc5549ca ZJS |
16 | c="$(dirname $i)" |
17 | [ -d "$c" ] || continue | |
18 | [ "$(basename "$c")" != mkosi.builddir ] || continue | |
ded65775 | 19 | |
cc5549ca ZJS |
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" | |
ded65775 ZJS |
25 | done |
26 | ||
27 | if [ -z "$found" ]; then | |
cc5549ca ZJS |
28 | echo 'Specify build directory with $BUILD_DIR' >&2 |
29 | exit 1 | |
ded65775 ZJS |
30 | fi |
31 | ||
32 | echo "$(realpath $found)" |