]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: split out setup-modules.sh
authorEmil Velikov <emil.l.velikov@gmail.com>
Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 3 Sep 2024 01:13:16 +0000 (20:13 -0500)
So that we can reuse it from the upcoming meson build.

v2:
 - shellcheck fixes, add TODO, move to scripts/

v3:
 - set MAKEFLAGS="-j$(nproc)" if empty

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Makefile.am
scripts/setup-modules.sh [new file with mode: 0755]

index 92f9dff7acba1d365b6fc8d9e2067e0ecdd1a184..3975074e2f7901f2417d24a589fa0ee63223bd20 100644 (file)
@@ -163,20 +163,17 @@ endif
 # TESTSUITE
 # ------------------------------------------------------------------------------
 
+EXTRA_DIST += scripts/setup-modules.sh
 EXTRA_DIST += scripts/setup-rootfs.sh
 
 MODULE_PLAYGROUND = testsuite/module-playground
+BUILD_MODULES = $(AM_V_GEN) $(top_srcdir)/scripts/setup-modules.sh $(top_srcdir) $(top_builddir) $(MODULE_PLAYGROUND) $(module_directory)
 ROOTFS = testsuite/rootfs
 ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
 CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/scripts/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir) $(module_directory)
 
 build-module-playground:
-       $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
-               $(RM) -rf testsuite/module-playground && \
-               mkdir -p testsuite/ && \
-               cp -r $(top_srcdir)/$(MODULE_PLAYGROUND) $(top_builddir)/$(MODULE_PLAYGROUND); \
-               fi
-       MODULE_DIRECTORY=$(module_directory) $(MAKE) -C $(MODULE_PLAYGROUND)
+       $(BUILD_MODULES)
 
 
 rootfs: build-module-playground
diff --git a/scripts/setup-modules.sh b/scripts/setup-modules.sh
new file mode 100755 (executable)
index 0000000..4996b64
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -euo pipefail
+
+SRCDIR=$1
+BUILDDIR=$2
+MODULE_PLAYGROUND=$3
+# shellcheck disable=SC2034 # used by the Makefile
+export MODULE_DIRECTORY=$4
+
+# TODO: meson allows only out of tree builds
+if test "$SRCDIR" != "$BUILDDIR"; then
+    rm -rf "$MODULE_PLAYGROUND"
+    mkdir -p "$(dirname "$MODULE_PLAYGROUND")"
+    cp -r "$SRCDIR/$MODULE_PLAYGROUND" "$MODULE_PLAYGROUND"
+fi
+
+export MAKEFLAGS=${MAKEFLAGS-"-j$(nproc)"}
+"${MAKE-make}" -C "$PWD/$MODULE_PLAYGROUND" modules