use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class AndroidNativeLibsPackageableGraphEnhancerTest method testNdkLibrary.
@Test
public void testNdkLibrary() throws Exception {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
NdkLibrary ndkLibrary = new NdkLibraryBuilder(BuildTargetFactory.newInstance("//:ndklib")).build(ruleResolver);
BuildTarget target = BuildTargetFactory.newInstance("//:target");
BuildRuleParams originalParams = new FakeBuildRuleParamsBuilder(target).setDeclaredDeps(ImmutableSortedSet.of(ndkLibrary)).build();
APKModuleGraph apkModuleGraph = new APKModuleGraph(TargetGraph.EMPTY, target, Optional.empty());
AndroidNativeLibsPackageableGraphEnhancer enhancer = new AndroidNativeLibsPackageableGraphEnhancer(ruleResolver, originalParams, ImmutableMap.of(), ImmutableSet.of(), CxxPlatformUtils.DEFAULT_CONFIG, /* nativeLibraryMergeMap */
Optional.empty(), /* nativeLibraryMergeGlue */
Optional.empty(), AndroidBinary.RelinkerMode.DISABLED, apkModuleGraph);
AndroidPackageableCollector collector = new AndroidPackageableCollector(target, ImmutableSet.of(), ImmutableSet.of(), apkModuleGraph);
collector.addPackageables(AndroidPackageableCollector.getPackageableRules(ImmutableSet.of(ndkLibrary)));
Optional<ImmutableMap<APKModule, CopyNativeLibraries>> copyNativeLibrariesOptional = enhancer.enhance(collector.build()).getCopyNativeLibraries();
CopyNativeLibraries copyNativeLibraries = copyNativeLibrariesOptional.get().get(apkModuleGraph.getRootAPKModule());
assertThat(copyNativeLibraries.getStrippedObjectDescriptions(), Matchers.empty());
assertThat(copyNativeLibraries.getNativeLibDirectories().stream().map(sourcePathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()), Matchers.contains(ndkLibrary.getLibraryPath()));
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class AndroidTransitiveDependencyGraphTest method findManifestFilesWithTransitiveDeps.
@Test
public void findManifestFilesWithTransitiveDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule dep3 = AndroidLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep3")).setManifestFile(new FakeSourcePath("manifest3.xml")).build(resolver);
BuildRule dep2 = AndroidLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep2")).addDep(dep3.getBuildTarget()).build(resolver);
BuildRule dep1 = AndroidLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep1")).setManifestFile(new FakeSourcePath("manifest1.xml")).addDep(dep2.getBuildTarget()).build(resolver);
assertThat(new AndroidTransitiveDependencyGraph(ImmutableSortedSet.of(dep1)).findManifestFiles(), Matchers.containsInAnyOrder(new FakeSourcePath("manifest1.xml"), new FakeSourcePath("manifest3.xml")));
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class ApkGenruleDescriptionTest method testClasspathTransitiveDepsBecomeFirstOrderDeps.
@Test
public void testClasspathTransitiveDepsBecomeFirstOrderDeps() throws Exception {
SourcePathResolver emptyPathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget installableApkTarget = BuildTargetFactory.newInstance("//:installable");
TargetNode<?, ?> installableApkNode = FakeTargetNodeBuilder.build(new FakeInstallable(installableApkTarget, emptyPathResolver));
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<?, ?> genruleNode = ApkGenruleBuilder.create(BuildTargetFactory.newInstance("//:rule")).setOut("out").setCmd("$(classpath //exciting:target)").setApk(installableApkTarget).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(installableApkNode, transitiveDepNode, depNode, genruleNode);
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule transitiveDep = resolver.requireRule(transitiveDepNode.getBuildTarget());
BuildRule dep = resolver.requireRule(depNode.getBuildTarget());
BuildRule genrule = resolver.requireRule(genruleNode.getBuildTarget());
assertThat(genrule.getDeps(), Matchers.hasItems(dep, transitiveDep));
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class DexProducedFromJavaLibraryThatContainsClassFilesTest method getOutputDoesNotAccessWrappedJavaLibrary.
@Test
public void getOutputDoesNotAccessWrappedJavaLibrary() throws Exception {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
JavaLibrary javaLibrary = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:lib")).build(ruleResolver);
BuildRuleParams params = new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:target")).build();
DexProducedFromJavaLibrary dexProducedFromJavaLibrary = new DexProducedFromJavaLibrary(params, javaLibrary);
ObjectMapper mapper = ObjectMappers.newDefaultInstance();
FakeOnDiskBuildInfo onDiskBuildInfo = new FakeOnDiskBuildInfo().putMetadata(DexProducedFromJavaLibrary.WEIGHT_ESTIMATE, "0").putMetadata(DexProducedFromJavaLibrary.CLASSNAMES_TO_HASHES, mapper.writeValueAsString(ImmutableMap.<String, String>of()));
initialize(dexProducedFromJavaLibrary, onDiskBuildInfo);
assertFalse(dexProducedFromJavaLibrary.hasOutput());
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class DummyRDotJavaTest method testRDotJavaBinFolder.
@Test
public void testRDotJavaBinFolder() {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
DummyRDotJava dummyRDotJava = new DummyRDotJava(new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//java/com/example:library")).build(), ruleFinder, ImmutableSet.of(), ANDROID_JAVAC_OPTIONS, /* forceFinalResourceIds */
false, Optional.empty(), Optional.empty(), false);
assertEquals(BuildTargets.getScratchPath(dummyRDotJava.getProjectFilesystem(), dummyRDotJava.getBuildTarget(), "__%s_rdotjava_bin__"), dummyRDotJava.getRDotJavaBinFolder());
}
Aggregations