use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class OcamlBuildStep method execute.
@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
if (hasGeneratedSources) {
StepExecutionResult genExecutionResult = generateSources(context, filesystem.getRootPath());
if (!genExecutionResult.isSuccess()) {
return genExecutionResult;
}
}
StepExecutionResult depToolExecutionResult = depToolStep.execute(context);
if (!depToolExecutionResult.isSuccess()) {
return depToolExecutionResult;
}
// OCaml requires module A to be present in command line to ocamlopt or ocamlc before
// module B if B depends on A. In OCaml circular dependencies are prohibited, so all
// dependency relations among modules form DAG. Topologically sorting this graph satisfies the
// requirement.
//
// To get the DAG we launch ocamldep tool which provides the direct dependency information, like
// module A depends on modules B, C, D.
ImmutableList<Path> sortedInput = sortDependency(depToolStep.getStdout(), ocamlContext.getSourcePathResolver().getAllAbsolutePaths(ocamlContext.getMLInput()));
ImmutableList.Builder<Path> nativeLinkerInputs = ImmutableList.builder();
if (!bytecodeOnly) {
StepExecutionResult mlCompileNativeExecutionResult = executeMLNativeCompilation(context, filesystem.getRootPath(), sortedInput, nativeLinkerInputs);
if (!mlCompileNativeExecutionResult.isSuccess()) {
return mlCompileNativeExecutionResult;
}
}
ImmutableList.Builder<Path> bytecodeLinkerInputs = ImmutableList.builder();
StepExecutionResult mlCompileBytecodeExecutionResult = executeMLBytecodeCompilation(context, filesystem.getRootPath(), sortedInput, bytecodeLinkerInputs);
if (!mlCompileBytecodeExecutionResult.isSuccess()) {
return mlCompileBytecodeExecutionResult;
}
ImmutableList.Builder<Path> cLinkerInputs = ImmutableList.builder();
StepExecutionResult cCompileExecutionResult = executeCCompilation(context, cLinkerInputs);
if (!cCompileExecutionResult.isSuccess()) {
return cCompileExecutionResult;
}
ImmutableList<Path> cObjects = cLinkerInputs.build();
if (!bytecodeOnly) {
nativeLinkerInputs.addAll(cObjects);
StepExecutionResult nativeLinkExecutionResult = executeNativeLinking(context, nativeLinkerInputs.build());
if (!nativeLinkExecutionResult.isSuccess()) {
return nativeLinkExecutionResult;
}
}
bytecodeLinkerInputs.addAll(cObjects);
StepExecutionResult bytecodeLinkExecutionResult = executeBytecodeLinking(context, bytecodeLinkerInputs.build());
if (!bytecodeLinkExecutionResult.isSuccess()) {
return bytecodeLinkExecutionResult;
}
if (!ocamlContext.isLibrary()) {
Step debugLauncher = new OcamlDebugLauncherStep(filesystem, resolver, new OcamlDebugLauncherStep.Args(ocamlContext.getOcamlDebug().get(), ocamlContext.getBytecodeOutput(), ocamlContext.getOcamlInput(), ocamlContext.getBytecodeIncludeFlags()));
return debugLauncher.execute(context);
} else {
return StepExecutionResult.SUCCESS;
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class LuaStandaloneBinary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
buildableContext.recordArtifact(output);
// Make sure the parent directory exists.
steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
// Delete any other pex that was there (when switching between pex styles).
steps.add(new RmStep(getProjectFilesystem(), output, RmStep.Mode.RECURSIVE));
SourcePathResolver resolver = context.getSourcePathResolver();
steps.add(new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected Optional<String> getStdin(ExecutionContext context) {
try {
return Optional.of(context.getObjectMapper().writeValueAsString(ImmutableMap.of("modules", Maps.transformValues(components.getModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "pythonModules", Maps.transformValues(components.getPythonModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "nativeLibraries", Maps.transformValues(components.getNativeLibraries(), Functions.compose(Object::toString, resolver::getAbsolutePath)))));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
ImmutableList.Builder<String> command = ImmutableList.builder();
command.addAll(builder.getCommandPrefix(resolver));
command.addAll(builderArgs);
command.add("--entry-point", mainModule);
command.add("--interpreter");
if (starter.isPresent()) {
command.add(resolver.getAbsolutePath(starter.get()).toString());
} else {
command.add(lua.getCommandPrefix(resolver).get(0));
}
command.add(getProjectFilesystem().resolve(output).toString());
return command.build();
}
@Override
public String getShortName() {
return "lua_package";
}
});
return steps.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class ExportFile method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
SourcePathResolver resolver = context.getSourcePathResolver();
// This file is copied rather than symlinked so that when it is included in an archive zip and
// unpacked on another machine, it is an ordinary file in both scenarios.
ImmutableList.Builder<Step> builder = ImmutableList.builder();
if (mode == ExportFileDescription.Mode.COPY) {
Path out = getCopiedPath();
builder.add(new MkdirStep(getProjectFilesystem(), out.getParent()));
builder.add(new RmStep(getProjectFilesystem(), out, RmStep.Mode.RECURSIVE));
if (resolver.getFilesystem(src).isDirectory(resolver.getRelativePath(src))) {
builder.add(CopyStep.forDirectory(getProjectFilesystem(), resolver.getAbsolutePath(src), out, CopyStep.DirectoryMode.CONTENTS_ONLY));
} else {
builder.add(CopyStep.forFile(getProjectFilesystem(), resolver.getAbsolutePath(src), out));
}
buildableContext.recordArtifact(out);
}
return builder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class Genrule method getBuildSteps.
@Override
@VisibleForTesting
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> commands = ImmutableList.builder();
// Make sure that the directory to contain the output file exists, deleting any pre-existing
// ones. Rules get output to a directory named after the base path, so we don't want to nuke
// the entire directory.
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToOutDirectory));
// Delete the old temp directory
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToTmpDirectory));
// Create a directory to hold all the source files.
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToSrcDirectory));
addSymlinkCommands(context, commands);
// Create a shell command that corresponds to this.cmd.
if (this.isWorkerGenrule) {
commands.add(createWorkerShellStep(context));
} else {
commands.add(createGenruleStep(context));
}
if (MorePaths.getFileExtension(pathToOutFile).equals("zip")) {
commands.add(new ZipScrubberStep(getProjectFilesystem(), pathToOutFile));
}
buildableContext.recordArtifact(pathToOutFile);
return commands.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class RustCompileRule method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) {
Path output = getOutput();
buildableContext.recordArtifact(output);
SourcePathResolver resolver = buildContext.getSourcePathResolver();
return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), scratchDir), new SymlinkFilesIntoDirectoryStep(getProjectFilesystem(), getProjectFilesystem().getRootPath(), srcs.stream().map(resolver::getRelativePath).collect(MoreCollectors.toImmutableList()), scratchDir), new MakeCleanDirectoryStep(getProjectFilesystem(), getOutputDir(getBuildTarget(), getProjectFilesystem())), new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList<String> linkerCmd = linker.getCommandPrefix(resolver);
ImmutableList.Builder<String> cmd = ImmutableList.builder();
Path src = scratchDir.resolve(resolver.getRelativePath(rootModule));
cmd.addAll(compiler.getCommandPrefix(resolver)).addAll(executionContext.getAnsi().isAnsiTerminal() ? ImmutableList.of("--color=always") : ImmutableList.of()).add(String.format("-Clinker=%s", linkerCmd.get(0))).addAll(processLinkerArgs(linkerCmd.subList(1, linkerCmd.size()))).addAll(processLinkerArgs(Arg.stringify(linkerArgs, buildContext.getSourcePathResolver()))).addAll(Arg.stringify(args, buildContext.getSourcePathResolver())).add("-o", output.toString()).add(src.toString());
return cmd.build();
}
/*
* Make sure all stderr output from rustc is emitted, since its either a warning or an
* error. In general Rust code should have zero warnings, or all warnings as errors.
* Regardless, respect requests for silence.
*/
@Override
protected boolean shouldPrintStderr(Verbosity verbosity) {
return !verbosity.isSilent();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext context) {
return compiler.getEnvironment(buildContext.getSourcePathResolver());
}
@Override
public String getShortName() {
return "rust-build";
}
});
}
Aggregations