exclude PluginsFieldTrialTest.NoPrefLeftBehind from valgrind bot
[chromium-blink-merge.git] / tools / gn / tool.h
blobce945464068ec4aaa4cebf18d88c11ed21652aef
1 // Copyright 2014 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_TOOL_H_
6 #define TOOLS_GN_TOOL_H_
8 #include <string>
10 #include "base/logging.h"
11 #include "base/macros.h"
12 #include "tools/gn/substitution_list.h"
13 #include "tools/gn/substitution_pattern.h"
15 class Tool {
16 public:
17 enum DepsFormat {
18 DEPS_GCC = 0,
19 DEPS_MSVC = 1
22 enum PrecompiledHeaderType {
23 PCH_NONE = 0,
24 PCH_MSVC = 1
27 Tool();
28 ~Tool();
30 // Getters/setters ----------------------------------------------------------
32 // After the tool has had its attributes set, the caller must call
33 // SetComplete(), at which point no other changes can be made.
35 // Command to run.
36 const SubstitutionPattern& command() const {
37 return command_;
39 void set_command(const SubstitutionPattern& cmd) {
40 DCHECK(!complete_);
41 command_ = cmd;
44 // Should include a leading "." if nonempty.
45 const std::string& default_output_extension() const {
46 return default_output_extension_;
48 void set_default_output_extension(const std::string& ext) {
49 DCHECK(!complete_);
50 DCHECK(ext.empty() || ext[0] == '.');
51 default_output_extension_ = ext;
54 // Dependency file (if supported).
55 const SubstitutionPattern& depfile() const {
56 return depfile_;
58 void set_depfile(const SubstitutionPattern& df) {
59 DCHECK(!complete_);
60 depfile_ = df;
63 DepsFormat depsformat() const {
64 return depsformat_;
66 void set_depsformat(DepsFormat f) {
67 DCHECK(!complete_);
68 depsformat_ = f;
71 PrecompiledHeaderType precompiled_header_type() const {
72 return precompiled_header_type_;
74 void set_precompiled_header_type(PrecompiledHeaderType pch_type) {
75 precompiled_header_type_ = pch_type;
78 const SubstitutionPattern& description() const {
79 return description_;
81 void set_description(const SubstitutionPattern& desc) {
82 DCHECK(!complete_);
83 description_ = desc;
86 const std::string& lib_switch() const {
87 return lib_switch_;
89 void set_lib_switch(const std::string& s) {
90 DCHECK(!complete_);
91 lib_switch_ = s;
94 const std::string& lib_dir_switch() const {
95 return lib_dir_switch_;
97 void set_lib_dir_switch(const std::string& s) {
98 DCHECK(!complete_);
99 lib_dir_switch_ = s;
102 const SubstitutionList& outputs() const {
103 return outputs_;
105 void set_outputs(const SubstitutionList& out) {
106 DCHECK(!complete_);
107 outputs_ = out;
110 // Should match files in the outputs() if nonempty.
111 const SubstitutionPattern& link_output() const {
112 return link_output_;
114 void set_link_output(const SubstitutionPattern& link_out) {
115 DCHECK(!complete_);
116 link_output_ = link_out;
119 const SubstitutionPattern& depend_output() const {
120 return depend_output_;
122 void set_depend_output(const SubstitutionPattern& dep_out) {
123 DCHECK(!complete_);
124 depend_output_ = dep_out;
127 const std::string& output_prefix() const {
128 return output_prefix_;
130 void set_output_prefix(const std::string& s) {
131 DCHECK(!complete_);
132 output_prefix_ = s;
135 bool restat() const {
136 return restat_;
138 void set_restat(bool r) {
139 DCHECK(!complete_);
140 restat_ = r;
143 const SubstitutionPattern& rspfile() const {
144 return rspfile_;
146 void set_rspfile(const SubstitutionPattern& rsp) {
147 DCHECK(!complete_);
148 rspfile_ = rsp;
151 const SubstitutionPattern& rspfile_content() const {
152 return rspfile_content_;
154 void set_rspfile_content(const SubstitutionPattern& content) {
155 DCHECK(!complete_);
156 rspfile_content_ = content;
159 // Other functions ----------------------------------------------------------
161 // Called when the toolchain is saving this tool, after everything is filled
162 // in.
163 void SetComplete();
165 // Returns true if this tool has separate outputs for dependency tracking
166 // and linking.
167 bool has_separate_solink_files() const {
168 return !link_output_.empty() || !depend_output_.empty();
171 // Substitutions required by this tool.
172 const SubstitutionBits& substitution_bits() const {
173 DCHECK(complete_);
174 return substitution_bits_;
177 private:
178 SubstitutionPattern command_;
179 std::string default_output_extension_;
180 SubstitutionPattern depfile_;
181 DepsFormat depsformat_;
182 PrecompiledHeaderType precompiled_header_type_;
183 SubstitutionPattern description_;
184 std::string lib_switch_;
185 std::string lib_dir_switch_;
186 SubstitutionList outputs_;
187 SubstitutionPattern link_output_;
188 SubstitutionPattern depend_output_;
189 std::string output_prefix_;
190 bool restat_;
191 SubstitutionPattern rspfile_;
192 SubstitutionPattern rspfile_content_;
194 bool complete_;
196 SubstitutionBits substitution_bits_;
198 DISALLOW_COPY_AND_ASSIGN(Tool);
201 #endif // TOOLS_GN_TOOL_H_