summaryrefslogtreecommitdiff
path: root/tools/bit
diff options
context:
space:
mode:
author Dan Willemsen <dwillemsen@google.com> 2017-10-17 17:46:41 -0700
committer Dan Willemsen <dwillemsen@google.com> 2017-10-17 17:53:36 -0700
commita40118d7b6f70f44eaf4a47a32808088fd039f71 (patch)
tree7d72e2f4756a4182d4bf68643ced4800e3bcaeea /tools/bit
parent154535317eaa84a50d70cb3af8697ab4e2c89a25 (diff)
Use soong_ui directly, instead of make
This will use ckati instead of make for dumping variables, for consistent makefile parsing. It may also sandbox executions, etc. Also skip the legacy make wrapper to build, and use soong_ui instead. The command line arguments are equivalent, but -j is no longer necessary, we'll default to a sane value. Test: bit -b framework Change-Id: Idc2c9d1abe84b6b783b8702925de5493d47a4509
Diffstat (limited to 'tools/bit')
-rw-r--r--tools/bit/command.cpp2
-rw-r--r--tools/bit/main.cpp7
-rw-r--r--tools/bit/make.cpp29
-rw-r--r--tools/bit/make.h2
4 files changed, 12 insertions, 28 deletions
diff --git a/tools/bit/command.cpp b/tools/bit/command.cpp
index 1ff7c221b26e..f95ea117a96e 100644
--- a/tools/bit/command.cpp
+++ b/tools/bit/command.cpp
@@ -189,7 +189,7 @@ run_command(const Command& command)
int
exec_with_path_search(const char* prog, char const* const* argv, char const* const* envp)
{
- if (prog[0] == '/') {
+ if (strchr(prog, '/') != NULL) {
return execve(prog, (char*const*)argv, (char*const*)envp);
} else {
char* pathEnv = strdup(getenv("PATH"));
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp
index ad23971152b2..e81898f82418 100644
--- a/tools/bit/main.cpp
+++ b/tools/bit/main.cpp
@@ -588,12 +588,13 @@ run_phases(vector<Target*> targets, const Options& options)
const string buildProduct = get_required_env("TARGET_PRODUCT", false);
const string buildVariant = get_required_env("TARGET_BUILD_VARIANT", false);
const string buildType = get_required_env("TARGET_BUILD_TYPE", false);
- const string buildDevice = get_build_var(buildTop, "TARGET_DEVICE", false);
- const string buildId = get_build_var(buildTop, "BUILD_ID", false);
- const string buildOut = get_out_dir();
chdir_or_exit(buildTop.c_str());
+ const string buildDevice = get_build_var("TARGET_DEVICE", false);
+ const string buildId = get_build_var("BUILD_ID", false);
+ const string buildOut = get_out_dir();
+
// Get the modules for the targets
map<string,Module> modules;
read_modules(buildOut, buildDevice, &modules, false);
diff --git a/tools/bit/make.cpp b/tools/bit/make.cpp
index a8002417b916..ef3ccc541589 100644
--- a/tools/bit/make.cpp
+++ b/tools/bit/make.cpp
@@ -36,31 +36,16 @@ using namespace std;
map<string,string> 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<unsigned int>(threads * 1.3f);
-}
-
string
-get_build_var(const string& buildTop, const string& name, bool quiet)
+get_build_var(const string& name, bool quiet)
{
int err;
map<string,string>::iterator it = g_buildVars.find(name);
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");
- cmd.AddArg("build/core/config.mk");
- cmd.AddArg(string("dumpvar-") + name);
- cmd.AddEnv("CALLED_FROM_SETUP", "true");
- cmd.AddEnv("BUILD_SYSTEM", "build/core");
+ Command cmd("build/soong/soong_ui.bash");
+ cmd.AddArg("--dumpvar-mode");
+ cmd.AddArg(name);
string output = trim(get_command_output(cmd, &err, quiet));
if (err == 0) {
@@ -208,10 +193,8 @@ read_modules(const string& buildOut, const string& device, map<string,Module>* r
int
build_goals(const vector<string>& goals)
{
- Command cmd("make");
- cmd.AddArg(string("-j") + std::to_string(get_thread_count()));
- cmd.AddArg("-f");
- cmd.AddArg("build/core/main.mk");
+ Command cmd("build/soong/soong_ui.bash");
+ cmd.AddArg("--make-mode");
for (size_t i=0; i<goals.size(); i++) {
cmd.AddArg(goals[i]);
}
diff --git a/tools/bit/make.h b/tools/bit/make.h
index bb83c6e14226..1c9504d62d46 100644
--- a/tools/bit/make.h
+++ b/tools/bit/make.h
@@ -31,7 +31,7 @@ struct Module
vector<string> installed;
};
-string get_build_var(const string& buildTop, const string& name, bool quiet);
+string get_build_var(const string& name, bool quiet);
/**
* Poke around in the out directory and try to find a device name that matches