Add utility functions needed for rect-based event targeting
[chromium-blink-merge.git] / tools / gn / toolchain.h
blob106f2f4bc73943ed8214b44b34cae40330229da5
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_TOOLCHAIN_H_
6 #define TOOLS_GN_TOOLCHAIN_H_
8 #include "base/compiler_specific.h"
9 #include "base/strings/string_piece.h"
10 #include "tools/gn/item.h"
11 #include "tools/gn/scope.h"
12 #include "tools/gn/value.h"
14 // Holds information on a specific toolchain. This data is filled in when we
15 // encounter a toolchain definition.
17 // This class is an Item so it can participate in dependency management. In
18 // particular, when a target uses a toolchain, it should have a dependency on
19 // that toolchain's object so that we can be sure we loaded the toolchain
20 // before generating the build for that target.
22 // Note on threadsafety: The label of the toolchain never changes so can
23 // safetly be accessed from any thread at any time (we do this when asking for
24 // the toolchain name). But the values in the toolchain do, so these can't
25 // be accessed until this Item is resolved.
26 class Toolchain : public Item {
27 public:
28 enum ToolType {
29 TYPE_NONE = 0,
30 TYPE_CC,
31 TYPE_CXX,
32 TYPE_OBJC,
33 TYPE_OBJCXX,
34 TYPE_RC,
35 TYPE_ASM,
36 TYPE_ALINK,
37 TYPE_SOLINK,
38 TYPE_LINK,
39 TYPE_STAMP,
40 TYPE_COPY,
42 TYPE_NUMTYPES // Must be last.
45 static const char* kToolCc;
46 static const char* kToolCxx;
47 static const char* kToolObjC;
48 static const char* kToolObjCxx;
49 static const char* kToolRc;
50 static const char* kToolAsm;
51 static const char* kToolAlink;
52 static const char* kToolSolink;
53 static const char* kToolLink;
54 static const char* kToolStamp;
55 static const char* kToolCopy;
57 struct Tool {
58 Tool();
59 ~Tool();
61 std::string command;
62 std::string depfile;
63 std::string deps;
64 std::string description;
65 std::string lib_dir_prefix;
66 std::string lib_prefix;
67 std::string pool;
68 std::string restat;
69 std::string rspfile;
70 std::string rspfile_content;
73 Toolchain(const Label& label);
74 virtual ~Toolchain();
76 // Item overrides.
77 virtual Toolchain* AsToolchain() OVERRIDE;
78 virtual const Toolchain* AsToolchain() const OVERRIDE;
80 // Returns TYPE_NONE on failure.
81 static ToolType ToolNameToType(const base::StringPiece& str);
82 static std::string ToolTypeToName(ToolType type);
84 const Tool& GetTool(ToolType type) const;
85 void SetTool(ToolType type, const Tool& t);
87 const std::string& environment() const { return environment_; }
88 void set_environment(const std::string& env) { environment_ = env; }
90 bool is_default() const { return is_default_; }
91 void set_is_default(bool id) { is_default_ = id; }
93 // Specifies build argument overrides that will be set on the base scope. It
94 // will be as if these arguments were passed in on the command line. This
95 // allows a toolchain to override the OS type of the default toolchain or
96 // pass in other settings.
97 Scope::KeyValueMap& args() { return args_; }
98 const Scope::KeyValueMap& args() const { return args_; }
100 private:
101 Tool tools_[TYPE_NUMTYPES];
103 bool is_default_;
104 Scope::KeyValueMap args_;
106 std::string environment_;
109 #endif // TOOLS_GN_TOOLCHAIN_H_