From 0b6389723a8d9d3a92e49dc0412fb395b62dc32c Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Tue, 8 Sep 2015 13:25:35 +0000 Subject: Avoid checking visibility and other constraints for the lipo dependency. The lipo dependency is artificial; it's an artifact of how LIPO is implemented in Bazel. Running these checks doesn't make sense; they unnecessarily disallow perfectly valid scenarios. -- MOS_MIGRATED_REVID=102550286 --- .../google/devtools/build/lib/analysis/RuleContext.java | 4 +++- .../build/lib/bazel/rules/cpp/BazelCppRuleClasses.java | 3 ++- .../google/devtools/build/lib/packages/Attribute.java | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index 16982f0519..0cfb114da0 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -1570,7 +1570,9 @@ public final class RuleContext extends TargetContext validateDirectPrerequisiteType(prerequisite, attribute); validateDirectPrerequisiteFileTypes(prerequisite, attribute); validateMandatoryProviders(prerequisite, attribute); - prerequisiteValidator.validate(this, prerequisite, attribute); + if (attribute.performConstraintsCheck()) { + prerequisiteValidator.validate(this, prerequisite, attribute); + } } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java index 5e4a7afa7a..1437192d50 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java @@ -374,7 +374,8 @@ public class BazelCppRuleClasses { .add(attr("includes", STRING_LIST)) .add(attr(":lipo_context_collector", LABEL) .cfg(CppTransition.LIPO_COLLECTOR) - .value(LIPO_CONTEXT_COLLECTOR)) + .value(LIPO_CONTEXT_COLLECTOR) + .skipConstraintsCheck()) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java index 391a1da7b6..c181a7e156 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java @@ -201,6 +201,11 @@ public final class Attribute implements Comparable { * its value based on properties of the build configuration. */ NONCONFIGURABLE, + + /** + * Whether we should skip constraints checks for licenses, visibility, etc. + */ + SKIP_CONSTRAINTS_CHECKS, } // TODO(bazel-team): modify this interface to extend Predicate and have an extra error @@ -520,6 +525,13 @@ public final class Attribute implements Comparable { return setPropertyFlag(PropertyFlag.TAGGABLE, "taggable"); } + /** + * Disables constraints and visibility checks. + */ + public Builder skipConstraintsCheck() { + return setPropertyFlag(PropertyFlag.SKIP_CONSTRAINTS_CHECKS, "skip_constraints_checks"); + } + /** * If this is a label or label-list attribute, then this sets the allowed * rule types for the labels occurring in the attribute. If the attribute @@ -1238,6 +1250,10 @@ public final class Attribute implements Comparable { return getPropertyFlag(PropertyFlag.CHECK_ALLOWED_VALUES); } + public boolean performConstraintsCheck() { + return !getPropertyFlag(PropertyFlag.SKIP_CONSTRAINTS_CHECKS); + } + /** * Returns true if this attribute's value can be influenced by the build configuration. */ -- cgit v1.2.3