use of com.facebook.buck.cxx.NativeLinkTarget in project buck by facebook.
the class CxxPythonExtensionDescriptionTest method nativeLinkTargetMode.
@Test
public void nativeLinkTargetMode() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:rule"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms());
CxxPythonExtension rule = builder.build(resolver);
NativeLinkTarget nativeLinkTarget = rule.getNativeLinkTarget(PY2);
assertThat(nativeLinkTarget.getNativeLinkTargetMode(CxxPlatformUtils.DEFAULT_PLATFORM), Matchers.equalTo(NativeLinkTargetMode.library()));
}
use of com.facebook.buck.cxx.NativeLinkTarget in project buck by facebook.
the class CxxPythonExtensionDescriptionTest method platformDeps.
@Test
public void platformDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
CxxLibrary dep = (CxxLibrary) new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).build(resolver);
CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:rule"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms());
CxxPythonExtension rule = builder.setPlatformDeps(PatternMatchedCollection.<ImmutableSortedSet<BuildTarget>>builder().add(Pattern.compile(PY2.getFlavor().toString()), ImmutableSortedSet.of(dep.getBuildTarget())).build()).build(resolver);
NativeLinkTarget py2NativeLinkTarget = rule.getNativeLinkTarget(PY2);
assertThat(ImmutableList.copyOf(py2NativeLinkTarget.getNativeLinkTargetDeps(CxxPlatformUtils.DEFAULT_PLATFORM)), Matchers.<NativeLinkable>hasItem(dep));
NativeLinkTarget py3NativeLinkTarget = rule.getNativeLinkTarget(PY3);
assertThat(ImmutableList.copyOf(py3NativeLinkTarget.getNativeLinkTargetDeps(CxxPlatformUtils.DEFAULT_PLATFORM)), Matchers.not(Matchers.<NativeLinkable>hasItem(dep)));
}
use of com.facebook.buck.cxx.NativeLinkTarget in project buck by facebook.
the class CxxPythonExtensionDescriptionTest method nativeLinkTargetDepsIncludePlatformCxxLibrary.
@Test
public void nativeLinkTargetDepsIncludePlatformCxxLibrary() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
CxxLibraryBuilder python2Builder = new CxxLibraryBuilder(PYTHON2_DEP_TARGET);
PythonPlatform platform = PY2.withCxxLibrary(PYTHON2_DEP_TARGET);
CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:rule"), FlavorDomain.of("Python Platform", platform), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms());
TargetGraph targetGraph = TargetGraphFactory.newInstance(python2Builder.build(), builder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
python2Builder.build(resolver, filesystem, targetGraph);
CxxPythonExtension rule = builder.build(resolver, filesystem, targetGraph);
NativeLinkTarget nativeLinkTarget = rule.getNativeLinkTarget(platform);
assertThat(ImmutableList.copyOf(nativeLinkTarget.getNativeLinkTargetDeps(CxxPlatformUtils.DEFAULT_PLATFORM)), Matchers.hasItem((NativeLinkable) resolver.getRule(PYTHON2_DEP_TARGET)));
}
Aggregations