OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/target.h" | 5 #include "tools/gn/target.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "tools/gn/config_values_extractors.h" | 10 #include "tools/gn/config_values_extractors.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 return deps.size(); | 66 return deps.size(); |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 Target::Target(const Settings* settings, const Label& label) | 71 Target::Target(const Settings* settings, const Label& label) |
72 : Item(settings, label), | 72 : Item(settings, label), |
73 output_type_(UNKNOWN), | 73 output_type_(UNKNOWN), |
74 all_headers_public_(true), | 74 all_headers_public_(true), |
75 check_includes_(true), | 75 check_includes_(true), |
76 complete_static_lib_(false), | |
76 testonly_(false), | 77 testonly_(false), |
77 hard_dep_(false), | 78 hard_dep_(false), |
78 toolchain_(NULL) { | 79 toolchain_(NULL) { |
79 } | 80 } |
80 | 81 |
81 Target::~Target() { | 82 Target::~Target() { |
82 } | 83 } |
83 | 84 |
84 // static | 85 // static |
85 const char* Target::GetStringForOutputType(OutputType type) { | 86 const char* Target::GetStringForOutputType(OutputType type) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 if (!CheckTestonly(err)) | 154 if (!CheckTestonly(err)) |
154 return false; | 155 return false; |
155 | 156 |
156 return true; | 157 return true; |
157 } | 158 } |
158 | 159 |
159 bool Target::IsLinkable() const { | 160 bool Target::IsLinkable() const { |
160 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; | 161 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; |
161 } | 162 } |
162 | 163 |
164 bool Target::IsFinal() const { | |
165 return output_type_ == EXECUTABLE || output_type_ == SHARED_LIBRARY || | |
166 (output_type_ == STATIC_LIBRARY && complete_static_lib_); | |
167 } | |
168 | |
163 std::string Target::GetComputedOutputName(bool include_prefix) const { | 169 std::string Target::GetComputedOutputName(bool include_prefix) const { |
164 DCHECK(toolchain_) | 170 DCHECK(toolchain_) |
165 << "Toolchain must be specified before getting the computed output name."; | 171 << "Toolchain must be specified before getting the computed output name."; |
166 | 172 |
167 const std::string& name = output_name_.empty() ? label().name() | 173 const std::string& name = output_name_.empty() ? label().name() |
168 : output_name_; | 174 : output_name_; |
169 | 175 |
170 std::string result; | 176 std::string result; |
171 if (include_prefix) { | 177 if (include_prefix) { |
172 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); | 178 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 MergeDirectDependentConfigsFrom(dep, &configs_); | 234 MergeDirectDependentConfigsFrom(dep, &configs_); |
229 | 235 |
230 // Direct dependent libraries. | 236 // Direct dependent libraries. |
231 if (dep->output_type() == STATIC_LIBRARY || | 237 if (dep->output_type() == STATIC_LIBRARY || |
232 dep->output_type() == SHARED_LIBRARY || | 238 dep->output_type() == SHARED_LIBRARY || |
233 dep->output_type() == SOURCE_SET) | 239 dep->output_type() == SOURCE_SET) |
234 inherited_libraries_.push_back(dep); | 240 inherited_libraries_.push_back(dep); |
235 | 241 |
236 // Inherited libraries and flags are inherited across static library | 242 // Inherited libraries and flags are inherited across static library |
237 // boundaries. | 243 // boundaries. |
238 if (dep->output_type() != SHARED_LIBRARY && | 244 if (dep->output_type() != SHARED_LIBRARY && |
brettw
2014/09/12 20:53:33
I think this condition should be replaced by an Is
Chris Masone
2014/09/12 22:56:37
Done.
| |
239 dep->output_type() != EXECUTABLE) { | 245 dep->output_type() != EXECUTABLE) { |
240 inherited_libraries_.Append(dep->inherited_libraries().begin(), | 246 inherited_libraries_.Append(dep->inherited_libraries().begin(), |
241 dep->inherited_libraries().end()); | 247 dep->inherited_libraries().end()); |
242 | 248 |
243 // Inherited library settings. | 249 // Inherited library settings. |
244 all_lib_dirs_.append(dep->all_lib_dirs()); | 250 all_lib_dirs_.append(dep->all_lib_dirs()); |
245 all_libs_.append(dep->all_libs()); | 251 all_libs_.append(dep->all_libs()); |
246 } | 252 } |
247 } | 253 } |
248 } | 254 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 | 387 |
382 for (size_t i = 0; i < datadeps_.size(); i++) { | 388 for (size_t i = 0; i < datadeps_.size(); i++) { |
383 if (datadeps_[i].ptr->testonly()) { | 389 if (datadeps_[i].ptr->testonly()) { |
384 *err = MakeTestOnlyError(this, datadeps_[i].ptr); | 390 *err = MakeTestOnlyError(this, datadeps_[i].ptr); |
385 return false; | 391 return false; |
386 } | 392 } |
387 } | 393 } |
388 | 394 |
389 return true; | 395 return true; |
390 } | 396 } |
OLD | NEW |