Zbigniew Jędrzejewski-Szmek | ded6577 | 2017-12-06 15:09:54 +0100 | [diff] [blame^] | 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 | |
| 6 | if [ -n "$BUILD_DIR" ]; then |
| 7 | echo "$(realpath "$BUILD_DIR")" |
| 8 | exit 0 |
| 9 | fi |
| 10 | |
| 11 | root="$(dirname "$(realpath "$0")")" |
| 12 | |
| 13 | found= |
| 14 | for 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" |
| 24 | done |
| 25 | |
| 26 | if [ -z "$found" ]; then |
| 27 | echo 'Specify build directory with $BUILD_DIR' >&2 |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | echo "$(realpath $found)" |