Search in sources :

Example 6 with NativeLinkTarget

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()));
}
Also used : DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Test(org.junit.Test)

Example 7 with NativeLinkTarget

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)));
}
Also used : CxxLibrary(com.facebook.buck.cxx.CxxLibrary) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) NativeLinkable(com.facebook.buck.cxx.NativeLinkable) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Test(org.junit.Test)

Example 8 with NativeLinkTarget

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)));
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) NativeLinkable(com.facebook.buck.cxx.NativeLinkable) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Test(org.junit.Test)

Aggregations

NativeLinkTarget (com.facebook.buck.cxx.NativeLinkTarget)8 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)5 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)5 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)5 Test (org.junit.Test)5 NativeLinkable (com.facebook.buck.cxx.NativeLinkable)4 CxxLibraryBuilder (com.facebook.buck.cxx.CxxLibraryBuilder)3 PrebuiltCxxLibraryBuilder (com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder)3 BuildTarget (com.facebook.buck.model.BuildTarget)3 BuildRule (com.facebook.buck.rules.BuildRule)3 SourcePath (com.facebook.buck.rules.SourcePath)3 CxxLibrary (com.facebook.buck.cxx.CxxLibrary)2 NativeLinkTargetMode (com.facebook.buck.cxx.NativeLinkTargetMode)2 OmnibusLibraries (com.facebook.buck.cxx.OmnibusLibraries)2 OmnibusLibrary (com.facebook.buck.cxx.OmnibusLibrary)2 OmnibusRoot (com.facebook.buck.cxx.OmnibusRoot)2 OmnibusRoots (com.facebook.buck.cxx.OmnibusRoots)2 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)2 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)2 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)2