use of com.facebook.buck.step.Step in project buck by facebook.
the class ReactNativeBundle method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// Generate the normal outputs.
final Path jsOutput = jsOutputDir.resolve(bundleName);
final Path depFile = getPathToDepFile(getBuildTarget(), getProjectFilesystem());
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), jsOutput.getParent()));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), resource));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), sourceMapOutputPath.getParent()));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), depFile.getParent()));
appendWorkerSteps(steps, context.getSourcePathResolver(), jsOutput, sourceMapOutputPath, depFile);
buildableContext.recordArtifact(jsOutputDir);
buildableContext.recordArtifact(resource);
buildableContext.recordArtifact(sourceMapOutputPath.getParent());
return steps.build();
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class JsBundle method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
final SourcePath jsOutputDir = getSourcePathToOutput();
final SourcePath sourceMapFile = getSourcePathToSourceMap();
String jobArgs = Stream.concat(Stream.of("bundle", JsFlavors.bundleJobArgs(getBuildTarget().getFlavors()), JsUtil.resolveMapJoin(libraries, sourcePathResolver, p -> "--lib " + p), String.format("--sourcemap %s", sourcePathResolver.getAbsolutePath(sourceMapFile)), String.format("--out %s/%s", sourcePathResolver.getAbsolutePath(jsOutputDir), bundleName)), entryPoints.stream()).filter(s -> !s.isEmpty()).collect(Collectors.joining(" "));
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(jsOutputDir));
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(sourceMapFile));
return ImmutableList.of(new RmStep(getProjectFilesystem(), sourcePathResolver.getAbsolutePath(getOutputRoot())), new MkdirStep(getProjectFilesystem(), sourcePathResolver.getAbsolutePath(jsOutputDir)), new MkdirStep(getProjectFilesystem(), sourcePathResolver.getAbsolutePath(sourceMapFile).getParent()), JsUtil.workerShellStep(worker, jobArgs, getBuildTarget(), sourcePathResolver, getProjectFilesystem()));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class JsLibrary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
final Path outputPath = sourcePathResolver.getAbsolutePath(getSourcePathToOutput());
final String jobArgs = String.format("library %s --out %s %s", JsUtil.resolveMapJoin(libraryDependencies, sourcePathResolver, p -> "--lib " + p), outputPath, JsUtil.resolveMapJoin(sources, sourcePathResolver, Path::toString));
return ImmutableList.of(new RmStep(getProjectFilesystem(), outputPath), JsUtil.workerShellStep(worker, jobArgs, getBuildTarget(), sourcePathResolver, getProjectFilesystem()));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class AndroidBinaryTest method testDexingCommandWithIntraDexReorder.
@Test
public void testDexingCommandWithIntraDexReorder() throws Exception {
SourcePath reorderTool = new FakeSourcePath("/tools#reorder_tool");
SourcePath reorderData = new FakeSourcePath("/tools#reorder_data");
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
AndroidBinary splitDexRule = AndroidBinaryBuilder.createBuilder(BuildTargetFactory.newInstance("//:fbandroid_with_dash_debug_fbsign")).setManifest(new FakeSourcePath("AndroidManifest.xml")).setKeystore(addKeystoreRule(ruleResolver).getBuildTarget()).setShouldSplitDex(true).setLinearAllocHardLimit(0).setPrimaryDexScenarioOverflowAllowed(true).setDexCompression(DexStore.JAR).setIntraDexReorderResources(true, reorderTool, reorderData).build(ruleResolver);
Set<Path> classpath = Sets.newHashSet();
ImmutableSet.Builder<Path> secondaryDexDirectories = ImmutableSet.builder();
ImmutableList.Builder<Step> commandsBuilder = ImmutableList.builder();
Path primaryDexPath = splitDexRule.getProjectFilesystem().getBuckPaths().getScratchDir().resolve(".dex/classes.dex");
splitDexRule.addDexingSteps(classpath, Suppliers.ofInstance(ImmutableMap.of()), secondaryDexDirectories, commandsBuilder, primaryDexPath, Optional.of(reorderTool), Optional.of(reorderData), /* additionalDexStoreToJarPathMap */
ImmutableMultimap.of(), new SourcePathResolver(new SourcePathRuleFinder(ruleResolver)));
assertEquals("Expected 2 new assets paths (one for metadata.txt and the other for the " + "secondary zips)", 2, secondaryDexDirectories.build().size());
List<Step> steps = commandsBuilder.build();
assertCommandsInOrder(steps, ImmutableList.of(SplitZipStep.class, SmartDexingStep.class));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class AndroidBinaryTest method testDexingCommand.
@Test
public void testDexingCommand() throws Exception {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
AndroidBinary splitDexRule = AndroidBinaryBuilder.createBuilder(BuildTargetFactory.newInstance("//:fbandroid_with_dash_debug_fbsign")).setManifest(new FakeSourcePath("AndroidManifest.xml")).setKeystore(addKeystoreRule(ruleResolver).getBuildTarget()).setShouldSplitDex(true).setLinearAllocHardLimit(0).setPrimaryDexScenarioOverflowAllowed(true).setDexCompression(DexStore.JAR).build(ruleResolver);
Set<Path> classpath = Sets.newHashSet();
ImmutableSet.Builder<Path> secondaryDexDirectories = ImmutableSet.builder();
ImmutableList.Builder<Step> commandsBuilder = ImmutableList.builder();
Path primaryDexPath = splitDexRule.getProjectFilesystem().getBuckPaths().getScratchDir().resolve(".dex/classes.dex");
splitDexRule.addDexingSteps(classpath, Suppliers.ofInstance(ImmutableMap.of()), secondaryDexDirectories, commandsBuilder, primaryDexPath, Optional.empty(), Optional.empty(), /* additionalDexStoreToJarPathMap */
ImmutableMultimap.of(), new SourcePathResolver(new SourcePathRuleFinder(ruleResolver)));
assertEquals("Expected 2 new assets paths (one for metadata.txt and the other for the " + "secondary zips)", 2, secondaryDexDirectories.build().size());
List<Step> steps = commandsBuilder.build();
assertCommandsInOrder(steps, ImmutableList.of(SplitZipStep.class, SmartDexingStep.class));
}
Aggregations