Merge "Convert -j to a reasonable parallelism for kati" am: bb5c13d359

am: 57de869060

Change-Id: I7c115293cc3dc86b7354b60ddf23b1bf5181ed6e
This commit is contained in:
Colin Cross 2017-01-19 00:14:26 +00:00 committed by android-build-merger
commit 8b8c5d98f1
2 changed files with 20 additions and 7 deletions

View file

@ -65,8 +65,9 @@ MAKEPARALLEL_NINJA_TEST := MAKEFLAGS= MAKELEVEL= MAKEPARALLEL="$(MAKEPARALLEL) -
makeparallel_test: $(MAKEPARALLEL)
@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234
@EXPECTED="-j123" $(MAKEPARALLEL_TEST) -j123
@EXPECTED="-j1" $(MAKEPARALLEL_TEST) -j1
@EXPECTED="-j1" $(MAKEPARALLEL_TEST)
@EXPECTED="" $(MAKEPARALLEL_TEST) -j1
@EXPECTED="-j$$(($$(nproc) + 2))" $(MAKEPARALLEL_TEST) -j
@EXPECTED="" $(MAKEPARALLEL_TEST)
@EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) -j1234
@EXPECTED="-j123" $(MAKEPARALLEL_NINJA_TEST) -j123
@ -87,8 +88,6 @@ makeparallel_test: $(MAKEPARALLEL)
@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -j1234 -k
@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -kt -j1234
@EXPECTED="-j1" $(MAKEPARALLEL_TEST) A=-j1234
@EXPECTED="-j1" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234
@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234 -j1234
@EXPECTED="" $(MAKEPARALLEL_TEST) A=-j1234
@EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234

View file

@ -317,13 +317,27 @@ int main(int argc, char* argv[]) {
}
}
std::string jarg = "-j" + std::to_string(tokens + 1);
std::string jarg;
if (parallel) {
if (tokens == 0) {
if (ninja) {
// ninja is parallel by default
jarg = "";
} else {
// make -j with no argument, guess a reasonable parallelism like ninja does
jarg = "-j" + std::to_string(sysconf(_SC_NPROCESSORS_ONLN) + 2);
}
} else {
jarg = "-j" + std::to_string(tokens + 1);
}
}
if (ninja) {
if (!parallel) {
// ninja is parallel by default, pass -j1 to disable parallelism if make wasn't parallel
args.push_back(strdup("-j1"));
} else if (tokens > 0) {
} else {
args.push_back(strdup(jarg.c_str()));
}
if (keep_going) {