forked from openkylin/platform_build
Convert -j to a reasonable parallelism for kati
When running makeparallel in non-ninja mode, which is used when running kati with USE_GOMA=true, convert -j to a reasonable parallelism value the same way ninja does. Bug: 34392351 Test: make -C build/make/tools/makeparallel makeparallel_test Change-Id: I9aee4dd2a3b0f2b1c2c10087be83f7b2b06f4368
This commit is contained in:
parent
ce0bae2f47
commit
ba55c623cb
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue