use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class JavaSourceJar method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
JavaPackageFinder packageFinder = context.getJavaPackageFinder();
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
steps.add(new RmStep(getProjectFilesystem(), output));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), temp));
Set<Path> seenPackages = Sets.newHashSet();
for (Path source : context.getSourcePathResolver().filterInputsToCompareToOutput(sources)) {
Path packageFolder = packageFinder.findJavaPackageFolder(source);
Path packageDir = temp.resolve(packageFolder);
if (seenPackages.add(packageDir)) {
steps.add(new MkdirStep(getProjectFilesystem(), packageDir));
}
steps.add(CopyStep.forFile(getProjectFilesystem(), source, packageDir.resolve(source.getFileName())));
}
steps.add(new ZipStep(getProjectFilesystem(), output, ImmutableSet.of(), /* junk paths */
false, DEFAULT_COMPRESSION_LEVEL, temp));
buildableContext.recordArtifact(output);
return steps.build();
}
use of com.facebook.buck.step.fs.MkdirStep 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.fs.MkdirStep in project buck by facebook.
the class AppleBundle method copyBinaryIntoBundle.
private void copyBinaryIntoBundle(ImmutableList.Builder<Step> stepsBuilder, Path binaryOutputPath) {
stepsBuilder.add(new MkdirStep(getProjectFilesystem(), bundleRoot.resolve(this.destinations.getExecutablesPath())));
stepsBuilder.add(CopyStep.forFile(getProjectFilesystem(), binaryOutputPath, bundleBinaryPath));
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class AppleBundle method addStepsToCopyExtensionBundlesDependencies.
private void addStepsToCopyExtensionBundlesDependencies(SourcePathResolver resolver, ImmutableList.Builder<Step> stepsBuilder, ImmutableList.Builder<Path> codeSignOnCopyPathsBuilder) {
for (Map.Entry<SourcePath, String> entry : extensionBundlePaths.entrySet()) {
Path srcPath = resolver.getAbsolutePath(entry.getKey());
Path destPath = bundleRoot.resolve(entry.getValue());
stepsBuilder.add(new MkdirStep(getProjectFilesystem(), destPath));
stepsBuilder.add(CopyStep.forDirectory(getProjectFilesystem(), srcPath, destPath, CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
if (srcPath.toString().endsWith("." + FRAMEWORK_EXTENSION)) {
codeSignOnCopyPathsBuilder.add(destPath.resolve(srcPath.getFileName()));
}
}
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class DexProducedFromJavaLibrary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new RmStep(getProjectFilesystem(), getPathToDex()));
// Make sure that the buck-out/gen/ directory exists for this.buildTarget.
steps.add(new MkdirStep(getProjectFilesystem(), getPathToDex().getParent()));
// If there are classes, run dx.
final ImmutableSortedMap<String, HashCode> classNamesToHashes = javaLibrary.getClassNamesToHashes();
final boolean hasClassesToDx = !classNamesToHashes.isEmpty();
final Supplier<Integer> weightEstimate;
@Nullable final DxStep dx;
if (hasClassesToDx) {
Path pathToOutputFile = context.getSourcePathResolver().getAbsolutePath(javaLibrarySourcePath);
EstimateDexWeightStep estimate = new EstimateDexWeightStep(getProjectFilesystem(), pathToOutputFile);
steps.add(estimate);
weightEstimate = estimate;
// To be conservative, use --force-jumbo for these intermediate .dex files so that they can be
// merged into a final classes.dex that uses jumbo instructions.
dx = new DxStep(getProjectFilesystem(), getPathToDex(), Collections.singleton(pathToOutputFile), EnumSet.of(DxStep.Option.USE_CUSTOM_DX_IF_AVAILABLE, DxStep.Option.RUN_IN_PROCESS, DxStep.Option.NO_OPTIMIZE, DxStep.Option.FORCE_JUMBO));
steps.add(dx);
// The `DxStep` delegates to android tools to build a ZIP with timestamps in it, making
// the output non-deterministic. So use an additional scrubbing step to zero these out.
steps.add(new ZipScrubberStep(getProjectFilesystem(), getPathToDex()));
} else {
dx = null;
weightEstimate = Suppliers.ofInstance(0);
}
// Run a step to record artifacts and metadata. The values recorded depend upon whether dx was
// run.
String stepName = hasClassesToDx ? "record_dx_success" : "record_empty_dx";
AbstractExecutionStep recordArtifactAndMetadataStep = new AbstractExecutionStep(stepName) {
@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException {
if (hasClassesToDx) {
buildableContext.recordArtifact(getPathToDex());
@Nullable Collection<String> referencedResources = dx.getResourcesReferencedInCode();
if (referencedResources != null) {
buildableContext.addMetadata(REFERENCED_RESOURCES, Ordering.natural().immutableSortedCopy(referencedResources));
}
}
buildableContext.addMetadata(WEIGHT_ESTIMATE, String.valueOf(weightEstimate.get()));
// Record the classnames to hashes map.
buildableContext.addMetadata(CLASSNAMES_TO_HASHES, context.getObjectMapper().writeValueAsString(Maps.transformValues(classNamesToHashes, Object::toString)));
return StepExecutionResult.SUCCESS;
}
};
steps.add(recordArtifactAndMetadataStep);
return steps.build();
}
Aggregations