use of com.google.devtools.build.lib.analysis.actions.CustomCommandLine in project bazel by bazelbuild.
the class CustomCommandLineTest method testArtifactJoinStringArgs.
@Test
public void testArtifactJoinStringArgs() {
CustomCommandLine cl = CustomCommandLine.builder().addJoinStrings("--path", ":", ImmutableList.of("foo", "bar")).build();
assertEquals(ImmutableList.of("--path", "foo:bar"), cl.arguments());
}
use of com.google.devtools.build.lib.analysis.actions.CustomCommandLine in project bazel by bazelbuild.
the class CustomCommandLineTest method testTreeFileArtifactExecPathWithTemplateArgs.
@Test
public void testTreeFileArtifactExecPathWithTemplateArgs() {
Artifact treeArtifact = createTreeArtifact("myArtifact/treeArtifact1");
CustomCommandLine commandLineTemplate = CustomCommandLine.builder().addPlaceholderTreeArtifactFormattedExecPath("path:%s", treeArtifact).build();
TreeFileArtifact treeFileArtifact = createTreeFileArtifact(treeArtifact, "children/child1");
CustomCommandLine commandLine = commandLineTemplate.evaluateTreeFileArtifacts(ImmutableList.of(treeFileArtifact));
assertThat(commandLine.arguments()).containsExactly("path:myArtifact/treeArtifact1/children/child1");
}
use of com.google.devtools.build.lib.analysis.actions.CustomCommandLine in project bazel by bazelbuild.
the class CustomCommandLineTest method testLabelArgs.
@Test
public void testLabelArgs() throws LabelSyntaxException {
CustomCommandLine cl = CustomCommandLine.builder().add(Label.parseAbsolute("//a:b")).build();
assertEquals(ImmutableList.of("//a:b"), cl.arguments());
}
use of com.google.devtools.build.lib.analysis.actions.CustomCommandLine in project bazel by bazelbuild.
the class CustomCommandLineTest method testCustomArgs.
@Test
public void testCustomArgs() {
CustomCommandLine cl = CustomCommandLine.builder().add(new CustomArgv() {
@Override
public String argv() {
return "--arg";
}
}).build();
assertEquals(ImmutableList.of("--arg"), cl.arguments());
}
use of com.google.devtools.build.lib.analysis.actions.CustomCommandLine in project bazel by bazelbuild.
the class DexArchiveAspect method createDesugarAction.
private static Artifact createDesugarAction(RuleContext ruleContext, String desugarPrereqName, Artifact jar, ImmutableList<Artifact> bootclasspath, NestedSet<Artifact> classpath, Artifact result) {
CustomCommandLine args = new CustomCommandLine.Builder().addExecPath("--input", jar).addExecPath("--output", result).addBeforeEachExecPath("--classpath_entry", classpath).addBeforeEachExecPath("--bootclasspath_entry", bootclasspath).build();
// Just use params file, since classpaths can get long
Artifact paramFile = ruleContext.getDerivedArtifact(ParameterFile.derivePath(result.getRootRelativePath()), result.getRoot());
ruleContext.registerAction(new ParameterFileWriteAction(ruleContext.getActionOwner(), paramFile, args, ParameterFile.ParameterFileType.UNQUOTED, ISO_8859_1));
ruleContext.registerAction(new SpawnAction.Builder().setExecutable(ruleContext.getExecutablePrerequisite(desugarPrereqName, Mode.HOST)).addArgument("@" + paramFile.getExecPathString()).addInput(jar).addInput(paramFile).addInputs(bootclasspath).addTransitiveInputs(classpath).addOutput(result).setMnemonic("Desugar").setProgressMessage("Desugaring " + jar.prettyPrint() + " for Android").build(ruleContext));
return result;
}
Aggregations