Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: tools/gn/toolchain.h

Issue 440333002: Support more configurability in GN toolchains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unsigned check Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/tool.cc ('k') | tools/gn/toolchain.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/toolchain.h
diff --git a/tools/gn/toolchain.h b/tools/gn/toolchain.h
index 4ab54124f9fe31368181336235dc51858fcbeac7..8264577e0b0c367cd6ff90d268f3d20cce3b4a93 100644
--- a/tools/gn/toolchain.h
+++ b/tools/gn/toolchain.h
@@ -6,10 +6,15 @@
#define TOOLS_GN_TOOLCHAIN_H_
#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "tools/gn/item.h"
#include "tools/gn/label_ptr.h"
#include "tools/gn/scope.h"
+#include "tools/gn/source_file_type.h"
+#include "tools/gn/substitution_type.h"
+#include "tools/gn/tool.h"
#include "tools/gn/value.h"
// Holds information on a specific toolchain. This data is filled in when we
@@ -21,7 +26,7 @@
// before generating the build for that target.
//
// Note on threadsafety: The label of the toolchain never changes so can
-// safetly be accessed from any thread at any time (we do this when asking for
+// safely be accessed from any thread at any time (we do this when asking for
// the toolchain name). But the values in the toolchain do, so these can't
// be accessed until this Item is resolved.
class Toolchain : public Item {
@@ -55,22 +60,6 @@ class Toolchain : public Item {
static const char* kToolStamp;
static const char* kToolCopy;
- struct Tool {
- Tool();
- ~Tool();
-
- std::string command;
- std::string depfile;
- std::string depsformat;
- std::string description;
- std::string lib_dir_prefix;
- std::string lib_prefix;
- std::string pool;
- std::string restat;
- std::string rspfile;
- std::string rspfile_content;
- };
-
Toolchain(const Settings* settings, const Label& label);
virtual ~Toolchain();
@@ -82,8 +71,15 @@ class Toolchain : public Item {
static ToolType ToolNameToType(const base::StringPiece& str);
static std::string ToolTypeToName(ToolType type);
- const Tool& GetTool(ToolType type) const;
- void SetTool(ToolType type, const Tool& t);
+ // Returns null if the tool hasn't been defined.
+ const Tool* GetTool(ToolType type) const;
+
+ // Set a tool. When all tools are configured, you should call
+ // ToolchainSetupComplete().
+ void SetTool(ToolType type, scoped_ptr<Tool> t);
+
+ // Does final setup on the toolchain once all tools are known.
+ void ToolchainSetupComplete();
// Targets that must be resolved before compiling any targets.
const LabelTargetVector& deps() const { return deps_; }
@@ -96,8 +92,29 @@ class Toolchain : public Item {
Scope::KeyValueMap& args() { return args_; }
const Scope::KeyValueMap& args() const { return args_; }
+ // Returns the tool for compiling the given source file type.
+ static ToolType GetToolTypeForSourceType(SourceFileType type);
+ const Tool* GetToolForSourceType(SourceFileType type);
+
+ // Returns the tool that produces the final output for the given target type.
+ // This isn't necessarily the tool you would expect. For copy target, this
+ // will return the stamp tool ionstead since the final output of a copy
+ // target is to stamp the set of copies done so there is one output.
+ static ToolType GetToolTypeForTargetFinalOutput(const Target* target);
+ const Tool* GetToolForTargetFinalOutput(const Target* target) const;
+
+ const SubstitutionBits& substitution_bits() const {
+ DCHECK(setup_complete_);
+ return substitution_bits_;
+ }
+
private:
- Tool tools_[TYPE_NUMTYPES];
+ scoped_ptr<Tool> tools_[TYPE_NUMTYPES];
+
+ bool setup_complete_;
+
+ // Substitutions used by the tools in this toolchain.
+ SubstitutionBits substitution_bits_;
LabelTargetVector deps_;
Scope::KeyValueMap args_;
« no previous file with comments | « tools/gn/tool.cc ('k') | tools/gn/toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698