1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Merge pull request #7554 from keszybz/autodetect-build

Autodetect build directory ignoring mkosi artefacts
This commit is contained in:
Lennart Poettering 2017-12-07 09:07:40 +01:00 committed by GitHub
commit ea781d0dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 24 deletions

View File

@ -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

View 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 --$@

View 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 --$@

View 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 --$@

View 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 --$@

View 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 --$@

View File

@ -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--"

31
tools/find-build-dir.sh Executable file
View File

@ -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)"