From 106f9e95c3d88209c5f1873b9718dc63ca1ad6f3 Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Mon, 16 Jan 2017 14:01:03 +0000 Subject: Delete the cmd_helper.template function. cmd_helper is deprecated and planned for deletion. RELNOTES[INC]: Removed the cmd_helper.template function. The function was equivalent to: def template(items, template): return [template.format(path = i.path, short_path = i.short_path) for i in items] -- PiperOrigin-RevId: 144628429 MOS_MIGRATED_REVID=144628429 --- .../build/lib/rules/SkylarkCommandLine.java | 36 ++-------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/SkylarkCommandLine.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkCommandLine.java index 6267493cd5..3237ec8b14 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkCommandLine.java @@ -14,8 +14,6 @@ package com.google.devtools.build.lib.rules; -import com.google.common.base.Function; -import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.skylarkinterface.Param; @@ -23,8 +21,6 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.skylarkinterface.SkylarkSignature; import com.google.devtools.build.lib.syntax.BuiltinFunction; -import com.google.devtools.build.lib.syntax.Environment; -import com.google.devtools.build.lib.syntax.SkylarkList.MutableList; import com.google.devtools.build.lib.syntax.SkylarkNestedSet; import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor; @@ -33,7 +29,7 @@ import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor; name = "cmd_helper", namespace = true, category = SkylarkModuleCategory.BUILTIN, - doc = "Module for creating memory efficient command lines." + doc = "Deprecated. Module for creating memory efficient command lines." ) public class SkylarkCommandLine { @@ -42,7 +38,7 @@ public class SkylarkCommandLine { objectType = SkylarkCommandLine.class, returnType = String.class, doc = - "Creates a single command line argument joining the paths of a set " + "Deprecated. Creates a single command line argument joining the paths of a set " + "of files on the separator string.", parameters = { @Param(name = "separator", type = String.class, doc = "the separator string to join on."), @@ -63,34 +59,6 @@ public class SkylarkCommandLine { } }; - // TODO(bazel-team): this method should support sets of objects and substitute all struct fields. - @SkylarkSignature(name = "template", - doc = "Transforms a set of files to a list of strings using the template string.", - objectType = SkylarkCommandLine.class, - returnType = MutableList.class, - parameters = { - @Param(name = "items", type = SkylarkNestedSet.class, generic1 = Artifact.class, - doc = "The set of structs to transform."), - @Param(name = "template", type = String.class, - doc = "The template to use for the transformation, %{path} and " - + "%{short_path} being substituted with the corresponding fields of each" - + " file.")}, - useEnvironment = true) - private static BuiltinFunction template = new BuiltinFunction("template") { - public MutableList invoke(final SkylarkNestedSet items, final String template, - Environment env) { - return new MutableList(Iterables.transform(items, new Function() { - @Override - public String apply(Object input) { - Artifact artifact = (Artifact) input; - return template - .replace("%{path}", artifact.getExecPathString()) - .replace("%{short_path}", artifact.getRootRelativePathString()); - } - }), env); - } - }; - static { SkylarkSignatureProcessor.configureSkylarkFunctions(SkylarkCommandLine.class); } -- cgit v1.2.3