use of com.facebook.buck.step.StepRunner in project buck by facebook.
the class SmartDexingStep method execute.
@Override
public StepExecutionResult execute(ExecutionContext context) throws InterruptedException {
try {
Multimap<Path, Path> outputToInputs = outputToInputsSupplier.get();
runDxCommands(context, outputToInputs);
if (secondaryOutputDir.isPresent()) {
removeExtraneousSecondaryArtifacts(secondaryOutputDir.get(), outputToInputs.keySet(), filesystem);
// Concatenate if solid compression is specified.
// create a mapping of the xzs file target and the dex.jar files that go into it
ImmutableMultimap.Builder<Path, Path> secondaryDexJarsMultimapBuilder = ImmutableMultimap.builder();
for (Path p : outputToInputs.keySet()) {
if (DexStore.XZS.matchesPath(p)) {
String[] matches = p.getFileName().toString().split("-");
Path output = p.getParent().resolve(matches[0].concat(SECONDARY_SOLID_DEX_EXTENSION));
secondaryDexJarsMultimapBuilder.put(output, p);
}
}
ImmutableMultimap<Path, Path> secondaryDexJarsMultimap = secondaryDexJarsMultimapBuilder.build();
if (!secondaryDexJarsMultimap.isEmpty()) {
for (Map.Entry<Path, Collection<Path>> entry : secondaryDexJarsMultimap.asMap().entrySet()) {
Path store = entry.getKey();
Collection<Path> secondaryDexJars = entry.getValue();
// Construct the output path for our solid blob and its compressed form.
Path secondaryBlobOutput = store.getParent().resolve("uncompressed.dex.blob");
Path secondaryCompressedBlobOutput = store;
// Concatenate the jars into a blob and compress it.
StepRunner stepRunner = new DefaultStepRunner();
Step concatStep = new ConcatStep(filesystem, ImmutableList.copyOf(secondaryDexJars), secondaryBlobOutput);
Step xzStep;
if (xzCompressionLevel.isPresent()) {
xzStep = new XzStep(filesystem, secondaryBlobOutput, secondaryCompressedBlobOutput, xzCompressionLevel.get().intValue());
} else {
xzStep = new XzStep(filesystem, secondaryBlobOutput, secondaryCompressedBlobOutput);
}
stepRunner.runStepForBuildTarget(context, concatStep, Optional.empty());
stepRunner.runStepForBuildTarget(context, xzStep, Optional.empty());
}
}
}
} catch (StepFailedException | IOException e) {
context.logError(e, "There was an error in smart dexing step.");
return StepExecutionResult.ERROR;
}
return StepExecutionResult.SUCCESS;
}
use of com.facebook.buck.step.StepRunner in project buck by facebook.
the class DefaultJavaLibraryTest method stubOutBuildContext.
@Before
public void stubOutBuildContext() {
ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot().toPath());
StepRunner stepRunner = createNiceMock(StepRunner.class);
JavaPackageFinder packageFinder = createNiceMock(JavaPackageFinder.class);
replay(packageFinder, stepRunner);
annotationScenarioGenPath = filesystem.resolve(filesystem.getBuckPaths().getAnnotationDir()).resolve("android/java/src/com/facebook/__fb_gen__").toAbsolutePath().toString();
}
Aggregations