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