From 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:49:52 +0200 Subject: Adding upstream version 255.4. Signed-off-by: Daniel Baumann --- tools/find-build-dir.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 tools/find-build-dir.sh (limited to 'tools/find-build-dir.sh') diff --git a/tools/find-build-dir.sh b/tools/find-build-dir.sh new file mode 100755 index 0000000..79a79fc --- /dev/null +++ b/tools/find-build-dir.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eu + +# Try to guess the build directory: +# we look for subdirectories of the parent directory that look like ninja build dirs. + +if [ -n "${BUILD_DIR:=}" ]; then + realpath "$BUILD_DIR" + exit 0 +fi + +root="$(dirname "$(realpath "$0")")" + +found= +for i in "$root"/../*/build.ninja; do + c="$(dirname "$i")" + [ -d "$c" ] || continue + [ "$(basename "$c")" != mkosi.builddir ] || continue + + if [ -n "$found" ]; then + echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2 + exit 2 + fi + found="$c" +done + +if [ -z "$found" ]; then + echo "Specify build directory with \$BUILD_DIR" >&2 + exit 1 +fi + +realpath "$found" -- cgit v1.2.3