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
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 16982f0..0cfb114 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 @@
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 5e4a7af..1437192 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 @@
.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 391a1da..c181a7e 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 @@
* 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
@@ -521,6 +526,13 @@
}
/**
+ * Disables constraints and visibility checks.
+ */
+ public Builder<TYPE> 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
* contains Labels of any other rule type, then an error is produced during
@@ -1238,6 +1250,10 @@
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.
*/