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
{
31 // Getters/setters ----------------------------------------------------------
33 // After the tool has had its attributes set, the caller must call
34 // SetComplete(), at which point no other changes can be made.
37 const SubstitutionPattern
& command() const {
40 void set_command(const SubstitutionPattern
& cmd
) {
45 // Should include a leading "." if nonempty.
46 const std::string
& default_output_extension() const {
47 return default_output_extension_
;
49 void set_default_output_extension(const std::string
& ext
) {
51 DCHECK(ext
.empty() || ext
[0] == '.');
52 default_output_extension_
= ext
;
55 // Dependency file (if supported).
56 const SubstitutionPattern
& depfile() const {
59 void set_depfile(const SubstitutionPattern
& df
) {
64 DepsFormat
depsformat() const {
67 void set_depsformat(DepsFormat f
) {
72 PrecompiledHeaderType
precompiled_header_type() const {
73 return precompiled_header_type_
;
75 void set_precompiled_header_type(PrecompiledHeaderType pch_type
) {
76 precompiled_header_type_
= pch_type
;
79 const SubstitutionPattern
& description() const {
82 void set_description(const SubstitutionPattern
& desc
) {
87 const std::string
& lib_switch() const {
90 void set_lib_switch(const std::string
& s
) {
95 const std::string
& lib_dir_switch() const {
96 return lib_dir_switch_
;
98 void set_lib_dir_switch(const std::string
& s
) {
103 const SubstitutionList
& outputs() const {
106 void set_outputs(const SubstitutionList
& out
) {
111 // Should match files in the outputs() if nonempty.
112 const SubstitutionPattern
& link_output() const {
115 void set_link_output(const SubstitutionPattern
& link_out
) {
117 link_output_
= link_out
;
120 const SubstitutionPattern
& depend_output() const {
121 return depend_output_
;
123 void set_depend_output(const SubstitutionPattern
& dep_out
) {
125 depend_output_
= dep_out
;
128 const std::string
& output_prefix() const {
129 return output_prefix_
;
131 void set_output_prefix(const std::string
& s
) {
136 bool restat() const {
139 void set_restat(bool r
) {
144 const SubstitutionPattern
& rspfile() const {
147 void set_rspfile(const SubstitutionPattern
& rsp
) {
152 const SubstitutionPattern
& rspfile_content() const {
153 return rspfile_content_
;
155 void set_rspfile_content(const SubstitutionPattern
& content
) {
157 rspfile_content_
= content
;
160 // Other functions ----------------------------------------------------------
162 // Called when the toolchain is saving this tool, after everything is filled
166 // Returns true if this tool has separate outputs for dependency tracking
168 bool has_separate_solink_files() const {
169 return !link_output_
.empty() || !depend_output_
.empty();
172 // Substitutions required by this tool.
173 const SubstitutionBits
& substitution_bits() const {
175 return substitution_bits_
;
179 SubstitutionPattern command_
;
180 std::string default_output_extension_
;
181 SubstitutionPattern depfile_
;
182 DepsFormat depsformat_
;
183 PrecompiledHeaderType precompiled_header_type_
;
184 SubstitutionPattern description_
;
185 std::string lib_switch_
;
186 std::string lib_dir_switch_
;
187 SubstitutionList outputs_
;
188 SubstitutionPattern link_output_
;
189 SubstitutionPattern depend_output_
;
190 std::string output_prefix_
;
192 SubstitutionPattern rspfile_
;
193 SubstitutionPattern rspfile_content_
;
197 SubstitutionBits substitution_bits_
;
199 DISALLOW_COPY_AND_ASSIGN(Tool
);
202 #endif // TOOLS_GN_TOOL_H_