summaryrefslogtreecommitdiffstats
path: root/tools/gn/ninja_toolchain_writer.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-19 21:11:05 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-19 21:11:05 +0000
commit60749e1c3bc06c226a427f82363acc71ec976d03 (patch)
tree63c337a1665ef511d0ee7f624079badd8205c6c6 /tools/gn/ninja_toolchain_writer.cc
parent3624f729459ccda7125fe003e10ef53845e64286 (diff)
downloadchromium_src-60749e1c3bc06c226a427f82363acc71ec976d03.zip
chromium_src-60749e1c3bc06c226a427f82363acc71ec976d03.tar.gz
chromium_src-60749e1c3bc06c226a427f82363acc71ec976d03.tar.bz2
This hooks up build flags from the command-line and the toolchain (for re-invoking the build).
Using this, I was able to make the NaCl build of base compile (if the correct NaCl toolchain is extracted in advance to the right location). This is the first time I actually ran a cross-compile, and Ninja complained about duplicate rule definitions, so I now prefix rules in the non-default toolchain with the toolchain name. There were also some files that went in the wrong directory. I moved the toolchain definitions from the other platforms into a new directory tree in build/toolchains to be more clear. To make the toolchain args get passed to the build configuration, I had to add another state to the toolchain_manager's state machine, since we need to see those flags before starting that part of the build. This is described in more detail at the top of the .cc file. Since I was moving stuff around, I wanted to find references to the thing I was moving, so wrote a new command to find places that reference a given target "gn refs". I added new help for patterns since I used these for the new "refs" command. I removed the requirement that declare_args only be called once in a given scope. It now can be used anywhere to facilitate module-specific arguments. Because build arguments can now be declared anywhere, I added a "gn args" command-line command that will find and print all of the command line arguments passed into the build. It also prints the comment above the argument as a way to document it. The code to extract the comment is a but unfortunate. I think if/when we write an autoformatter, we'll need to incorporate comments into the parse tree more and this can be simplified greatly. Fixes up build.ninja dependencies if you remove a buildfile. Because I specified all input buildfiles in build.ninja, it would fail if you removed any of them. I now write out the build deps (for regenerating the build) in a .d file which will tolerate missing files. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/22998003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/ninja_toolchain_writer.cc')
-rw-r--r--tools/gn/ninja_toolchain_writer.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/gn/ninja_toolchain_writer.cc b/tools/gn/ninja_toolchain_writer.cc
index 8dd2175..95cb408 100644
--- a/tools/gn/ninja_toolchain_writer.cc
+++ b/tools/gn/ninja_toolchain_writer.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "base/strings/stringize_macros.h"
#include "tools/gn/build_settings.h"
+#include "tools/gn/item_node.h"
#include "tools/gn/settings.h"
#include "tools/gn/target.h"
#include "tools/gn/toolchain.h"
@@ -58,13 +59,17 @@ void NinjaToolchainWriter::WriteRules() {
const Toolchain* tc = settings_->toolchain();
std::string indent(" ");
+ NinjaHelper helper(settings_->build_settings());
+ std::string rule_prefix = helper.GetRulePrefix(tc);
+
for (int i = Toolchain::TYPE_NONE + 1; i < Toolchain::TYPE_NUMTYPES; i++) {
Toolchain::ToolType tool_type = static_cast<Toolchain::ToolType>(i);
const Toolchain::Tool& tool = tc->GetTool(tool_type);
if (tool.empty())
continue;
- out_ << "rule " << Toolchain::ToolTypeToName(tool_type) << std::endl;
+ out_ << "rule " << rule_prefix << Toolchain::ToolTypeToName(tool_type)
+ << std::endl;
#define WRITE_ARG(name) \
if (!tool.name.empty()) \
@@ -83,7 +88,10 @@ void NinjaToolchainWriter::WriteRules() {
}
void NinjaToolchainWriter::WriteSubninjas() {
+ // Write subninja commands for each generated target.
for (size_t i = 0; i < targets_.size(); i++) {
+ if (!targets_[i]->item_node()->should_generate())
+ continue;
out_ << "subninja ";
path_output_.WriteFile(out_, helper_.GetNinjaFileForTarget(targets_[i]));
out_ << std::endl;