aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-10-26 10:27:00 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-10-26 10:59:41 +0200
commit8cb1d2fb460a9caf47df58d7ff051d31080a77cb (patch)
treedcca2e1b72d55de0f990c289176765af8b88192a /src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java
parente012dcff33c26f5054066d5b8d9c26d356d5a30b (diff)
Automated rollback of commit ca77f608e486bf7aa762565d25bf7b9e30f2268c.
This also rolls back unknown commit. *** Reason for rollback *** Affected expand_location Skylark API semantics - it no longer accepts ${abc} or plain dollar signs, but complains. *** Original change description *** Extend TemplateExpander to handle $(func param) expansion Rewrite the Expander to use the new functionality; also rewrite the Skylark expand_location function to use it. PiperOrigin-RevId: 173508888
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java
index 53aaf47e79..f71730b10a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleImplementationFunctions.java
@@ -20,12 +20,11 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.AliasProvider;
import com.google.devtools.build.lib.analysis.CommandHelper;
import com.google.devtools.build.lib.analysis.FileProvider;
+import com.google.devtools.build.lib.analysis.LocationExpander;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.configuredtargets.AbstractConfiguredTarget;
-import com.google.devtools.build.lib.analysis.stringtemplate.ExpansionException;
-import com.google.devtools.build.lib.analysis.stringtemplate.TemplateContext;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -319,12 +318,11 @@ public class SkylarkRuleImplementationFunctions {
throws EvalException {
ctx.checkMutable("expand_location");
try {
- return ctx
- .getRuleContext()
- .getExpander(new FakeTemplateContext())
- .withExecLocations(
- makeLabelMap(targets.getContents(TransitiveInfoCollection.class, "targets")))
- .expand(/*attributeName=*/null, input);
+ return new LocationExpander(
+ ctx.getRuleContext(),
+ makeLabelMap(targets.getContents(TransitiveInfoCollection.class, "targets")),
+ LocationExpander.Options.EXEC_PATHS)
+ .expand(input);
} catch (IllegalStateException ise) {
throw new EvalException(loc, ise);
}
@@ -332,23 +330,6 @@ public class SkylarkRuleImplementationFunctions {
};
/**
- * This class only exists for backwards compatibility. Previously, we were using LocationExpander
- * directly, which passes through all unrecognized $() expressions.
- */
- private static final class FakeTemplateContext implements TemplateContext {
- @Override
- public String lookupVariable(String name) throws ExpansionException {
- return String.format("$$(%s)", name);
- }
-
- @Override
- public String lookupFunction(String name, String param) throws ExpansionException {
- // Variables get recursively expanded, functions don't.
- return String.format("$(%s %s)", name, param);
- }
- }
-
- /**
* Builds a map: Label -> List of files from the given labels
*
* @param knownLabels List of known labels