aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index aff9c39e18..21714bbf33 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.actions.ActionOwner;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MiddlemanFactory;
import com.google.devtools.build.lib.analysis.AnalysisUtils;
+import com.google.devtools.build.lib.analysis.ConfigurationMakeVariableContext;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.MakeVariableSupplier;
import com.google.devtools.build.lib.analysis.PlatformConfiguration;
@@ -158,20 +159,22 @@ public class CppHelper {
List<String> tokens = new ArrayList<>();
ImmutableList<? extends MakeVariableSupplier> makeVariableSuppliers =
ImmutableList.of(new CcFlagsSupplier(ruleContext));
+ ConfigurationMakeVariableContext makeVariableContext =
+ ruleContext.getConfigurationMakeVariableContext(makeVariableSuppliers);
for (String token : input) {
try {
// Legacy behavior: tokenize all items.
if (tokenization) {
ruleContext.tokenizeAndExpandMakeVars(
- tokens, attributeName, token, makeVariableSuppliers);
+ tokens, attributeName, token, makeVariableContext);
} else {
String exp =
- ruleContext.expandSingleMakeVariable(attributeName, token, makeVariableSuppliers);
+ ruleContext.expandSingleMakeVariable(attributeName, token, makeVariableContext);
if (exp != null) {
ShellUtils.tokenize(tokens, exp);
} else {
tokens.add(
- ruleContext.expandMakeVariables(attributeName, token, makeVariableSuppliers));
+ ruleContext.expandMakeVariables(attributeName, token, makeVariableContext));
}
}
} catch (ShellUtils.TokenizationException e) {
@@ -197,17 +200,18 @@ public class CppHelper {
* variable or flag) or tokenizes and expands make variables.
*/
public static void expandAttribute(RuleContext ruleContext,
- List<String> values, String attrName, String attrValue, boolean attemptLabelExpansion) {
+ List<String> result, String attrName, String attrValue, boolean attemptLabelExpansion) {
if (attemptLabelExpansion && CppHelper.isLinkoptLabel(attrValue)) {
- if (!CppHelper.expandLabel(ruleContext, values, attrValue)) {
+ if (!CppHelper.expandLabel(ruleContext, result, attrValue)) {
ruleContext.attributeError(attrName, "could not resolve label '" + attrValue + "'");
}
} else {
ruleContext.tokenizeAndExpandMakeVars(
- values,
+ result,
attrName,
attrValue,
- ImmutableList.of(new CcFlagsSupplier(ruleContext)));
+ ruleContext.getConfigurationMakeVariableContext(
+ ImmutableList.of(new CcFlagsSupplier(ruleContext))));
}
}
@@ -232,8 +236,8 @@ public class CppHelper {
* @param labelName the name of the label to expand
* @return true if the label was expanded successfully, false otherwise
*/
- private static boolean expandLabel(RuleContext ruleContext, List<String> linkopts,
- String labelName) {
+ private static boolean expandLabel(
+ RuleContext ruleContext, List<String> linkopts, String labelName) {
try {
Label label = ruleContext.getLabel().getRelative(labelName);
for (String prereqKind : LINKOPTS_PREREQUISITE_LABEL_KINDS) {