Search in sources :

Example 6 with ParameterFileWriteAction

use of com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction in project bazel by bazelbuild.

the class DexArchiveAspect method createDexArchiveAction.

/**
   * Creates a dexbuilder action with the given input, output, and flags.  Flags must have been
   * filtered and normalized to a set that the dexbuilder tool can understand.
   */
private static Artifact createDexArchiveAction(RuleContext ruleContext, String dexbuilderPrereq, Artifact jar, Set<String> incrementalDexopts, Artifact dexArchive) {
    // Write command line arguments into a params file for compatibility with WorkerSpawnStrategy
    CustomCommandLine args = new CustomCommandLine.Builder().addExecPath("--input_jar", jar).addExecPath("--output_zip", dexArchive).add(incrementalDexopts).build();
    Artifact paramFile = ruleContext.getDerivedArtifact(ParameterFile.derivePath(dexArchive.getRootRelativePath()), dexArchive.getRoot());
    ruleContext.registerAction(new ParameterFileWriteAction(ruleContext.getActionOwner(), paramFile, args, ParameterFile.ParameterFileType.UNQUOTED, ISO_8859_1));
    SpawnAction.Builder dexbuilder = new SpawnAction.Builder().setExecutable(ruleContext.getExecutablePrerequisite(dexbuilderPrereq, Mode.HOST)).addArgument("@" + paramFile.getExecPathString()).addInput(jar).addInput(paramFile).addOutput(dexArchive).setMnemonic("DexBuilder").setExecutionInfo(ImmutableMap.of("supports-workers", "1")).setProgressMessage("Dexing " + jar.prettyPrint() + " with applicable dexopts " + incrementalDexopts);
    ruleContext.registerAction(dexbuilder.build(ruleContext));
    return dexArchive;
}
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)

Example 7 with ParameterFileWriteAction

use of com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction in project bazel by bazelbuild.

the class CompilationSupport method registerObjFilelistAction.

/**
   * Registers an action that writes given set of object files to the given objList. This objList is
   * suitable to signal symbols to archive in a libtool archiving invocation.
   */
protected CompilationSupport registerObjFilelistAction(Iterable<Artifact> objFiles, Artifact objList) {
    ImmutableSet<Artifact> dedupedObjFiles = ImmutableSet.copyOf(objFiles);
    CustomCommandLine.Builder objFilesToLinkParam = new CustomCommandLine.Builder();
    ImmutableList.Builder<Artifact> treeObjFiles = new ImmutableList.Builder<>();
    for (Artifact objFile : dedupedObjFiles) {
        // files properly.
        if (objFile.isTreeArtifact()) {
            treeObjFiles.add(objFile);
            objFilesToLinkParam.addExpandedTreeArtifactExecPaths(objFile);
        } else {
            objFilesToLinkParam.addPath(objFile.getExecPath());
        }
    }
    ruleContext.registerAction(new ParameterFileWriteAction(ruleContext.getActionOwner(), treeObjFiles.build(), objList, objFilesToLinkParam.build(), ParameterFile.ParameterFileType.UNQUOTED, ISO_8859_1));
    return this;
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) ParameterFileWriteAction(com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction) ImmutableList(com.google.common.collect.ImmutableList) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) Builder(com.google.devtools.build.lib.rules.objc.XcodeProvider.Builder) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)7 ParameterFileWriteAction (com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction)7 CustomCommandLine (com.google.devtools.build.lib.analysis.actions.CustomCommandLine)6 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)4 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)4 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableSet (com.google.common.collect.ImmutableSet)1 Builder (com.google.common.collect.ImmutableSet.Builder)1 Action (com.google.devtools.build.lib.actions.Action)1 Builder (com.google.devtools.build.lib.analysis.Runfiles.Builder)1 IterablesChain (com.google.devtools.build.lib.collect.IterablesChain)1 Variables (com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables)1 SequenceBuilder (com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.SequenceBuilder)1 VariablesExtension (com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.VariablesExtension)1 LibraryToLink (com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink)1 Jvm (com.google.devtools.build.lib.rules.java.Jvm)1 Builder (com.google.devtools.build.lib.rules.objc.XcodeProvider.Builder)1 ProtoCompileActionBuilder (com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder)1 ArrayList (java.util.ArrayList)1