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());
}
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());
}
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)));
}
Aggregations