Search in sources :

Example 6 with CustomCommandLine

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());
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) Test(org.junit.Test)

Example 7 with CustomCommandLine

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");
}
Also used : TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) Test(org.junit.Test)

Example 8 with CustomCommandLine

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());
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) Test(org.junit.Test)

Example 9 with CustomCommandLine

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());
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) CustomArgv(com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomArgv) Test(org.junit.Test)

Example 10 with CustomCommandLine

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;
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) SpawnAction(com.google.devtools.build.lib.analysis.actions.SpawnAction) ParameterFileWriteAction(com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

CustomCommandLine (com.google.devtools.build.lib.analysis.actions.CustomCommandLine)28 Test (org.junit.Test)22 Artifact (com.google.devtools.build.lib.actions.Artifact)6 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)5 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)3 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)3 ParameterFileWriteAction (com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction)3 ToolchainInvocation (com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.ToolchainInvocation)3 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)2 LazyString (com.google.devtools.build.lib.util.LazyString)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FilesToRunProvider (com.google.devtools.build.lib.analysis.FilesToRunProvider)1 CustomArgv (com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomArgv)1 CustomMultiArgv (com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomMultiArgv)1 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)1 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)1 Platform (com.google.devtools.build.lib.rules.apple.Platform)1 DotdFile (com.google.devtools.build.lib.rules.cpp.CppCompileAction.DotdFile)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 HashSet (java.util.HashSet)1