Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1984)

Unified Diff: tools/gn/binary_target_generator.cc

Issue 516683002: Add GN variables for controlling header checking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@desc
Patch Set: merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/binary_target_generator.h ('k') | tools/gn/command_check.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b11a529dc0ff0a6baf570c00133a98e3d3d7ab10 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 entries are in the deps.
+ 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]);
+}
« no previous file with comments | « tools/gn/binary_target_generator.h ('k') | tools/gn/command_check.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698