Chromium Code Reviews| Index: tools/gn/binary_target_generator.cc |
| diff --git a/tools/gn/binary_target_generator.cc b/tools/gn/binary_target_generator.cc |
| index 22a5ea633b28f48beac5a9173c7d190216bb2103..e5d0bf82704cfcd0655c47bf1f448390da480c0e 100644 |
| --- a/tools/gn/binary_target_generator.cc |
| +++ b/tools/gn/binary_target_generator.cc |
| @@ -6,7 +6,9 @@ |
| #include "tools/gn/config_values_generator.h" |
| #include "tools/gn/err.h" |
| +#include "tools/gn/functions.h" |
| #include "tools/gn/scope.h" |
| +#include "tools/gn/value_extractors.h" |
| #include "tools/gn/variables.h" |
| BinaryTargetGenerator::BinaryTargetGenerator( |
| @@ -41,6 +43,10 @@ void BinaryTargetGenerator::DoRun() { |
| if (err_->has_error()) |
| return; |
| + FillCheckIncludes(); |
| + if (err_->has_error()) |
| + return; |
| + |
| FillInputs(); |
| if (err_->has_error()) |
| return; |
| @@ -49,6 +55,10 @@ void BinaryTargetGenerator::DoRun() { |
| if (err_->has_error()) |
| return; |
| + FillAllowCircularIncludesFrom(); |
| + if (err_->has_error()) |
| + return; |
| + |
| // Config values (compiler flags, etc.) set directly on this target. |
| ConfigValuesGenerator gen(&target_->config_values(), scope_, |
| scope_->GetSourceDir(), err_); |
| @@ -57,6 +67,15 @@ void BinaryTargetGenerator::DoRun() { |
| return; |
| } |
| +void BinaryTargetGenerator::FillCheckIncludes() { |
| + const Value* value = scope_->GetValue(variables::kCheckIncludes, true); |
| + if (!value) |
| + return; |
| + if (!value->VerifyTypeIs(Value::BOOLEAN, err_)) |
| + return; |
| + target_->set_check_includes(value->boolean_value()); |
| +} |
| + |
| void BinaryTargetGenerator::FillOutputName() { |
| const Value* value = scope_->GetValue(variables::kOutputName, true); |
| if (!value) |
| @@ -74,3 +93,40 @@ void BinaryTargetGenerator::FillOutputExtension() { |
| return; |
| target_->set_output_extension(value->string_value()); |
| } |
| + |
| +void BinaryTargetGenerator::FillAllowCircularIncludesFrom() { |
| + const Value* value = scope_->GetValue( |
| + variables::kAllowCircularIncludesFrom, true); |
| + if (!value) |
| + return; |
| + |
| + UniqueVector<Label> circular; |
| + ExtractListOfUniqueLabels(*value, scope_->GetSourceDir(), |
| + ToolchainLabelForScope(scope_), &circular, err_); |
| + if (err_->has_error()) |
| + return; |
| + |
| + // Validate that all circular includes entriews are in the deps. |
|
viettrungluu
2014/08/28 19:47:54
s/entriews/entries/
|
| + const LabelTargetVector& deps = target_->deps(); |
| + for (size_t circular_i = 0; circular_i < circular.size(); circular_i++) { |
| + bool found_dep = false; |
| + for (size_t dep_i = 0; dep_i < deps.size(); dep_i++) { |
| + if (deps[dep_i].label == circular[circular_i]) { |
| + found_dep = true; |
| + break; |
| + } |
| + } |
| + if (!found_dep) { |
| + *err_ = Err(*value, "Label not in deps.", |
| + "The label \"" + circular[circular_i].GetUserVisibleName(false) + |
| + "\"\nwas not in the deps of this target. " |
| + "allow_circular_includes_from only allows\ntargets present in the " |
| + "deps."); |
| + return; |
| + } |
| + } |
| + |
| + // Add to the set. |
| + for (size_t i = 0; i < circular.size(); i++) |
| + target_->allow_circular_includes_from().insert(circular[i]); |
| +} |