Change next_proto member type.
[chromium-blink-merge.git] / tools / gn / tool.h
blob10a2ba15909091c1da3b212ba94bc6334834ad69
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/basictypes.h"
11 #include "base/logging.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 Tool();
23 ~Tool();
25 // Getters/setters ----------------------------------------------------------
27 // After the tool has had its attributes set, the caller must call
28 // SetComplete(), at which point no other changes can be made.
30 // Command to run.
31 const SubstitutionPattern& command() const {
32 return command_;
34 void set_command(const SubstitutionPattern& cmd) {
35 DCHECK(!complete_);
36 command_ = cmd;
39 // Should include a leading "." if nonempty.
40 const std::string& default_output_extension() const {
41 return default_output_extension_;
43 void set_default_output_extension(const std::string& ext) {
44 DCHECK(!complete_);
45 DCHECK(ext.empty() || ext[0] == '.');
46 default_output_extension_ = ext;
49 // Dependency file (if supported).
50 const SubstitutionPattern& depfile() const {
51 return depfile_;
53 void set_depfile(const SubstitutionPattern& df) {
54 DCHECK(!complete_);
55 depfile_ = df;
58 DepsFormat depsformat() const {
59 return depsformat_;
61 void set_depsformat(DepsFormat f) {
62 DCHECK(!complete_);
63 depsformat_ = f;
66 const SubstitutionPattern& description() const {
67 return description_;
69 void set_description(const SubstitutionPattern& desc) {
70 DCHECK(!complete_);
71 description_ = desc;
74 const std::string& lib_switch() const {
75 return lib_switch_;
77 void set_lib_switch(const std::string& s) {
78 DCHECK(!complete_);
79 lib_switch_ = s;
82 const std::string& lib_dir_switch() const {
83 return lib_dir_switch_;
85 void set_lib_dir_switch(const std::string& s) {
86 DCHECK(!complete_);
87 lib_dir_switch_ = s;
90 const SubstitutionList& outputs() const {
91 return outputs_;
93 void set_outputs(const SubstitutionList& out) {
94 DCHECK(!complete_);
95 outputs_ = out;
98 // Should match files in the outputs() if nonempty.
99 const SubstitutionPattern& link_output() const {
100 return link_output_;
102 void set_link_output(const SubstitutionPattern& link_out) {
103 DCHECK(!complete_);
104 link_output_ = link_out;
107 const SubstitutionPattern& depend_output() const {
108 return depend_output_;
110 void set_depend_output(const SubstitutionPattern& dep_out) {
111 DCHECK(!complete_);
112 depend_output_ = dep_out;
115 const std::string& output_prefix() const {
116 return output_prefix_;
118 void set_output_prefix(const std::string& s) {
119 DCHECK(!complete_);
120 output_prefix_ = s;
123 bool restat() const {
124 return restat_;
126 void set_restat(bool r) {
127 DCHECK(!complete_);
128 restat_ = r;
131 const SubstitutionPattern& rspfile() const {
132 return rspfile_;
134 void set_rspfile(const SubstitutionPattern& rsp) {
135 DCHECK(!complete_);
136 rspfile_ = rsp;
139 const SubstitutionPattern& rspfile_content() const {
140 return rspfile_content_;
142 void set_rspfile_content(const SubstitutionPattern& content) {
143 DCHECK(!complete_);
144 rspfile_content_ = content;
147 // Other functions ----------------------------------------------------------
149 // Called when the toolchain is saving this tool, after everything is filled
150 // in.
151 void SetComplete();
153 // Returns true if this tool has separate outputs for dependency tracking
154 // and linking.
155 bool has_separate_solink_files() const {
156 return !link_output_.empty() || !depend_output_.empty();
159 // Substitutions required by this tool.
160 const SubstitutionBits& substitution_bits() const {
161 DCHECK(complete_);
162 return substitution_bits_;
165 public:
166 SubstitutionPattern command_;
167 std::string default_output_extension_;
168 SubstitutionPattern depfile_;
169 DepsFormat depsformat_;
170 SubstitutionPattern description_;
171 std::string lib_switch_;
172 std::string lib_dir_switch_;
173 SubstitutionList outputs_;
174 SubstitutionPattern link_output_;
175 SubstitutionPattern depend_output_;
176 std::string output_prefix_;
177 bool restat_;
178 SubstitutionPattern rspfile_;
179 SubstitutionPattern rspfile_content_;
181 bool complete_;
183 SubstitutionBits substitution_bits_;
185 DISALLOW_COPY_AND_ASSIGN(Tool);
188 #endif // TOOLS_GN_TOOL_H_