aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Marcel Hlopko <hlopko@google.com>2017-01-03 14:28:07 +0000
committerGravatar John Cater <jcater@google.com>2017-01-03 15:06:24 +0000
commit2b6279a8a0afed3dcd1a4126aa141babaa7bd318 (patch)
tree955b7ad320ea7f8f4ef8c806dad6a414f4e017ef /src/main/java
parent536d9cb8c7bc9798dc8d5015bea6c7ec2501a312 (diff)
Add expand_if_equal crosstool.proto message
This will be used by LibrariesToLinkValue to switch on many different types of libraries. -- PiperOrigin-RevId: 143438434 MOS_MIGRATED_REVID=143438434
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
index 2c3a139b7c..4e763cb538 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
@@ -331,6 +331,17 @@ public class CcToolchainFeatures implements Serializable {
}
}
+ @Immutable
+ private static class VariableWithValue {
+ public final String variable;
+ public final String value;
+
+ public VariableWithValue(String variable, String value) {
+ this.variable = variable;
+ this.value = value;
+ }
+ }
+
/**
* A group of flags. When iterateOverVariable is specified, we assume the variable is a sequence
* and the flag_group will be expanded repeatedly for every value in the sequence.
@@ -343,6 +354,7 @@ public class CcToolchainFeatures implements Serializable {
private final ImmutableSet<String> expandIfAllAvailable;
private final String expandIfTrue;
private final String expandIfFalse;
+ private final VariableWithValue expandIfEqual;
/**
* TODO(b/32655571): Cleanup and get rid of usedVariables field once implicit iteration is not
@@ -380,6 +392,13 @@ public class CcToolchainFeatures implements Serializable {
this.expandIfAllAvailable = ImmutableSet.copyOf(flagGroup.getExpandIfAllAvailableList());
this.expandIfTrue = Strings.emptyToNull(flagGroup.getExpandIfTrue());
this.expandIfFalse = Strings.emptyToNull(flagGroup.getExpandIfFalse());
+ if (flagGroup.hasExpandIfEqual()) {
+ this.expandIfEqual = new VariableWithValue(
+ flagGroup.getExpandIfEqual().getVariable(),
+ flagGroup.getExpandIfEqual().getValue());
+ } else {
+ this.expandIfEqual = null;
+ }
}
@Override
@@ -421,6 +440,14 @@ public class CcToolchainFeatures implements Serializable {
&& variables.getVariable(expandIfFalse).isTruthy()) {
return false;
}
+ if (expandIfEqual != null
+ && (!variables.isAvailable(expandIfEqual.variable)
+ || !variables
+ .getVariable(expandIfEqual.variable)
+ .getStringValue(expandIfEqual.variable)
+ .equals(expandIfEqual.value))) {
+ return false;
+ }
return true;
}