]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #7554 from keszybz/autodetect-build
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Dec 2017 08:07:40 +0000 (09:07 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2017 08:07:40 +0000 (09:07 +0100)
Autodetect build directory ignoring mkosi artefacts

test/Makefile.guess [deleted file]
test/TEST-01-BASIC/Makefile
test/TEST-13-NSPAWN-SMOKE/Makefile
test/TEST-17-UDEV-WANTS/Makefile
test/TEST-18-FAILUREACTION/Makefile
test/TEST-19-DELEGATE/Makefile
test/run-integration-tests.sh
tools/find-build-dir.sh [new file with mode: 0755]

diff --git a/test/Makefile.guess b/test/Makefile.guess
deleted file mode 100644 (file)
index 1916d09..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# Try to guess the build directory:
-# we look for subdirectories of ../.. that look like ninja build dirs.
-
-ifeq ($(BUILD_DIR),)
-        dirs = $(dir $(wildcard ../../*/.ninja_log))
-        ifeq ($(dirs),)
-                $(error Cannot guess build dir, set BUILD_DIR)
-        endif
-        ifneq ($(firstword $(dirs)),$(dirs))
-                $(warning Candidates: $(dirs))
-                $(error Too many build dirs to pick from, set BUILD_DIR)
-        endif
-        BUILD_DIR=$(dirs)
-endif
index b895de8bcb58de9581d0308b5f4422a307041010..3a212a07a917789bde5ab3051595cccb98efb2d4 100644 (file)
@@ -1,4 +1,4 @@
-include ../Makefile.guess
+BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
 
 all setup clean run:
        @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index 41cca23c7fb7c8c1e643e79bfc36b7b8769967c4..ddcbbc302fa4250b7834fe003bb259440cbf0ee8 100644 (file)
@@ -1,4 +1,4 @@
-include ../Makefile.guess
+BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
 
 all setup run:
        @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index b895de8bcb58de9581d0308b5f4422a307041010..3a212a07a917789bde5ab3051595cccb98efb2d4 100644 (file)
@@ -1,4 +1,4 @@
-include ../Makefile.guess
+BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
 
 all setup clean run:
        @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index b895de8bcb58de9581d0308b5f4422a307041010..3a212a07a917789bde5ab3051595cccb98efb2d4 100644 (file)
@@ -1,4 +1,4 @@
-include ../Makefile.guess
+BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
 
 all setup clean run:
        @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index b895de8bcb58de9581d0308b5f4422a307041010..3a212a07a917789bde5ab3051595cccb98efb2d4 100644 (file)
@@ -1,4 +1,4 @@
-include ../Makefile.guess
+BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
 
 all setup clean run:
        @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index 3ece46c7717599fe3b3987fd0e839d3b732242e6..7d70be3fea6179f229110f0846d03c6e6f93cfe8 100755 (executable)
@@ -1,21 +1,24 @@
 #!/bin/bash -e
 
-if ! test -d ../build ; then
-        echo "Expected build directory in ../build, but couldn't find it." >&2
-        exit 1
+BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
+if [ $# -gt 0 ]; then
+        args="$@"
+else
+        args="clean setup run"
 fi
 
-ninja -C ../build
+ninja -C "$BUILD_DIR"
 
 declare -A results
 
 RESULT=0
 FAILURES=0
 
+cd "$(dirname "$0")"
 for TEST in TEST-??-* ; do
         echo -e "\n--x-- Starting $TEST --x--"
         set +e
-        make -C "$TEST" BUILD_DIR=$(pwd)/../build clean setup run
+        make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args
         RESULT=$?
         set -e
         echo "--x-- Result of $TEST: $RESULT --x--"
diff --git a/tools/find-build-dir.sh b/tools/find-build-dir.sh
new file mode 100755 (executable)
index 0000000..33b40f9
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh -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)"