Index: tools/gn/target_generator.cc |
diff --git a/tools/gn/target_generator.cc b/tools/gn/target_generator.cc |
index b0e1dee56b840d8e198e94d71b95cea2843d0352..3fdd9e39a104ec5a19ddbf46c6995c2ffae6c3af 100644 |
--- a/tools/gn/target_generator.cc |
+++ b/tools/gn/target_generator.cc |
@@ -22,6 +22,7 @@ |
#include "tools/gn/token.h" |
#include "tools/gn/value.h" |
#include "tools/gn/value_extractors.h" |
+#include "tools/gn/variables.h" |
namespace { |
@@ -98,6 +99,7 @@ void TargetGenerator::Run() { |
if (TypeHasOutputs(output_type)) |
FillOutputs(); |
FillDependencies(); // All types have dependencies. |
+ FillDataDependencies(); // All types have dependencies. |
if (TypeHasConfigValues(output_type)) { |
ConfigValuesGenerator gen(&target_->config_values(), scope_, |
@@ -208,22 +210,46 @@ void TargetGenerator::FillGenericConfigs( |
(target_->*setter)(&dest_configs); |
} |
+void TargetGenerator::FillGenericDeps( |
+ const char* var_name, |
+ void (Target::*setter)(std::vector<const Target*>*)) { |
+ const Value* value = scope_->GetValue(var_name, true); |
+ if (!value) |
+ return; |
+ |
+ std::vector<Label> labels; |
+ if (!ExtractListOfLabels(*value, input_directory_, |
+ ToolchainLabelForScope(scope_), &labels, err_)) |
+ return; |
+ |
+ std::vector<const Target*> dest_deps; |
+ dest_deps.resize(labels.size()); |
+ for (size_t i = 0; i < labels.size(); i++) { |
+ dest_deps[i] = GetBuildSettings()->target_manager().GetTarget( |
+ labels[i], value->list_value()[i].origin()->GetRange(), target_, err_); |
+ if (err_->has_error()) |
+ return; |
+ } |
+ |
+ (target_->*setter)(&dest_deps); |
+} |
+ |
void TargetGenerator::FillConfigs() { |
- FillGenericConfigs("configs", &Target::swap_in_configs); |
+ FillGenericConfigs(variables::kConfigs, &Target::swap_in_configs); |
} |
void TargetGenerator::FillAllDependentConfigs() { |
- FillGenericConfigs("all_dependent_configs", |
+ FillGenericConfigs(variables::kAllDependentConfigs, |
&Target::swap_in_all_dependent_configs); |
} |
void TargetGenerator::FillDirectDependentConfigs() { |
- FillGenericConfigs("direct_dependent_configs", |
+ FillGenericConfigs(variables::kDirectDependentConfigs, |
&Target::swap_in_direct_dependent_configs); |
} |
void TargetGenerator::FillSources() { |
- const Value* value = scope_->GetValue("sources", true); |
+ const Value* value = scope_->GetValue(variables::kSources, true); |
if (!value) |
return; |
@@ -235,6 +261,8 @@ void TargetGenerator::FillSources() { |
} |
void TargetGenerator::FillData() { |
+ // TODO(brettW) hook this up to the constant when we have cleaned up |
+ // how data files are used. |
const Value* value = scope_->GetValue("data", true); |
if (!value) |
return; |
@@ -247,25 +275,11 @@ void TargetGenerator::FillData() { |
} |
void TargetGenerator::FillDependencies() { |
- const Value* value = scope_->GetValue("deps", true); |
- if (!value) |
- return; |
- |
- std::vector<Label> labels; |
- if (!ExtractListOfLabels(*value, input_directory_, |
- ToolchainLabelForScope(scope_), &labels, err_)) |
- return; |
- |
- std::vector<const Target*> dest_deps; |
- dest_deps.resize(labels.size()); |
- for (size_t i = 0; i < labels.size(); i++) { |
- dest_deps[i] = GetBuildSettings()->target_manager().GetTarget( |
- labels[i], value->list_value()[i].origin()->GetRange(), target_, err_); |
- if (err_->has_error()) |
- return; |
- } |
+ FillGenericDeps(variables::kDeps, &Target::swap_in_deps); |
+} |
- target_->swap_in_deps(&dest_deps); |
+void TargetGenerator::FillDataDependencies() { |
+ FillGenericDeps(variables::kDatadeps, &Target::swap_in_datadeps); |
} |
void TargetGenerator::FillDestDir() { |