| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "tools/gn/action_target_generator.h" | 9 #include "tools/gn/action_target_generator.h" |
| 10 #include "tools/gn/binary_target_generator.h" | 10 #include "tools/gn/binary_target_generator.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 void TargetGenerator::Run() { | 39 void TargetGenerator::Run() { |
| 40 // All target types use these. | 40 // All target types use these. |
| 41 if (!FillDependentConfigs()) | 41 if (!FillDependentConfigs()) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 if (!FillData()) | 44 if (!FillData()) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 if (!FillBundleData()) |
| 48 return; |
| 49 |
| 47 if (!FillDependencies()) | 50 if (!FillDependencies()) |
| 48 return; | 51 return; |
| 49 | 52 |
| 50 if (!FillTestonly()) | 53 if (!FillTestonly()) |
| 51 return; | 54 return; |
| 52 | 55 |
| 53 if (!FillAssertNoDeps()) | 56 if (!FillAssertNoDeps()) |
| 54 return; | 57 return; |
| 55 | 58 |
| 56 if (!Visibility::FillItemVisibility(target_, scope_, err_)) | 59 if (!Visibility::FillItemVisibility(target_, scope_, err_)) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 80 Label label(scope->GetSourceDir(), args[0].string_value(), | 83 Label label(scope->GetSourceDir(), args[0].string_value(), |
| 81 toolchain_label.dir(), toolchain_label.name()); | 84 toolchain_label.dir(), toolchain_label.name()); |
| 82 | 85 |
| 83 if (g_scheduler->verbose_logging()) | 86 if (g_scheduler->verbose_logging()) |
| 84 g_scheduler->Log("Defining target", label.GetUserVisibleName(true)); | 87 g_scheduler->Log("Defining target", label.GetUserVisibleName(true)); |
| 85 | 88 |
| 86 scoped_ptr<Target> target(new Target(scope->settings(), label)); | 89 scoped_ptr<Target> target(new Target(scope->settings(), label)); |
| 87 target->set_defined_from(function_call); | 90 target->set_defined_from(function_call); |
| 88 | 91 |
| 89 // Create and call out to the proper generator. | 92 // Create and call out to the proper generator. |
| 90 if (output_type == functions::kCopy) { | 93 if (output_type == functions::kCopy || |
| 91 CopyTargetGenerator generator(target.get(), scope, function_call, err); | 94 output_type == functions::kCopyBundleData) { |
| 95 Target::OutputType target_output_type = output_type == functions::kCopy |
| 96 ? Target::COPY_FILES |
| 97 : Target::COPY_BUNDLE_DATA; |
| 98 CopyTargetGenerator generator(target.get(), scope, function_call, |
| 99 target_output_type, err); |
| 92 generator.Run(); | 100 generator.Run(); |
| 93 } else if (output_type == functions::kAction) { | 101 } else if (output_type == functions::kAction) { |
| 94 ActionTargetGenerator generator(target.get(), scope, function_call, | 102 ActionTargetGenerator generator(target.get(), scope, function_call, |
| 95 Target::ACTION, err); | 103 Target::ACTION, err); |
| 96 generator.Run(); | 104 generator.Run(); |
| 97 } else if (output_type == functions::kActionForEach) { | 105 } else if (output_type == functions::kActionForEach) { |
| 98 ActionTargetGenerator generator(target.get(), scope, function_call, | 106 ActionTargetGenerator generator(target.get(), scope, function_call, |
| 99 Target::ACTION_FOREACH, err); | 107 Target::ACTION_FOREACH, err); |
| 100 generator.Run(); | 108 generator.Run(); |
| 101 } else if (output_type == functions::kExecutable) { | 109 } else if (output_type == functions::kExecutable) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // Resolve as file. | 242 // Resolve as file. |
| 235 SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path); | 243 SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path); |
| 236 if (err_->has_error()) | 244 if (err_->has_error()) |
| 237 return false; | 245 return false; |
| 238 output_list.push_back(resolved.value()); | 246 output_list.push_back(resolved.value()); |
| 239 } | 247 } |
| 240 } | 248 } |
| 241 return true; | 249 return true; |
| 242 } | 250 } |
| 243 | 251 |
| 252 bool TargetGenerator::FillBundleData() { |
| 253 const Value* value = scope_->GetValue(variables::kBundleData, true); |
| 254 if (!value) |
| 255 return true; |
| 256 |
| 257 Target::FileList bundle_data; |
| 258 if (!ExtractListOfRelativeFiles(scope_->settings()->build_settings(), *value, |
| 259 scope_->GetSourceDir(), &bundle_data, err_)) |
| 260 return false; |
| 261 |
| 262 target_->bundle_data().insert(bundle_data.begin(), bundle_data.end()); |
| 263 return true; |
| 264 } |
| 265 |
| 266 bool TargetGenerator::FillBundleDataFilter() { |
| 267 const Value* value = scope_->GetValue(variables::kBundleDataFilter, true); |
| 268 if (!value) |
| 269 return true; |
| 270 |
| 271 PatternList filter; |
| 272 filter.SetFromValue(*value, err_); |
| 273 if (err_->has_error()) |
| 274 return false; |
| 275 |
| 276 std::swap(target_->bundle_data_filter(), filter); |
| 277 return true; |
| 278 } |
| 279 |
| 244 bool TargetGenerator::FillDependencies() { | 280 bool TargetGenerator::FillDependencies() { |
| 245 if (!FillGenericDeps(variables::kDeps, &target_->private_deps())) | 281 if (!FillGenericDeps(variables::kDeps, &target_->private_deps())) |
| 246 return false; | 282 return false; |
| 247 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps())) | 283 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps())) |
| 248 return false; | 284 return false; |
| 249 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps())) | 285 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps())) |
| 250 return false; | 286 return false; |
| 251 | 287 |
| 252 // "data_deps" was previously named "datadeps". For backwards-compat, read | 288 // "data_deps" was previously named "datadeps". For backwards-compat, read |
| 253 // the old one if no "data_deps" were specified. | 289 // the old one if no "data_deps" were specified. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 402 |
| 367 bool TargetGenerator::FillGenericDeps(const char* var_name, | 403 bool TargetGenerator::FillGenericDeps(const char* var_name, |
| 368 LabelTargetVector* dest) { | 404 LabelTargetVector* dest) { |
| 369 const Value* value = scope_->GetValue(var_name, true); | 405 const Value* value = scope_->GetValue(var_name, true); |
| 370 if (value) { | 406 if (value) { |
| 371 ExtractListOfLabels(*value, scope_->GetSourceDir(), | 407 ExtractListOfLabels(*value, scope_->GetSourceDir(), |
| 372 ToolchainLabelForScope(scope_), dest, err_); | 408 ToolchainLabelForScope(scope_), dest, err_); |
| 373 } | 409 } |
| 374 return !err_->has_error(); | 410 return !err_->has_error(); |
| 375 } | 411 } |
| OLD | NEW |