]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
scripts: Add support for out-of-tree builds to test script
authorTobias Brunner <tobias@strongswan.org>
Fri, 28 Feb 2025 10:28:47 +0000 (11:28 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 28 Feb 2025 13:21:49 +0000 (14:21 +0100)
Can be useful when using the script locally.

scripts/test.sh

index 4f6024c50d11d7a85063227cb8dedfc77d7bd377..ddbaed144240c84fefbbef2aa68337d0bb2dedc0 100755 (executable)
@@ -204,6 +204,7 @@ prepare_system_openssl()
        fi
 }
 
+: ${SRC_DIR=$PWD}
 : ${BUILD_DIR=$PWD}
 : ${DEPS_BUILD_DIR=$BUILD_DIR/..}
 : ${DEPS_PREFIX=/usr/local}
@@ -456,7 +457,11 @@ fuzzing)
        ;;
 nm)
        DEPS="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
-       cd src/frontends/gnome
+       ORIG_SRC_DIR="$SRC_DIR"
+       SRC_DIR="$ORIG_SRC_DIR/src/frontends/gnome"
+       if [ "$ORIG_SRC_DIR" = "$BUILD_DIR" ]; then
+               BUILD_DIR="$SRC_DIR"
+       fi
        # don't run ./configure with ./autogen.sh
        export NOCONFIGURE=1
        ;;
@@ -524,10 +529,15 @@ case "$TEST" in
                ;;
 esac
 
-echo "$ ./autogen.sh"
-./autogen.sh || exit $?
+cd $SRC_DIR
+if [ ! -f ./configure ]; then
+       echo "$ ./autogen.sh"
+       ./autogen.sh || exit $?
+fi
+
+cd $BUILD_DIR
 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
-CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG || exit $?
+CC="$CC" CFLAGS="$CFLAGS" $SRC_DIR/configure $CONFIG || exit $?
 
 case "$TEST" in
 apidoc)
@@ -573,7 +583,7 @@ sonarcloud)
        ;;
 android)
        rm -r strongswan-*
-       cd src/frontends/android
+       cd $SRC_DIR/src/frontends/android
        echo "$ ./gradlew build"
        NDK_CCACHE=ccache ./gradlew build --info || exit $?
        ;;
@@ -581,6 +591,7 @@ android)
        ;;
 esac
 
+cd $SRC_DIR
 # ensure there are no unignored build artifacts (or other changes) in the Git repo
 unclean="$(git status --porcelain)"
 if test -n "$unclean"; then