use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class PythonBinaryDescriptionTest method transitiveDepsOfLibsWithPrebuiltNativeLibsAreNotIncludedInMergedLink.
@Test
public void transitiveDepsOfLibsWithPrebuiltNativeLibsAreNotIncludedInMergedLink() throws Exception {
CxxLibraryBuilder transitiveCxxLibraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:transitive_cxx")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("transitive_cxx.c"))));
CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:cxx")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("cxx.c")))).setDeps(ImmutableSortedSet.of(transitiveCxxLibraryBuilder.getTarget()));
PythonLibraryBuilder pythonLibraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib")).setSrcs(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new FakeSourcePath("prebuilt.so")))).setDeps(ImmutableSortedSet.of(cxxLibraryBuilder.getTarget()));
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {
@Override
public NativeLinkStrategy getNativeLinkStrategy() {
return NativeLinkStrategy.MERGED;
}
};
PythonBinaryBuilder pythonBinaryBuilder = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
pythonBinaryBuilder.setMainModule("main");
pythonBinaryBuilder.setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget()));
TargetGraph targetGraph = TargetGraphFactory.newInstance(transitiveCxxLibraryBuilder.build(), cxxLibraryBuilder.build(), pythonLibraryBuilder.build(), pythonBinaryBuilder.build());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
transitiveCxxLibraryBuilder.build(resolver, filesystem, targetGraph);
cxxLibraryBuilder.build(resolver, filesystem, targetGraph);
pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
PythonBinary binary = pythonBinaryBuilder.build(resolver, filesystem, targetGraph);
assertThat(Iterables.transform(binary.getComponents().getNativeLibraries().keySet(), Object::toString), Matchers.hasItem("libtransitive_cxx.so"));
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class TargetNodeTranslatorTest method noTranslate.
@Test
public void noTranslate() {
BuildTarget a = BuildTargetFactory.newInstance("//:a");
BuildTarget b = BuildTargetFactory.newInstance("//:b");
BuildTarget c = BuildTargetFactory.newInstance("//:c");
TargetNode<CxxLibraryDescription.Arg, ?> node = new CxxLibraryBuilder(a).setDeps(ImmutableSortedSet.of(b)).setExportedDeps(ImmutableSortedSet.of(c)).build();
TargetNodeTranslator translator = new TargetNodeTranslator(ImmutableList.of()) {
@Override
public Optional<BuildTarget> translateBuildTarget(BuildTarget target) {
return Optional.empty();
}
@Override
public Optional<ImmutableMap<BuildTarget, Version>> getSelectedVersions(BuildTarget target) {
return Optional.empty();
}
};
Optional<TargetNode<CxxLibraryDescription.Arg, ?>> translated = translator.translateNode(node);
assertFalse(translated.isPresent());
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class TargetNodeTranslatorTest method translate.
@Test
public void translate() {
BuildTarget a = BuildTargetFactory.newInstance("//:a");
BuildTarget b = BuildTargetFactory.newInstance("//:b");
BuildTarget c = BuildTargetFactory.newInstance("//:c");
final BuildTarget d = BuildTargetFactory.newInstance("//:d");
TargetNode<CxxLibraryDescription.Arg, ?> node = new CxxLibraryBuilder(a).setDeps(ImmutableSortedSet.of(b)).setExportedDeps(ImmutableSortedSet.of(c)).build();
TargetNodeTranslator translator = new TargetNodeTranslator(ImmutableList.of()) {
@Override
public Optional<BuildTarget> translateBuildTarget(BuildTarget target) {
return Optional.of(d);
}
@Override
public Optional<ImmutableMap<BuildTarget, Version>> getSelectedVersions(BuildTarget target) {
return Optional.empty();
}
};
Optional<TargetNode<CxxLibraryDescription.Arg, ?>> translated = translator.translateNode(node);
assertThat(translated.get().getBuildTarget(), Matchers.equalTo(d));
assertThat(translated.get().getDeclaredDeps(), Matchers.equalTo(ImmutableSet.of(d)));
assertThat(translated.get().getExtraDeps(), Matchers.equalTo(ImmutableSet.of(d)));
assertThat(translated.get().getConstructorArg().deps, Matchers.equalTo(ImmutableSortedSet.of(d)));
assertThat(translated.get().getConstructorArg().exportedDeps, Matchers.equalTo(ImmutableSortedSet.of(d)));
}
Aggregations