diff options
| author | 2015-10-20 15:41:05 -0700 | |
|---|---|---|
| committer | 2015-10-20 17:05:49 -0700 | |
| commit | 466ea35202f5e858f6f9191cb43d99d113698f5d (patch) | |
| tree | b67c8609dc3ddb9da6b0b758df16a8f023a0c5e7 | |
| parent | 88dc18a31952edcf2dfea737e3989f2112e5155f (diff) | |
makeparallel: prepend flags to ninja command line
Ninja stops parsing top level options after -t is used to select a
tool. Put any inserted command line options at the beginning of the
command.
Change-Id: I2ba903143366aaded63e21d749476248617c8962
| -rw-r--r-- | tools/makeparallel/Makefile | 2 | ||||
| -rw-r--r-- | tools/makeparallel/Makefile.test | 2 | ||||
| -rw-r--r-- | tools/makeparallel/makeparallel.cpp | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/tools/makeparallel/Makefile b/tools/makeparallel/Makefile index 4e79708991..4e12b10f2a 100644 --- a/tools/makeparallel/Makefile +++ b/tools/makeparallel/Makefile @@ -90,3 +90,5 @@ makeparallel_test: $(MAKEPARALLEL) @EXPECTED="-j1" $(MAKEPARALLEL_TEST) A=-j1234 @EXPECTED="-j1" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234 @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234 -j1234 + + @EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234 diff --git a/tools/makeparallel/Makefile.test b/tools/makeparallel/Makefile.test index 91aacf7d7d..cf53684c0d 100644 --- a/tools/makeparallel/Makefile.test +++ b/tools/makeparallel/Makefile.test @@ -3,7 +3,7 @@ MAKEPARALLEL ?= ./makeparallel .PHONY: test test: @+echo MAKEFLAGS=$${MAKEFLAGS}; \ - result=$$($(MAKEPARALLEL) echo); \ + result=$$($(MAKEPARALLEL) echo $(ARGS)); \ echo result: $${result}; \ if [ "$${result}" = "$(EXPECTED)" ]; then \ echo SUCCESS && echo; \ diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp index 7dd0ceb2ad..576fe8df8f 100644 --- a/tools/makeparallel/makeparallel.cpp +++ b/tools/makeparallel/makeparallel.cpp @@ -298,8 +298,12 @@ int main(int argc, char* argv[]) { argc--; } + if (argc < 2) { + error(EXIT_FAILURE, 0, "expected command to run"); + } + const char* path = argv[1]; - std::vector<char*> args(&argv[1], &argv[argc]); + std::vector<char*> args({argv[1]}); std::vector<std::string> makeflags = ReadMakeflags(); if (ParseMakeflags(makeflags, &in_fd, &out_fd, ¶llel, &keep_going)) { @@ -328,6 +332,8 @@ int main(int argc, char* argv[]) { args.push_back(strdup(jarg.c_str())); } + args.insert(args.end(), &argv[2], &argv[argc]); + args.push_back(nullptr); pid_t pid = fork(); |