Search in sources :

Example 1 with CxxGenruleBuilder

use of com.facebook.buck.cxx.CxxGenruleBuilder in project buck by facebook.

the class RustLibraryDescriptionTest method testGeneratedSourceFromCxxGenrule.

@Test
public void testGeneratedSourceFromCxxGenrule() throws NoSuchBuildTargetException {
    CxxGenruleBuilder srcBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:src")).setOut("lib.rs");
    RustLibraryBuilder libraryBuilder = RustLibraryBuilder.from("//:lib").setSrcs(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(srcBuilder.getTarget())));
    RustBinaryBuilder binaryBuilder = RustBinaryBuilder.from("//:bin").setSrcs(ImmutableSortedSet.of(new FakeSourcePath("main.rs"))).setDeps(ImmutableSortedSet.of(libraryBuilder.getTarget()));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(srcBuilder.build(), libraryBuilder.build(), binaryBuilder.build());
    BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    ruleResolver.requireRule(binaryBuilder.getTarget());
}
Also used : CxxGenruleBuilder(com.facebook.buck.cxx.CxxGenruleBuilder) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 2 with CxxGenruleBuilder

use of com.facebook.buck.cxx.CxxGenruleBuilder in project buck by facebook.

the class RustBinaryDescriptionTest method testGeneratedSourceFromCxxGenrule.

@Test
public void testGeneratedSourceFromCxxGenrule() throws NoSuchBuildTargetException {
    CxxGenruleBuilder srcBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:src")).setOut("main.rs");
    RustBinaryBuilder binaryBuilder = RustBinaryBuilder.from("//:bin").setSrcs(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(srcBuilder.getTarget())));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(srcBuilder.build(), binaryBuilder.build());
    BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    ruleResolver.requireRule(binaryBuilder.getTarget());
}
Also used : CxxGenruleBuilder(com.facebook.buck.cxx.CxxGenruleBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 3 with CxxGenruleBuilder

use of com.facebook.buck.cxx.CxxGenruleBuilder in project buck by facebook.

the class PythonLibraryDescriptionTest method cxxGenruleSrcs.

@Test
public void cxxGenruleSrcs() throws Exception {
    CxxGenruleBuilder srcBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:src")).setOut("out.py");
    PythonLibraryBuilder libraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib")).setSrcs(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(srcBuilder.getTarget()))));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(srcBuilder.build(), libraryBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    CxxGenrule src = (CxxGenrule) resolver.requireRule(srcBuilder.getTarget());
    PythonLibrary library = (PythonLibrary) resolver.requireRule(libraryBuilder.getTarget());
    PythonPackageComponents components = library.getPythonPackageComponents(PythonTestUtils.PYTHON_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORM);
    assertThat(components.getModules().values(), Matchers.contains(src.getGenrule(CxxPlatformUtils.DEFAULT_PLATFORM)));
}
Also used : CxxGenruleBuilder(com.facebook.buck.cxx.CxxGenruleBuilder) CxxGenrule(com.facebook.buck.cxx.CxxGenrule) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

CxxGenruleBuilder (com.facebook.buck.cxx.CxxGenruleBuilder)3 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 TargetGraph (com.facebook.buck.rules.TargetGraph)3 Test (org.junit.Test)3 CxxGenrule (com.facebook.buck.cxx.CxxGenrule)1 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)1