use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class SceneKitAssets method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
for (SourcePath inputPath : sceneKitAssetsPaths) {
final Path absoluteInputPath = context.getSourcePathResolver().getAbsolutePath(inputPath);
if (copySceneKitAssets.isPresent()) {
stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
commandBuilder.addAll(copySceneKitAssets.get().getCommandPrefix(context.getSourcePathResolver()));
commandBuilder.add(absoluteInputPath.toString(), "-o", getProjectFilesystem().resolve(outputDir).resolve(absoluteInputPath.getFileName()).toString(), "--target-platform=" + sdkName, "--target-version=" + minOSVersion);
return commandBuilder.build();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
return copySceneKitAssets.get().getEnvironment(context.getSourcePathResolver());
}
@Override
public String getShortName() {
return "copy-scenekit-assets";
}
});
} else {
stepsBuilder.add(CopyStep.forDirectory(getProjectFilesystem(), absoluteInputPath, outputDir, CopyStep.DirectoryMode.CONTENTS_ONLY));
}
}
buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
return stepsBuilder.build();
}
use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class MultiarchFileTest method descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile.
@SuppressWarnings({ "unchecked" })
@Test
public void descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64");
BuildTarget sandboxTarget = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64,sandbox");
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(new AppleLibraryBuilder(sandboxTarget).build()), new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRule multiarchRule = nodeBuilderFactory.getNodeBuilder(target).build(resolver, filesystem);
assertThat(multiarchRule, instanceOf(MultiarchFile.class));
ImmutableList<Step> steps = multiarchRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
ShellStep step = Iterables.getLast(Iterables.filter(steps, ShellStep.class));
ExecutionContext executionContext = TestExecutionContext.newInstance();
ImmutableList<String> command = step.getShellCommand(executionContext);
assertThat(command, Matchers.contains(endsWith("lipo"), equalTo("-create"), equalTo("-output"), containsString("foo/thing#"), containsString("/thing#"), containsString("/thing#")));
}
use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class HaskellCompileRule method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) {
buildableContext.recordArtifact(getObjectDir());
buildableContext.recordArtifact(getInterfaceDir());
buildableContext.recordArtifact(getStubDir());
return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), getObjectDir()), new MakeCleanDirectoryStep(getProjectFilesystem(), getInterfaceDir()), new MakeCleanDirectoryStep(getProjectFilesystem(), getStubDir()), new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext context) {
return ImmutableMap.<String, String>builder().putAll(super.getEnvironmentVariables(context)).putAll(compiler.getEnvironment(buildContext.getSourcePathResolver())).build();
}
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
SourcePathResolver resolver = buildContext.getSourcePathResolver();
return ImmutableList.<String>builder().addAll(compiler.getCommandPrefix(resolver)).addAll(flags).add("-no-link").addAll(picType == CxxSourceRuleFactory.PicType.PIC ? ImmutableList.of("-dynamic", "-fPIC", "-hisuf", "dyn_hi") : ImmutableList.of()).addAll(MoreIterables.zipAndConcat(Iterables.cycle("-main-is"), OptionalCompat.asSet(main))).addAll(getPackageNameArgs()).addAll(getPreprocessorFlags(buildContext.getSourcePathResolver())).add("-odir", getProjectFilesystem().resolve(getObjectDir()).toString()).add("-hidir", getProjectFilesystem().resolve(getInterfaceDir()).toString()).add("-stubdir", getProjectFilesystem().resolve(getStubDir()).toString()).add("-i" + includes.stream().map(resolver::getAbsolutePath).map(Object::toString).collect(Collectors.joining(":"))).addAll(getPackageArgs(buildContext.getSourcePathResolver())).addAll(sources.getSourcePaths().stream().map(resolver::getAbsolutePath).map(Object::toString).iterator()).build();
}
@Override
public String getShortName() {
return "haskell-compile";
}
});
}
use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class GwtBinary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// Create a clean directory where the .zip file will be written.
Path workingDirectory = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()).getParent();
ProjectFilesystem projectFilesystem = getProjectFilesystem();
steps.add(new MakeCleanDirectoryStep(projectFilesystem, workingDirectory));
// Write the deploy files into a separate directory so that the generated .zip is smaller.
final Path deployDirectory = workingDirectory.resolve("deploy");
steps.add(new MkdirStep(projectFilesystem, deployDirectory));
Step javaStep = new ShellStep(projectFilesystem.getRootPath()) {
@Override
public String getShortName() {
return "gwt-compile";
}
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> javaArgsBuilder = ImmutableList.builder();
javaArgsBuilder.add(javaRuntimeLauncher.getCommand());
javaArgsBuilder.add("-Dgwt.normalizeTimestamps=true");
javaArgsBuilder.addAll(vmArgs);
javaArgsBuilder.add("-classpath", Joiner.on(File.pathSeparator).join(Iterables.transform(getClasspathEntries(context.getSourcePathResolver()), getProjectFilesystem()::resolve)), GWT_COMPILER_CLASS, "-war", context.getSourcePathResolver().getAbsolutePath(getSourcePathToOutput()).toString(), "-style", style.name(), "-optimize", String.valueOf(optimize), "-localWorkers", String.valueOf(localWorkers), "-deploy", getProjectFilesystem().resolve(deployDirectory).toString());
if (draftCompile) {
javaArgsBuilder.add("-draftCompile");
}
if (strict) {
javaArgsBuilder.add("-strict");
}
javaArgsBuilder.addAll(experimentalArgs);
javaArgsBuilder.addAll(modules);
final ImmutableList<String> javaArgs = javaArgsBuilder.build();
return javaArgs;
}
};
steps.add(javaStep);
buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
return steps.build();
}
use of com.facebook.buck.shell.ShellStep 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();
}
Aggregations