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
This commit is contained in:
Colin Cross
2015-10-20 15:41:05 -07:00
parent 88dc18a319
commit 466ea35202
3 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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; \

View File

@@ -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, &parallel, &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();