Added new RuleClass flag to turn off platform support, to stop dependency cycles when loading platforms.
Part of #4128.
Change-Id: Ie55a91aaaec15d8eb537f59131fc2e69a8f9c251
PiperOrigin-RevId: 176509311
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 5f078d7..743625d 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -486,6 +486,7 @@
private final Map<String, Attribute> attributes = new LinkedHashMap<>();
private final Set<Label> requiredToolchains = new HashSet<>();
+ private boolean supportsPlatforms = true;
/**
* Constructs a new {@code RuleClassBuilder} using all attributes from all
@@ -517,6 +518,7 @@
supportsConstraintChecking = parent.supportsConstraintChecking;
addRequiredToolchains(parent.getRequiredToolchains());
+ supportsPlatforms = parent.supportsPlatforms;
for (Attribute attribute : parent.getAttributes()) {
String attrName = attribute.getName();
@@ -599,6 +601,7 @@
configurationFragmentPolicy.build(),
supportsConstraintChecking,
requiredToolchains,
+ supportsPlatforms,
attributes.values().toArray(new Attribute[0]));
}
@@ -1010,6 +1013,11 @@
return this;
}
+ public Builder supportsPlatforms(boolean flag) {
+ this.supportsPlatforms = flag;
+ return this;
+ }
+
/**
* Returns an Attribute.Builder object which contains a replica of the
* same attribute in the parent rule if exists.
@@ -1132,6 +1140,7 @@
private final boolean supportsConstraintChecking;
private final ImmutableSet<Label> requiredToolchains;
+ private final boolean supportsPlatforms;
/**
* Constructs an instance of RuleClass whose name is 'name', attributes are 'attributes'. The
@@ -1181,6 +1190,7 @@
ConfigurationFragmentPolicy configurationFragmentPolicy,
boolean supportsConstraintChecking,
Set<Label> requiredToolchains,
+ boolean supportsPlatforms,
Attribute... attributes) {
this.name = name;
this.key = key;
@@ -1211,6 +1221,7 @@
this.configurationFragmentPolicy = configurationFragmentPolicy;
this.supportsConstraintChecking = supportsConstraintChecking;
this.requiredToolchains = ImmutableSet.copyOf(requiredToolchains);
+ this.supportsPlatforms = supportsPlatforms;
// Create the index and collect non-configurable attributes.
int index = 0;
@@ -2031,6 +2042,10 @@
return requiredToolchains;
}
+ public boolean supportsPlatforms() {
+ return supportsPlatforms;
+ }
+
public static boolean isThirdPartyPackage(PackageIdentifier packageIdentifier) {
if (!packageIdentifier.getRepository().isMain()) {
return false;