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_generator.h" | 5 #include "tools/gn/target_generator.h" |
6 | 6 |
7 #include "tools/gn/action_target_generator.h" | 7 #include "tools/gn/action_target_generator.h" |
8 #include "tools/gn/binary_target_generator.h" | 8 #include "tools/gn/binary_target_generator.h" |
9 #include "tools/gn/build_settings.h" | 9 #include "tools/gn/build_settings.h" |
10 #include "tools/gn/config.h" | 10 #include "tools/gn/config.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 &target_->public_configs())) | 194 &target_->public_configs())) |
195 return false; | 195 return false; |
196 } | 196 } |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 bool TargetGenerator::FillData() { | 200 bool TargetGenerator::FillData() { |
201 const Value* value = scope_->GetValue(variables::kData, true); | 201 const Value* value = scope_->GetValue(variables::kData, true); |
202 if (!value) | 202 if (!value) |
203 return true; | 203 return true; |
| 204 if (!value->VerifyTypeIs(Value::LIST, err_)) |
| 205 return false; |
204 | 206 |
205 Target::FileList dest_data; | 207 const std::vector<Value>& input_list = value->list_value(); |
206 if (!ExtractListOfRelativeFiles(scope_->settings()->build_settings(), *value, | 208 std::vector<std::string>& output_list = target_->data(); |
207 scope_->GetSourceDir(), &dest_data, err_)) | 209 output_list.reserve(input_list.size()); |
208 return false; | 210 |
209 target_->data().swap(dest_data); | 211 const SourceDir& dir = scope_->GetSourceDir(); |
| 212 const std::string& root_path = |
| 213 scope_->settings()->build_settings()->root_path_utf8(); |
| 214 |
| 215 for (size_t i = 0; i < input_list.size(); i++) { |
| 216 const Value& input = input_list[i]; |
| 217 if (!input.VerifyTypeIs(Value::STRING, err_)) |
| 218 return false; |
| 219 const std::string& input_str = input.string_value(); |
| 220 |
| 221 // Treat each input as either a file or a directory, depending on the |
| 222 // last character. |
| 223 if (!input_str.empty() && input_str[input_str.size() - 1] == '/') { |
| 224 // Resolve as directory. |
| 225 SourceDir resolved = |
| 226 dir.ResolveRelativeDir(input, input_str, err_, root_path); |
| 227 if (err_->has_error()) |
| 228 return false; |
| 229 output_list.push_back(resolved.value()); |
| 230 } else { |
| 231 // Resolve as file. |
| 232 SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path); |
| 233 if (err_->has_error()) |
| 234 return false; |
| 235 output_list.push_back(resolved.value()); |
| 236 } |
| 237 } |
210 return true; | 238 return true; |
211 } | 239 } |
212 | 240 |
213 bool TargetGenerator::FillDependencies() { | 241 bool TargetGenerator::FillDependencies() { |
214 if (!FillGenericDeps(variables::kDeps, &target_->private_deps())) | 242 if (!FillGenericDeps(variables::kDeps, &target_->private_deps())) |
215 return false; | 243 return false; |
216 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps())) | 244 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps())) |
217 return false; | 245 return false; |
218 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps())) | 246 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps())) |
219 return false; | 247 return false; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 bool TargetGenerator::FillForwardDependentConfigs() { | 369 bool TargetGenerator::FillForwardDependentConfigs() { |
342 const Value* value = scope_->GetValue( | 370 const Value* value = scope_->GetValue( |
343 variables::kForwardDependentConfigsFrom, true); | 371 variables::kForwardDependentConfigsFrom, true); |
344 if (value) { | 372 if (value) { |
345 ExtractListOfUniqueLabels(*value, scope_->GetSourceDir(), | 373 ExtractListOfUniqueLabels(*value, scope_->GetSourceDir(), |
346 ToolchainLabelForScope(scope_), | 374 ToolchainLabelForScope(scope_), |
347 &target_->forward_dependent_configs(), err_); | 375 &target_->forward_dependent_configs(), err_); |
348 } | 376 } |
349 return !err_->has_error(); | 377 return !err_->has_error(); |
350 } | 378 } |
OLD | NEW |