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;
}
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;
}
Aggregations