use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class ExternallyBuiltApplePackageTest method sdkrootEnvironmentVariableIsSet.
@Test
public void sdkrootEnvironmentVariableIsSet() {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(this.resolver));
ExternallyBuiltApplePackage rule = new ExternallyBuiltApplePackage(params, config, new FakeSourcePath(bundleLocation), true);
resolver.addToIndex(rule);
ShellStep step = Iterables.getOnlyElement(Iterables.filter(rule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext()), AbstractGenruleStep.class));
assertThat(step.getEnvironmentVariables(TestExecutionContext.newInstance()), hasEntry("SDKROOT", DEFAULT_IPHONEOS_I386_PLATFORM.getAppleSdkPaths().getSdkPath().toString()));
}
use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class CoreDataModel 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 dataModelPath : dataModelPaths) {
stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
commandBuilder.addAll(momc.getCommandPrefix(context.getSourcePathResolver()));
commandBuilder.add("--sdkroot", sdkRoot.toString(), "--" + sdkName + "-deployment-target", minOSVersion, "--module", moduleName, context.getSourcePathResolver().getAbsolutePath(dataModelPath).toString(), getProjectFilesystem().resolve(outputDir).toString());
return commandBuilder.build();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
return momc.getEnvironment(context.getSourcePathResolver());
}
@Override
public String getShortName() {
return "momc";
}
});
}
buildableContext.recordArtifact(outputDir);
return stepsBuilder.build();
}
use of com.facebook.buck.shell.ShellStep in project buck by facebook.
the class GenAidlTest method testSimpleGenAidlRule.
@Test
public void testSimpleGenAidlRule() throws IOException {
ProjectFilesystem stubFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
Files.createDirectories(stubFilesystem.getRootPath().resolve("java/com/example/base"));
FakeSourcePath pathToAidl = new FakeSourcePath(stubFilesystem, "java/com/example/base/IWhateverService.aidl");
String importPath = Paths.get("java/com/example/base").toString();
BuildTarget target = BuildTargetFactory.newInstance(stubFilesystem.getRootPath(), "//java/com/example/base:IWhateverService");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(stubFilesystem).build();
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
GenAidl genAidlRule = new GenAidl(params, pathToAidl, importPath);
GenAidlDescription description = new GenAidlDescription();
assertEquals(Description.getBuildRuleType(GenAidlDescription.class), Description.getBuildRuleType(description));
assertTrue(genAidlRule.getProperties().is(ANDROID));
List<Step> steps = genAidlRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
final String pathToAidlExecutable = Paths.get("/usr/local/bin/aidl").toString();
final String pathToFrameworkAidl = Paths.get("/home/root/android/platforms/android-16/framework.aidl").toString();
final AndroidPlatformTarget androidPlatformTarget = createMock(AndroidPlatformTarget.class);
expect(androidPlatformTarget.getAidlExecutable()).andReturn(Paths.get(pathToAidlExecutable));
expect(androidPlatformTarget.getAndroidFrameworkIdlFile()).andReturn(Paths.get(pathToFrameworkAidl));
replay(androidPlatformTarget);
ExecutionContext executionContext = TestExecutionContext.newBuilder().setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatformTarget)).build();
assertEquals(executionContext.getAndroidPlatformTarget(), androidPlatformTarget);
Path outputDirectory = BuildTargets.getScratchPath(stubFilesystem, target, "__%s.aidl");
MakeCleanDirectoryStep mkdirStep = (MakeCleanDirectoryStep) steps.get(1);
assertEquals("gen_aidl() should make a directory at " + outputDirectory, outputDirectory, mkdirStep.getPath());
ShellStep aidlStep = (ShellStep) steps.get(2);
assertEquals("gen_aidl() should use the aidl binary to write .java files.", String.format("(cd %s && %s -p%s -I%s -o%s %s)", stubFilesystem.getRootPath(), pathToAidlExecutable, pathToFrameworkAidl, stubFilesystem.resolve(importPath), stubFilesystem.resolve(outputDirectory), pathToAidl.getRelativePath()), aidlStep.getDescription(executionContext));
assertEquals(5, steps.size());
verify(androidPlatformTarget);
}
Aggregations