makeparallel: improve support for wrapping ninja
Allow makeparallel to pass better -j and -k arguments to ninja if the
first argument to makeparallel is --ninja. Uses getopt to parse
MAKEFLAGS to get values for --jobserver-fds, -k, and -j, and uses the
result to not pass any -j argument to ninja for make -j with no number,
and pass -k0 to ninja for make -k.
Also improve the test makefile to provide many more tests.
Bug: 24199503
Change-Id: Id6481430f77e9e952213be58a98fe78c46ee5d6a
diff --git a/tools/makeparallel/Makefile.test b/tools/makeparallel/Makefile.test
index bd682f7..91aacf7 100644
--- a/tools/makeparallel/Makefile.test
+++ b/tools/makeparallel/Makefile.test
@@ -2,4 +2,11 @@
.PHONY: test
test:
- +if [ "$$($(MAKEPARALLEL) echo)" = "-j1234" ]; then echo SUCCESS; else echo FAILED; fi
+ @+echo MAKEFLAGS=$${MAKEFLAGS}; \
+ result=$$($(MAKEPARALLEL) echo); \
+ echo result: $${result}; \
+ if [ "$${result}" = "$(EXPECTED)" ]; then \
+ echo SUCCESS && echo; \
+ else \
+ echo FAILED expected $(EXPECTED) && false; \
+ fi