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_
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "tools/gn/substitution_list.h"
13 #include "tools/gn/substitution_pattern.h"
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.
31 const SubstitutionPattern
& command() const {
34 void set_command(const SubstitutionPattern
& 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
) {
45 DCHECK(ext
.empty() || ext
[0] == '.');
46 default_output_extension_
= ext
;
49 // Dependency file (if supported).
50 const SubstitutionPattern
& depfile() const {
53 void set_depfile(const SubstitutionPattern
& df
) {
58 DepsFormat
depsformat() const {
61 void set_depsformat(DepsFormat f
) {
66 const SubstitutionPattern
& description() const {
69 void set_description(const SubstitutionPattern
& desc
) {
74 const std::string
& lib_switch() const {
77 void set_lib_switch(const std::string
& s
) {
82 const std::string
& lib_dir_switch() const {
83 return lib_dir_switch_
;
85 void set_lib_dir_switch(const std::string
& s
) {
90 const SubstitutionList
& outputs() const {
93 void set_outputs(const SubstitutionList
& out
) {
98 // Should match files in the outputs() if nonempty.
99 const SubstitutionPattern
& link_output() const {
102 void set_link_output(const SubstitutionPattern
& link_out
) {
104 link_output_
= link_out
;
107 const SubstitutionPattern
& depend_output() const {
108 return depend_output_
;
110 void set_depend_output(const SubstitutionPattern
& dep_out
) {
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
) {
123 bool restat() const {
126 void set_restat(bool r
) {
131 const SubstitutionPattern
& rspfile() const {
134 void set_rspfile(const SubstitutionPattern
& rsp
) {
139 const SubstitutionPattern
& rspfile_content() const {
140 return rspfile_content_
;
142 void set_rspfile_content(const SubstitutionPattern
& content
) {
144 rspfile_content_
= content
;
147 // Other functions ----------------------------------------------------------
149 // Called when the toolchain is saving this tool, after everything is filled
153 // Returns true if this tool has separate outputs for dependency tracking
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 {
162 return substitution_bits_
;
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_
;
178 SubstitutionPattern rspfile_
;
179 SubstitutionPattern rspfile_content_
;
183 SubstitutionBits substitution_bits_
;
185 DISALLOW_COPY_AND_ASSIGN(Tool
);
188 #endif // TOOLS_GN_TOOL_H_