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/logging.h"
11 #include "base/macros.h"
12 #include "tools/gn/substitution_list.h"
13 #include "tools/gn/substitution_pattern.h"
22 enum PrecompiledHeaderType
{
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.
36 const SubstitutionPattern
& command() const {
39 void set_command(const SubstitutionPattern
& 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
) {
50 DCHECK(ext
.empty() || ext
[0] == '.');
51 default_output_extension_
= ext
;
54 // Dependency file (if supported).
55 const SubstitutionPattern
& depfile() const {
58 void set_depfile(const SubstitutionPattern
& df
) {
63 DepsFormat
depsformat() const {
66 void set_depsformat(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 {
81 void set_description(const SubstitutionPattern
& desc
) {
86 const std::string
& lib_switch() const {
89 void set_lib_switch(const std::string
& s
) {
94 const std::string
& lib_dir_switch() const {
95 return lib_dir_switch_
;
97 void set_lib_dir_switch(const std::string
& s
) {
102 const SubstitutionList
& outputs() const {
105 void set_outputs(const SubstitutionList
& out
) {
110 // Should match files in the outputs() if nonempty.
111 const SubstitutionPattern
& link_output() const {
114 void set_link_output(const SubstitutionPattern
& link_out
) {
116 link_output_
= link_out
;
119 const SubstitutionPattern
& depend_output() const {
120 return depend_output_
;
122 void set_depend_output(const SubstitutionPattern
& dep_out
) {
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
) {
135 bool restat() const {
138 void set_restat(bool r
) {
143 const SubstitutionPattern
& rspfile() const {
146 void set_rspfile(const SubstitutionPattern
& rsp
) {
151 const SubstitutionPattern
& rspfile_content() const {
152 return rspfile_content_
;
154 void set_rspfile_content(const SubstitutionPattern
& content
) {
156 rspfile_content_
= content
;
159 // Other functions ----------------------------------------------------------
161 // Called when the toolchain is saving this tool, after everything is filled
165 // Returns true if this tool has separate outputs for dependency tracking
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 {
174 return substitution_bits_
;
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_
;
191 SubstitutionPattern rspfile_
;
192 SubstitutionPattern rspfile_content_
;
196 SubstitutionBits substitution_bits_
;
198 DISALLOW_COPY_AND_ASSIGN(Tool
);
201 #endif // TOOLS_GN_TOOL_H_