use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class AndroidBinaryTest method testGetProguardOutputFromInputClasspath.
@Test
public void testGetProguardOutputFromInputClasspath() throws Exception {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildTarget target = BuildTargetFactory.newInstance("//:fbandroid_with_dash_debug_fbsign");
AndroidBinary rule = AndroidBinaryBuilder.createBuilder(target).setManifest(new FakeSourcePath("AndroidManifest.xml")).setKeystore(addKeystoreRule(ruleResolver).getBuildTarget()).build(ruleResolver);
BuildTarget libBaseTarget = BuildTargetFactory.newInstance("//first-party/orca/lib-base:lib-base");
Path proguardConfigDir = BuildTargets.getGenPath(rule.getProjectFilesystem(), target.withFlavors(AndroidBinaryGraphEnhancer.AAPT_PACKAGE_FLAVOR), "__%s__proguard__/.proguard");
Path proguardDir = AndroidBinary.getProguardOutputFromInputClasspath(proguardConfigDir, BuildTargets.getScratchPath(rule.getProjectFilesystem(), libBaseTarget, "lib__%s__classes"));
assertEquals(proguardConfigDir.resolve(BuildTargets.getScratchPath(rule.getProjectFilesystem(), libBaseTarget, "lib__%s__classes-obfuscated.jar")), proguardDir);
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class AndroidBinaryTest method testCreateFilterResourcesStep.
@Test
public void testCreateFilterResourcesStep() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule keystoreRule = addKeystoreRule(resolver);
BuildTarget target = BuildTargetFactory.newInstance("//:target");
AndroidBinaryBuilder builder = AndroidBinaryBuilder.createBuilder(target).setManifest(new FakeSourcePath("AndroidManifest.xml")).setKeystore(keystoreRule.getBuildTarget()).setResourceFilter(new ResourceFilter(ImmutableList.of("mdpi"))).setResourceCompressionMode(ResourceCompressionMode.ENABLED_WITH_STRINGS_AS_ASSETS);
AndroidBinary buildRule = builder.build(resolver);
ImmutableList<Path> resourceDirectories = ImmutableList.of(Paths.get("one"), Paths.get("two"));
FilteredResourcesProvider resourcesProvider = buildRule.getEnhancementResult().getAaptPackageResources().getFilteredResourcesProvider();
assertTrue(resourcesProvider instanceof ResourcesFilter);
ImmutableList.Builder<Path> filteredDirs = ImmutableList.builder();
((ResourcesFilter) resourcesProvider).createFilterResourcesStep(resourceDirectories, /* whitelistedStringsDir */
ImmutableSet.of(), /* locales */
ImmutableSet.of(), filteredDirs);
assertEquals(ImmutableList.of(BuildTargets.getScratchPath(buildRule.getProjectFilesystem(), target.withFlavors(AndroidBinaryGraphEnhancer.RESOURCES_FILTER_FLAVOR), "__filtered__%s__/0"), BuildTargets.getScratchPath(buildRule.getProjectFilesystem(), target.withFlavors(AndroidBinaryGraphEnhancer.RESOURCES_FILTER_FLAVOR), "__filtered__%s__/1")), filteredDirs.build());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class AndroidBinaryTest method noDxParametersAreHintsAndNotHardDependencies.
@Test
public void noDxParametersAreHintsAndNotHardDependencies() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule keystoreRule = addKeystoreRule(resolver);
AndroidBinaryBuilder.createBuilder(BuildTargetFactory.newInstance("//:target")).setBuildTargetsToExcludeFromDex(ImmutableSet.of(BuildTargetFactory.newInstance("//missing:dep"))).setKeystore(keystoreRule.getBuildTarget()).setManifest(new FakeSourcePath("AndroidManifest.xml")).build(resolver);
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class AndroidBinaryTest method createAndroidLibraryRule.
static BuildRule createAndroidLibraryRule(String buildTarget, BuildRuleResolver ruleResolver, String resDirectory, String assetDirectory, String nativeLibsDirectory) throws Exception {
BuildTarget libraryOnebuildTarget = BuildTargetFactory.newInstance(buildTarget);
AndroidLibraryBuilder androidLibraryRuleBuilder = AndroidLibraryBuilder.createBuilder(libraryOnebuildTarget).addSrc(Paths.get(buildTarget.split(":")[1] + ".java"));
if (!Strings.isNullOrEmpty(resDirectory) || !Strings.isNullOrEmpty(assetDirectory)) {
BuildTarget resourceOnebuildTarget = BuildTargetFactory.newInstance(buildTarget + "_resources");
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
BuildRule androidResourceRule = ruleResolver.addToIndex(AndroidResourceRuleBuilder.newBuilder().setRuleFinder(ruleFinder).setAssets(new FakeSourcePath(assetDirectory)).setRes(resDirectory == null ? null : new FakeSourcePath(resDirectory)).setBuildTarget(resourceOnebuildTarget).build());
androidLibraryRuleBuilder.addDep(androidResourceRule.getBuildTarget());
}
if (!Strings.isNullOrEmpty(nativeLibsDirectory)) {
BuildTarget nativeLibOnebuildTarget = BuildTargetFactory.newInstance(buildTarget + "_native_libs");
BuildRule nativeLibsRule = PrebuiltNativeLibraryBuilder.newBuilder(nativeLibOnebuildTarget).setNativeLibs(Paths.get(nativeLibsDirectory)).build(ruleResolver);
ruleResolver.addToIndex(nativeLibsRule);
androidLibraryRuleBuilder.addDep(nativeLibsRule.getBuildTarget());
}
return androidLibraryRuleBuilder.build(ruleResolver);
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class AndroidBinaryDescriptionTest method testNoDxRulesBecomeFirstOrderDeps.
@Test
public void testNoDxRulesBecomeFirstOrderDeps() throws Exception {
TargetNode<?, ?> transitiveDepNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//exciting:dep")).addSrc(Paths.get("Dep.java")).build();
TargetNode<?, ?> depNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//exciting:target")).addSrc(Paths.get("Other.java")).addDep(transitiveDepNode.getBuildTarget()).build();
TargetNode<?, ?> keystoreNode = KeystoreBuilder.createBuilder(BuildTargetFactory.newInstance("//:keystore")).setStore(new FakeSourcePath("store")).setProperties(new FakeSourcePath("properties")).build();
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
TargetNode<?, ?> androidBinaryNode = AndroidBinaryBuilder.createBuilder(target).setManifest(new FakeSourcePath("manifest.xml")).setKeystore(BuildTargetFactory.newInstance("//:keystore")).setNoDx(ImmutableSet.of(transitiveDepNode.getBuildTarget())).setOriginalDeps(ImmutableSortedSet.of(depNode.getBuildTarget())).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(transitiveDepNode, depNode, keystoreNode, androidBinaryNode);
BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule transitiveDep = ruleResolver.requireRule(transitiveDepNode.getBuildTarget());
AndroidBinary androidBinary = (AndroidBinary) ruleResolver.requireRule(target);
assertThat(androidBinary.getDeps(), Matchers.hasItem(transitiveDep));
}
Aggregations