diff options
| author | 2017-01-18 14:38:20 -0800 | |
|---|---|---|
| committer | 2017-01-18 14:50:50 -0800 | |
| commit | ba55c623cbc8e4a1ea9b191b223e0d9c4de4dfea (patch) | |
| tree | 88d31b4deb8a9cc412b17618ce4c0aec1bab8776 /tools/makeparallel/makeparallel.cpp | |
| parent | ce0bae2f470373131f2d5f9d79838c2340f0ba0e (diff) | |
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
Diffstat (limited to 'tools/makeparallel/makeparallel.cpp')
| -rw-r--r-- | tools/makeparallel/makeparallel.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp index 4ae8f61d9d..b90668186e 100644 --- a/tools/makeparallel/makeparallel.cpp +++ b/tools/makeparallel/makeparallel.cpp @@ -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) { |