use of com.facebook.buck.cxx.CxxBinaryBuilder in project buck by facebook.
the class PythonTestDescriptionTest method runtimeDepOnDeps.
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
CxxBinaryBuilder cxxBinaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
PythonLibraryBuilder pythonLibraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib")).setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
PythonTestBuilder pythonTestBuilder = PythonTestBuilder.create(BuildTargetFactory.newInstance("//:test")).setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget())).setPackageStyle(packageStyle);
TargetGraph targetGraph = TargetGraphFactory.newInstance(cxxBinaryBuilder.build(), pythonLibraryBuilder.build(), pythonTestBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule cxxBinary = cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
PythonTest pythonTest = pythonTestBuilder.build(resolver, filesystem, targetGraph);
assertThat(String.format("Transitive runtime deps of %s [%s]", pythonTest, packageStyle.toString()), BuildRules.getTransitiveRuntimeDeps(pythonTest, resolver), Matchers.hasItem(cxxBinary.getBuildTarget()));
}
}
use of com.facebook.buck.cxx.CxxBinaryBuilder in project buck by facebook.
the class PythonTestDescriptionTest method nonBuildDepsDoNotAffectRuleKey.
@Test
public void nonBuildDepsDoNotAffectRuleKey() throws Exception {
ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
// First, calculate the rule key of a python binary with no deps.
PythonTestBuilder pythonTestBuilder = PythonTestBuilder.create(BuildTargetFactory.newInstance("//:bin")).setPackageStyle(packageStyle);
TargetGraph targetGraph = TargetGraphFactory.newInstance(pythonTestBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PythonTest pythonTestWithoutDep = pythonTestBuilder.build(resolver, filesystem, targetGraph);
RuleKey ruleKeyWithoutDep = calculateRuleKey(resolver, pythonTestWithoutDep);
// Next, calculate the rule key of a python binary with a deps on another binary.
CxxBinaryBuilder cxxBinaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
pythonTestBuilder.setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
targetGraph = TargetGraphFactory.newInstance(cxxBinaryBuilder.build(), pythonTestBuilder.build());
resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
PythonTest pythonBinaryWithDep = pythonTestBuilder.build(resolver, filesystem, targetGraph);
RuleKey ruleKeyWithDep = calculateRuleKey(resolver, pythonBinaryWithDep);
// Verify that the rule keys are identical.
assertThat(ruleKeyWithoutDep, Matchers.equalTo(ruleKeyWithDep));
}
}
use of com.facebook.buck.cxx.CxxBinaryBuilder in project buck by facebook.
the class CxxPythonExtensionDescriptionTest method runtimeDeps.
@Test
public void runtimeDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep#sandbox")).build()), new DefaultTargetNodeToBuildRuleTransformer());
BuildTarget depTarget = BuildTargetFactory.newInstance("//:dep");
BuildRule cxxBinary = new CxxBinaryBuilder(depTarget).build(resolver);
CxxPythonExtension cxxPythonExtension = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:ext"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms()).setDeps(ImmutableSortedSet.of(cxxBinary.getBuildTarget())).build(resolver);
assertThat(cxxPythonExtension.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(cxxBinary.getBuildTarget()));
}
use of com.facebook.buck.cxx.CxxBinaryBuilder in project buck by facebook.
the class PythonBinaryDescriptionTest method nonBuildDepsDoNotAffectRuleKey.
@Test
public void nonBuildDepsDoNotAffectRuleKey() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
// First, calculate the rule key of a python binary with no deps.
PythonBinaryBuilder pythonBinaryBuilder = PythonBinaryBuilder.create(BuildTargetFactory.newInstance("//:bin")).setMainModule("main").setPackageStyle(packageStyle);
TargetGraph targetGraph = TargetGraphFactory.newInstance(pythonBinaryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PythonBinary pythonBinaryWithoutDep = pythonBinaryBuilder.build(resolver, filesystem, targetGraph);
RuleKey ruleKeyWithoutDep = calculateRuleKey(resolver, pythonBinaryWithoutDep);
// Next, calculate the rule key of a python binary with a deps on another binary.
CxxBinaryBuilder cxxBinaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
pythonBinaryBuilder.setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
targetGraph = TargetGraphFactory.newInstance(cxxBinaryBuilder.build(), pythonBinaryBuilder.build());
resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
PythonBinary pythonBinaryWithDep = pythonBinaryBuilder.build(resolver, filesystem, targetGraph);
RuleKey ruleKeyWithDep = calculateRuleKey(resolver, pythonBinaryWithDep);
// Verify that the rule keys are identical.
assertThat(ruleKeyWithoutDep, Matchers.equalTo(ruleKeyWithDep));
}
}
use of com.facebook.buck.cxx.CxxBinaryBuilder in project buck by facebook.
the class PythonBinaryDescriptionTest method runtimeDepOnDeps.
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
CxxBinaryBuilder cxxBinaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
PythonLibraryBuilder pythonLibraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib")).setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
PythonBinaryBuilder pythonBinaryBuilder = PythonBinaryBuilder.create(BuildTargetFactory.newInstance("//:bin")).setMainModule("main").setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget())).setPackageStyle(packageStyle);
TargetGraph targetGraph = TargetGraphFactory.newInstance(cxxBinaryBuilder.build(), pythonLibraryBuilder.build(), pythonBinaryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule cxxBinary = cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
PythonBinary pythonBinary = pythonBinaryBuilder.build(resolver, filesystem, targetGraph);
assertThat(String.format("Transitive runtime deps of %s [%s]", pythonBinary, packageStyle.toString()), BuildRules.getTransitiveRuntimeDeps(pythonBinary, resolver), Matchers.hasItem(cxxBinary.getBuildTarget()));
}
}
Aggregations