Created a <webview> find API.
[chromium-blink-merge.git] / tools / gn / toolchain.h
blob3b37a7ac506036990c0ffd0416c110927fdccb37
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 Settings* settings, 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 // This extra stuff is specified by the build and will be added to the top
88 // of a generated GYP file (right after the opening "{").
89 std::string gyp_header() const { return gyp_header_; }
90 void set_gyp_header(const std::string& gh) { gyp_header_ = gh; }
92 // Specifies build argument overrides that will be set on the base scope. It
93 // will be as if these arguments were passed in on the command line. This
94 // allows a toolchain to override the OS type of the default toolchain or
95 // pass in other settings.
96 Scope::KeyValueMap& args() { return args_; }
97 const Scope::KeyValueMap& args() const { return args_; }
99 private:
100 Tool tools_[TYPE_NUMTYPES];
102 Scope::KeyValueMap args_;
104 std::string gyp_header_;
107 #endif // TOOLS_GN_TOOLCHAIN_H_