diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
3 files changed, 16 insertions, 11 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) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java index 73e4f91b3c..029c0f507c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java @@ -547,7 +547,7 @@ public class JavaCommon { public static List<String> getJvmFlags(RuleContext ruleContext) { List<String> jvmFlags = new ArrayList<>(); jvmFlags.addAll(ruleContext.getFragment(JavaConfiguration.class).getDefaultJvmFlags()); - jvmFlags.addAll(ruleContext.getExpandedStringListAttr("jvm_flags", RuleContext.Tokenize.NO)); + jvmFlags.addAll(ruleContext.getExpandedStringListAttr("jvm_flags")); return jvmFlags; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java index b0dd535c95..e1e779a13b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java @@ -92,7 +92,8 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory { ruleContext, defaultRunfiles, common.getExecutable(), - ImmutableList.of(new CcFlagsSupplier(ruleContext))); + ruleContext.getConfigurationMakeVariableContext( + ImmutableList.of(new CcFlagsSupplier(ruleContext)))); if (ruleContext.hasErrors()) { return null; |