From d973affed21e490a9eef1ae76dfcc3bd0358cb0e Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 11 Jan 2017 18:34:57 -0800 Subject: Compile bit on darwin, use -j when invoking make Test: ran the host tool and checked the output Change-Id: Idd561139348779982b8c01977fcc18fdfbd0134d --- tools/bit/make.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/bit/make.cpp') diff --git a/tools/bit/make.cpp b/tools/bit/make.cpp index 60b5687bb313..a8002417b916 100644 --- a/tools/bit/make.cpp +++ b/tools/bit/make.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,14 @@ using namespace std; map g_buildVars; +static unsigned int +get_thread_count() +{ + unsigned int threads = std::thread::hardware_concurrency(); + // Guess if the value cannot be computed + return threads == 0 ? 4 : static_cast(threads * 1.3f); +} + string get_build_var(const string& buildTop, const string& name, bool quiet) { @@ -44,6 +53,7 @@ get_build_var(const string& buildTop, const string& name, bool quiet) if (it == g_buildVars.end()) { Command cmd("make"); cmd.AddArg("--no-print-directory"); + cmd.AddArg(string("-j") + std::to_string(get_thread_count())); cmd.AddArg("-C"); cmd.AddArg(buildTop); cmd.AddArg("-f"); @@ -199,6 +209,7 @@ int build_goals(const vector& goals) { Command cmd("make"); + cmd.AddArg(string("-j") + std::to_string(get_thread_count())); cmd.AddArg("-f"); cmd.AddArg("build/core/main.mk"); for (size_t i=0; i