use of com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer 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.DefaultTargetNodeToBuildRuleTransformer 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.DefaultTargetNodeToBuildRuleTransformer 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.DefaultTargetNodeToBuildRuleTransformer 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());
}
use of com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer in project buck by facebook.
the class AppleBinaryDescriptionTest method linkerFlagsLocationMacro.
@Test
public void linkerFlagsLocationMacro() throws Exception {
assumeThat(Platform.detect(), is(Platform.MACOS));
BuildTarget sandboxTarget = BuildTargetFactory.newInstance("//:rule#sandbox," + FakeAppleRuleDescriptions.DEFAULT_IPHONEOS_I386_PLATFORM.getFlavor());
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(new AppleBinaryBuilder(sandboxTarget).build()), new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
Genrule dep = GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:dep")).setOut("out").build(resolver);
AppleBinaryBuilder builder = new AppleBinaryBuilder(BuildTargetFactory.newInstance("//:rule")).setLinkerFlags(ImmutableList.of(StringWithMacrosUtils.format("--linker-script=%s", LocationMacro.of(dep.getBuildTarget()))));
assertThat(builder.build().getExtraDeps(), Matchers.hasItem(dep.getBuildTarget()));
BuildRule binary = ((CxxBinary) builder.build(resolver)).getLinkRule();
assertThat(binary, Matchers.instanceOf(CxxLink.class));
assertThat(Arg.stringify(((CxxLink) binary).getArgs(), pathResolver), Matchers.hasItem(String.format("--linker-script=%s", dep.getAbsoluteOutputFilePath(pathResolver))));
assertThat(binary.getDeps(), Matchers.hasItem(dep));
}
Aggregations