Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 ---------------------------------------------------------- | |
|
jamesr
2014/08/19 19:30:42
seems like this should just be a struct with publi
brettw
2014/08/19 21:29:57
I wanted to have the DCHECKs for verifying that it
| |
| 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 DepsFormat depsformat() const { | |
| 58 return depsformat_; | |
| 59 } | |
| 60 void set_depsformat(DepsFormat f) { | |
| 61 DCHECK(!complete_); | |
| 62 depsformat_ = f; | |
| 63 } | |
| 64 | |
| 65 const SubstitutionPattern& description() const { | |
| 66 return description_; | |
| 67 } | |
| 68 void set_description(const SubstitutionPattern& desc) { | |
| 69 DCHECK(!complete_); | |
| 70 description_ = desc; | |
| 71 } | |
| 72 | |
| 73 // Switch prefixes for libs and lib dirs. | |
| 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 const std::string& lib_dir_switch() const { | |
|
jamesr
2014/08/19 19:30:42
either put a blank line between different getter/s
brettw
2014/08/19 21:29:57
Done.
| |
| 82 return lib_dir_switch_; | |
| 83 } | |
| 84 void set_lib_dir_switch(const std::string& s) { | |
| 85 DCHECK(!complete_); | |
| 86 lib_dir_switch_ = s; | |
| 87 } | |
| 88 | |
| 89 const SubstitutionList& outputs() const { | |
| 90 return outputs_; | |
| 91 } | |
| 92 void set_outputs(const SubstitutionList& out) { | |
| 93 DCHECK(!complete_); | |
| 94 outputs_ = out; | |
| 95 } | |
| 96 | |
| 97 // Should match files in the outputs() if nonempty. | |
| 98 const SubstitutionPattern& link_output() const { | |
| 99 return link_output_; | |
| 100 } | |
| 101 void set_link_output(const SubstitutionPattern& link_out) { | |
| 102 DCHECK(!complete_); | |
| 103 link_output_ = link_out; | |
| 104 } | |
| 105 const SubstitutionPattern& depend_output() const { | |
| 106 return depend_output_; | |
| 107 } | |
| 108 void set_depend_output(const SubstitutionPattern& dep_out) { | |
| 109 DCHECK(!complete_); | |
| 110 depend_output_ = dep_out; | |
| 111 } | |
| 112 | |
| 113 const std::string& output_prefix() const { | |
| 114 return output_prefix_; | |
| 115 } | |
| 116 void set_output_prefix(const std::string& s) { | |
| 117 DCHECK(!complete_); | |
| 118 output_prefix_ = s; | |
| 119 } | |
| 120 | |
| 121 const std::string& pool() const { | |
| 122 return pool_; | |
| 123 } | |
| 124 void set_pool(const std::string& s) { | |
| 125 DCHECK(!complete_); | |
| 126 pool_ = s; | |
| 127 } | |
| 128 | |
| 129 bool restat() const { | |
| 130 return restat_; | |
| 131 } | |
| 132 void set_restat(bool r) { | |
| 133 DCHECK(!complete_); | |
| 134 restat_ = r; | |
| 135 } | |
| 136 | |
| 137 const SubstitutionPattern& rspfile() const { | |
| 138 return rspfile_; | |
| 139 } | |
| 140 void set_rspfile(const SubstitutionPattern& rsp) { | |
| 141 DCHECK(!complete_); | |
| 142 rspfile_ = rsp; | |
| 143 } | |
| 144 | |
| 145 const SubstitutionPattern& rspfile_content() const { | |
| 146 return rspfile_content_; | |
| 147 } | |
| 148 void set_rspfile_content(const SubstitutionPattern& content) { | |
| 149 DCHECK(!complete_); | |
| 150 rspfile_content_ = content; | |
| 151 } | |
| 152 | |
| 153 // Other functions ---------------------------------------------------------- | |
| 154 | |
| 155 // Called when the toolchain is saving this tool, after everything is filled | |
| 156 // in. | |
| 157 void SetComplete(); | |
| 158 | |
| 159 // Returns true if this tool has separate outputs for dependency tracking | |
| 160 // and linking. | |
| 161 bool has_separate_solink_files() const { | |
| 162 return !link_output_.empty() || !depend_output_.empty(); | |
| 163 } | |
| 164 | |
| 165 // Substitutions required by this tool. | |
| 166 const SubstitutionBits& substitution_bits() const { | |
| 167 DCHECK(complete_); | |
| 168 return substitution_bits_; | |
| 169 } | |
| 170 | |
| 171 public: | |
| 172 SubstitutionPattern command_; | |
| 173 std::string default_output_extension_; | |
| 174 SubstitutionPattern depfile_; | |
| 175 DepsFormat depsformat_; | |
| 176 SubstitutionPattern description_; | |
| 177 std::string lib_switch_; | |
| 178 std::string lib_dir_switch_; | |
| 179 SubstitutionList outputs_; | |
| 180 SubstitutionPattern link_output_; | |
| 181 SubstitutionPattern depend_output_; | |
| 182 std::string output_prefix_; | |
| 183 std::string pool_; | |
| 184 bool restat_; | |
| 185 SubstitutionPattern rspfile_; | |
| 186 SubstitutionPattern rspfile_content_; | |
| 187 | |
| 188 bool complete_; | |
| 189 | |
| 190 SubstitutionBits substitution_bits_; | |
| 191 | |
| 192 DISALLOW_COPY_AND_ASSIGN(Tool); | |
| 193 }; | |
| 194 | |
| 195 #endif // TOOLS_GN_TOOL_H_ | |
| OLD | NEW |