From f68e8b3a706524c6049ecbe556a1bf3e03d6ab0a Mon Sep 17 00:00:00 2001 From: Isaac Garzon Date: Wed, 10 Aug 2022 14:09:36 +0300 Subject: [PATCH] build: allow setting the path to GNU Parallel in the Makefile (#118) This allows using more up to date versions from the user's system as well as possibly patched versions with additional features. --- Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 73fe35d44..c2d1c93c3 100644 --- a/Makefile +++ b/Makefile @@ -925,6 +925,11 @@ prioritize_long_running_tests = \ # See "man parallel" for its "-j ..." option. J ?= 100% +PARALLEL ?= build_tools/gnu_parallel +PARALLEL_OK := $(shell command -v "$(PARALLEL)" 2>&1 >/dev/null && \ + ("$(PARALLEL)" --gnu --version 2>/dev/null | grep -q 'Ole Tange') && \ + echo 1) + # Use this regexp to select the subset of tests whose names match. tests-regexp = . EXCLUDE_TESTS_REGEX ?= "^$$" @@ -953,7 +958,7 @@ check_0: gen_parallel_tests | $(prioritize_long_running_tests) \ | grep -E '$(tests-regexp)' \ | grep -E -v '$(EXCLUDE_TESTS_REGEX)' \ - | build_tools/gnu_parallel -j$(J) --plain --joblog=LOG --eta --gnu \ + | "$(PARALLEL)" -j$(J) --plain --joblog=LOG --eta --gnu \ --tmpdir=$(TEST_TMPDIR) '{} $(parallel_redir)' ; \ parallel_retcode=$$? ; \ awk '{ if ($$7 != 0 || $$8 != 0) { if ($$7 == "Exitval") { h = $$0; } else { if (!f) print h; print; f = 1 } } } END { if(f) exit 1; }' < LOG ; \ @@ -975,7 +980,7 @@ valgrind_check_0: gen_parallel_tests | $(prioritize_long_running_tests) \ | grep -E '$(tests-regexp)' \ | grep -E -v '$(valgrind-exclude-regexp)' \ - | build_tools/gnu_parallel -j$(J) --plain --joblog=LOG --eta --gnu \ + | "$(PARALLEL)" -j$(J) --plain --joblog=LOG --eta --gnu \ --tmpdir=$(TEST_TMPDIR) \ '(if [[ "{}" == "./"* ]] ; then $(DRIVER) {}; else {}; fi) \ $(parallel_redir)' \ @@ -998,9 +1003,7 @@ dump-log: # If J != 1 and GNU parallel is installed, run the tests in parallel, # via the check_0 rule above. Otherwise, run them sequentially. check: all - $(AM_V_GEN)if test "$(J)" != 1 \ - && (build_tools/gnu_parallel --gnu --help 2>/dev/null) | \ - grep -q 'GNU Parallel'; \ + $(AM_V_GEN)if [ "$(J)" != "1" ] && [ "$(PARALLEL_OK)" = "1" ]; \ then \ $(MAKE) T="$$t" check_0; \ else \ @@ -1102,9 +1105,7 @@ valgrind_test_some: ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check_some valgrind_check: $(TESTS) - $(AM_V_GEN)if test "$(J)" != 1 \ - && (build_tools/gnu_parallel --gnu --help 2>/dev/null) | \ - grep -q 'GNU Parallel'; \ + $(AM_V_GEN)if [ "$(J)" != "1" ] && [ "$(PARALLEL_OK)" = "1" ]; \ then \ $(MAKE) \ DRIVER="$(VALGRIND_VER) $(VALGRIND_OPTS)" valgrind_check_0; \