use of com.facebook.buck.cxx.CxxLibrary in project buck by facebook.
the class CxxPythonExtensionDescriptionTest method createBuildRuleNativeLinkableDep.
@Test
public void createBuildRuleNativeLinkableDep() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget target = BuildTargetFactory.newInstance("//:target");
// Setup a C/C++ library that we'll depend on form the C/C++ binary description.
BuildTarget cxxLibraryTarget = BuildTargetFactory.newInstance("//:dep");
CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(cxxLibraryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("something.cpp"), ImmutableList.of())));
CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(target, FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms()).setDeps(ImmutableSortedSet.of(cxxLibraryTarget));
TargetGraph targetGraph = TargetGraphFactory.newInstance(cxxLibraryBuilder.build(), builder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
CxxLibrary dep = (CxxLibrary) cxxLibraryBuilder.build(resolver, filesystem, targetGraph);
CxxPythonExtension extension = builder.build(resolver, filesystem, targetGraph);
NativeLinkableInput depInput = dep.getNativeLinkableInput(CxxPlatformUtils.DEFAULT_PLATFORM, Linker.LinkableDepType.SHARED);
// Verify that the shared library dep propagated to the link rule.
extension.getPythonPackageComponents(PY2, CxxPlatformUtils.DEFAULT_PLATFORM);
BuildRule rule = resolver.getRule(CxxPythonExtensionDescription.getExtensionTarget(target, PY2.getFlavor(), CxxPlatformUtils.DEFAULT_PLATFORM.getFlavor()));
assertThat(rule.getDeps(), Matchers.hasItems(FluentIterable.from(depInput.getArgs()).transformAndConcat(arg -> arg.getDeps(ruleFinder)).toArray(BuildRule.class)));
}
Aggregations