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

Side by Side Diff: tools/gn/tool.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/test_with_scope.cc ('k') | tools/gn/tool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef TOOLS_GN_TOOL_H_
6 #define TOOLS_GN_TOOL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "tools/gn/substitution_list.h"
13 #include "tools/gn/substitution_pattern.h"
14
15 class Tool {
16 public:
17 enum DepsFormat {
18 DEPS_GCC = 0,
19 DEPS_MSVC = 1
20 };
21
22 Tool();
23 ~Tool();
24
25 // Getters/setters ----------------------------------------------------------
26 //
27 // After the tool has had its attributes set, the caller must call
28 // SetComplete(), at which point no other changes can be made.
29
30 // Command to run.
31 const SubstitutionPattern& command() const {
32 return command_;
33 }
34 void set_command(const SubstitutionPattern& cmd) {
35 DCHECK(!complete_);
36 command_ = cmd;
37 }
38
39 // Should include a leading "." if nonempty.
40 const std::string& default_output_extension() const {
41 return default_output_extension_;
42 }
43 void set_default_output_extension(const std::string& ext) {
44 DCHECK(!complete_);
45 DCHECK(ext.empty() || ext[0] == '.');
46 default_output_extension_ = ext;
47 }
48
49 // Dependency file (if supported).
50 const SubstitutionPattern& depfile() const {
51 return depfile_;
52 }
53 void set_depfile(const SubstitutionPattern& df) {
54 DCHECK(!complete_);
55 depfile_ = df;
56 }
57
58 DepsFormat depsformat() const {
59 return depsformat_;
60 }
61 void set_depsformat(DepsFormat f) {
62 DCHECK(!complete_);
63 depsformat_ = f;
64 }
65
66 const SubstitutionPattern& description() const {
67 return description_;
68 }
69 void set_description(const SubstitutionPattern& desc) {
70 DCHECK(!complete_);
71 description_ = desc;
72 }
73
74 const std::string& lib_switch() const {
75 return lib_switch_;
76 }
77 void set_lib_switch(const std::string& s) {
78 DCHECK(!complete_);
79 lib_switch_ = s;
80 }
81
82 const std::string& lib_dir_switch() const {
83 return lib_dir_switch_;
84 }
85 void set_lib_dir_switch(const std::string& s) {
86 DCHECK(!complete_);
87 lib_dir_switch_ = s;
88 }
89
90 const SubstitutionList& outputs() const {
91 return outputs_;
92 }
93 void set_outputs(const SubstitutionList& out) {
94 DCHECK(!complete_);
95 outputs_ = out;
96 }
97
98 // Should match files in the outputs() if nonempty.
99 const SubstitutionPattern& link_output() const {
100 return link_output_;
101 }
102 void set_link_output(const SubstitutionPattern& link_out) {
103 DCHECK(!complete_);
104 link_output_ = link_out;
105 }
106
107 const SubstitutionPattern& depend_output() const {
108 return depend_output_;
109 }
110 void set_depend_output(const SubstitutionPattern& dep_out) {
111 DCHECK(!complete_);
112 depend_output_ = dep_out;
113 }
114
115 const std::string& output_prefix() const {
116 return output_prefix_;
117 }
118 void set_output_prefix(const std::string& s) {
119 DCHECK(!complete_);
120 output_prefix_ = s;
121 }
122
123 const std::string& pool() const {
124 return pool_;
125 }
126 void set_pool(const std::string& s) {
127 DCHECK(!complete_);
128 pool_ = s;
129 }
130
131 bool restat() const {
132 return restat_;
133 }
134 void set_restat(bool r) {
135 DCHECK(!complete_);
136 restat_ = r;
137 }
138
139 const SubstitutionPattern& rspfile() const {
140 return rspfile_;
141 }
142 void set_rspfile(const SubstitutionPattern& rsp) {
143 DCHECK(!complete_);
144 rspfile_ = rsp;
145 }
146
147 const SubstitutionPattern& rspfile_content() const {
148 return rspfile_content_;
149 }
150 void set_rspfile_content(const SubstitutionPattern& content) {
151 DCHECK(!complete_);
152 rspfile_content_ = content;
153 }
154
155 // Other functions ----------------------------------------------------------
156
157 // Called when the toolchain is saving this tool, after everything is filled
158 // in.
159 void SetComplete();
160
161 // Returns true if this tool has separate outputs for dependency tracking
162 // and linking.
163 bool has_separate_solink_files() const {
164 return !link_output_.empty() || !depend_output_.empty();
165 }
166
167 // Substitutions required by this tool.
168 const SubstitutionBits& substitution_bits() const {
169 DCHECK(complete_);
170 return substitution_bits_;
171 }
172
173 public:
174 SubstitutionPattern command_;
175 std::string default_output_extension_;
176 SubstitutionPattern depfile_;
177 DepsFormat depsformat_;
178 SubstitutionPattern description_;
179 std::string lib_switch_;
180 std::string lib_dir_switch_;
181 SubstitutionList outputs_;
182 SubstitutionPattern link_output_;
183 SubstitutionPattern depend_output_;
184 std::string output_prefix_;
185 std::string pool_;
186 bool restat_;
187 SubstitutionPattern rspfile_;
188 SubstitutionPattern rspfile_content_;
189
190 bool complete_;
191
192 SubstitutionBits substitution_bits_;
193
194 DISALLOW_COPY_AND_ASSIGN(Tool);
195 };
196
197 #endif // TOOLS_GN_TOOL_H_
OLDNEW
« no previous file with comments | « tools/gn/test_with_scope.cc ('k') | tools/gn/tool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698