use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class ReDexStepTest method constructorArgsAreUsedToCreateShellCommand.
@Test
public void constructorArgsAreUsedToCreateShellCommand() {
Path workingDirectory = Paths.get("/where/the/code/is");
List<String> redexBinaryArgs = ImmutableList.of("/usr/bin/redex");
Map<String, String> redexEnvironmentVariables = ImmutableMap.of("REDEX_DEBUG", "1");
Path inputApkPath = Paths.get("buck-out/gen/app.apk.zipalign");
Path outputApkPath = Paths.get("buck-out/gen/app.apk");
Path keystorePath = Paths.get("keystores/debug.keystore");
KeystoreProperties keystoreProperties = new KeystoreProperties(keystorePath, "storepass", "keypass", "alias");
Supplier<KeystoreProperties> keystorePropertiesSupplier = Suppliers.ofInstance(keystoreProperties);
Path redexConfigPath = Paths.get("redex/redex-config.json");
Optional<Path> redexConfig = Optional.of(redexConfigPath);
ImmutableList<Arg> redexExtraArgs = ImmutableList.of(StringArg.of("foo"), StringArg.of("bar"));
Path proguardMap = Paths.get("buck-out/gen/app/__proguard__/mapping.txt");
Path proguardConfig = Paths.get("app.proguard.config");
Path seeds = Paths.get("buck-out/gen/app/__proguard__/seeds.txt");
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
ReDexStep redex = new ReDexStep(workingDirectory, redexBinaryArgs, redexEnvironmentVariables, inputApkPath, outputApkPath, keystorePropertiesSupplier, redexConfig, redexExtraArgs, proguardMap, proguardConfig, seeds, pathResolver);
assertEquals("redex", redex.getShortName());
AndroidPlatformTarget androidPlatform = EasyMock.createMock(AndroidPlatformTarget.class);
Path sdkDirectory = Paths.get("/Users/user/android-sdk-macosx");
EasyMock.expect(androidPlatform.getSdkDirectory()).andReturn(Optional.of(sdkDirectory));
EasyMock.replay(androidPlatform);
ExecutionContext context = TestExecutionContext.newBuilder().setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatform)).build();
assertEquals(ImmutableMap.of("ANDROID_SDK", sdkDirectory.toString(), "REDEX_DEBUG", "1"), redex.getEnvironmentVariables(context));
EasyMock.verify(androidPlatform);
assertEquals(ImmutableList.of("/usr/bin/redex", "--config", redexConfigPath.toString(), "--sign", "--keystore", keystorePath.toString(), "--keyalias", "alias", "--keypass", "keypass", "--proguard-map", proguardMap.toString(), "-P", proguardConfig.toString(), "--keep", seeds.toString(), "--out", outputApkPath.toString(), "foo", "bar", inputApkPath.toString()), redex.getShellCommandInternal(context));
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class ExternallyBuiltApplePackageTest method outputContainsCorrectExtension.
@Test
public void outputContainsCorrectExtension() {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(this.resolver));
ExternallyBuiltApplePackage rule = new ExternallyBuiltApplePackage(params, config, new FakeSourcePath("Fake/Bundle/Location"), true);
resolver.addToIndex(rule);
assertThat(pathResolver.getRelativePath(Preconditions.checkNotNull(rule.getSourcePathToOutput())).toString(), endsWith(".api"));
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class ExternallyBuiltApplePackageTest method commandContainsCorrectCommand.
@Test
public void commandContainsCorrectCommand() {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(this.resolver));
ExternallyBuiltApplePackage rule = new ExternallyBuiltApplePackage(params, config, new FakeSourcePath("Fake/Bundle/Location"), true);
resolver.addToIndex(rule);
AbstractGenruleStep step = Iterables.getOnlyElement(Iterables.filter(rule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext()), AbstractGenruleStep.class));
assertThat(step.getScriptFileContents(TestExecutionContext.newInstance()), is(equalTo("echo $SDKROOT $OUT")));
}
use of com.facebook.buck.rules.SourcePathResolver 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.rules.SourcePathResolver in project buck by facebook.
the class AppleCxxPlatformsTest method watchOSSdkPathsBuiltFromDirectory.
@Test
public void watchOSSdkPathsBuiltFromDirectory() throws Exception {
AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/WatchOS.platform")).setSdkPath(Paths.get("Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk")).build();
AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.WATCHOS).setName("watchos2.0").setVersion("2.0").setToolchains(ImmutableList.of(toolchain)).build();
ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/ar")).build();
AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "2.0", "armv7k", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
assertEquals(ImmutableList.of("usr/bin/actool"), appleCxxPlatform.getActool().getCommandPrefix(resolver));
assertEquals(ImmutableList.of("usr/bin/ibtool"), appleCxxPlatform.getIbtool().getCommandPrefix(resolver));
assertEquals(ImmutableList.of("usr/bin/lldb"), appleCxxPlatform.getLldb().getCommandPrefix(resolver));
assertEquals(ImmutableList.of("Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil"), appleCxxPlatform.getDsymutil().getCommandPrefix(resolver));
assertEquals(ImmutableList.of("usr/bin/xctest"), appleCxxPlatform.getXctest().getCommandPrefix(resolver));
assertEquals(InternalFlavor.of("watchos2.0-armv7k"), cxxPlatform.getFlavor());
assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang").toString(), cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
assertThat(ImmutableList.<String>builder().addAll(cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver)).addAll(cxxPlatform.getCflags()).build(), hasConsecutiveItems("-isysroot", Paths.get("Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk").toString()));
assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-arch", "armv7k"));
assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-mwatchos-version-min=2.0"));
assertThat(cxxPlatform.getLdflags(), hasConsecutiveItems("-Wl,-sdk_version", "-Wl,2.0"));
assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++").toString(), cxxPlatform.getCxx().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
assertEquals(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/ar").toString(), cxxPlatform.getAr().getCommandPrefix(resolver).get(0));
}
Aggregations