1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-25 23:21:33 +03:00
systemd-stable/tools/find-build-dir.sh
Zbigniew Jędrzejewski-Szmek 9ee03516df tree-wide: add spdx header on all scripts and helpers
Even though many of those scripts are very simple, it is easier to include
the header than to try to say whether each of those files is trivial enough
not to require one.
2021-01-28 09:55:35 +01:00

34 lines
736 B
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
# 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
echo "$(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
echo "$(realpath $found)"