use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryWithoutHeadersSymLinks.
@Test
public void testCxxLibraryWithoutHeadersSymLinks() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/bar.h"))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/foo.h"), new FakeSourcePath("foo/dir2/baz.h"))).setSrcs(ImmutableSortedSet.of()).setXcodePublicHeadersSymlinks(false).setXcodePrivateHeadersSymlinks(false).build();
ImmutableSet.Builder<ProjectGenerator.Option> optionsBuilder = ImmutableSet.builder();
ImmutableSet<ProjectGenerator.Option> projectGeneratorOptions = optionsBuilder.build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), projectGeneratorOptions);
projectGenerator.createXcodeProjects();
List<Path> headerSymlinkTrees = projectGenerator.getGeneratedHeaderSymlinkTrees();
assertThat(headerSymlinkTrees, hasSize(2));
assertThat(headerSymlinkTrees.get(0).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-pub")));
assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-pub"), ImmutableMap.of("foo/dir1/bar.h", "foo/dir1/bar.h"));
assertThat(headerSymlinkTrees.get(1).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-priv")));
assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-priv"), ImmutableMap.<String, String>builder().put("foo/dir1/foo.h", "foo/dir1/foo.h").put("foo/dir2/baz.h", "foo/dir2/baz.h").build());
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryWithListsOfHeaders.
@Test
public void testCxxLibraryWithListsOfHeaders() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/bar.h"))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/foo.h"), new FakeSourcePath("foo/dir2/baz.h"))).setSrcs(ImmutableSortedSet.of()).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
List<Path> headerSymlinkTrees = projectGenerator.getGeneratedHeaderSymlinkTrees();
assertThat(headerSymlinkTrees, hasSize(2));
assertThat(headerSymlinkTrees.get(0).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-pub")));
assertThatHeaderSymlinkTreeContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-pub"), ImmutableMap.of("foo/dir1/bar.h", "foo/dir1/bar.h"));
assertThat(headerSymlinkTrees.get(1).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-priv")));
assertThatHeaderSymlinkTreeContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-priv"), ImmutableMap.<String, String>builder().put("foo/dir1/foo.h", "foo/dir1/foo.h").put("foo/dir2/baz.h", "foo/dir2/baz.h").build());
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryExportedPlatformFlags.
@Test
public void testCxxLibraryExportedPlatformFlags() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedPlatformPreprocessorFlags(PatternMatchedCollection.<ImmutableList<String>>builder().add(Pattern.compile("iphone.*"), ImmutableList.of("-fbar-iphone")).build()).setExportedPlatformLinkerFlags(PatternMatchedCollection.<ImmutableList<StringWithMacros>>builder().add(Pattern.compile("macosx.*"), ImmutableList.of(StringWithMacrosUtils.format("-lbaz-macosx"))).build()).build();
BuildTarget dependentBuildTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
TargetNode<?, ?> dependentNode = AppleBinaryBuilder.createBuilder(dependentBuildTarget).setPlatformCompilerFlags(PatternMatchedCollection.<ImmutableList<String>>builder().add(Pattern.compile("iphone.*"), ImmutableList.of("-ffoo-iphone")).build()).setDeps(ImmutableSortedSet.of(buildTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node, dependentNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
assertHasConfigurations(target, "Debug", "Release", "Profile");
ImmutableMap<String, String> settings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Debug");
assertEquals("-Wno-deprecated -Wno-conversion -fbar-iphone -Wno-deprecated -Wno-conversion -fbar-iphone", settings.get("OTHER_CFLAGS[sdk=*iphone*]"));
assertEquals("-Wundeclared-selector -Wno-objc-designated-initializers -fbar-iphone " + "-Wundeclared-selector -Wno-objc-designated-initializers -fbar-iphone", settings.get("OTHER_CPLUSPLUSFLAGS[sdk=*iphone*]"));
assertEquals(null, settings.get("OTHER_LDFLAGS[sdk=*iphone*]"));
PBXTarget dependentTarget = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bin");
assertHasConfigurations(target, "Debug", "Release", "Profile");
ImmutableMap<String, String> dependentSettings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, dependentBuildTarget, dependentTarget, "Debug");
assertEquals("-Wno-deprecated -Wno-conversion -ffoo-iphone -fbar-iphone " + "-Wno-deprecated -Wno-conversion -ffoo-iphone -fbar-iphone", dependentSettings.get("OTHER_CFLAGS[sdk=*iphone*]"));
assertEquals("-Wundeclared-selector -Wno-objc-designated-initializers -ffoo-iphone -fbar-iphone " + "-Wundeclared-selector -Wno-objc-designated-initializers -ffoo-iphone -fbar-iphone", dependentSettings.get("OTHER_CPLUSPLUSFLAGS[sdk=*iphone*]"));
assertEquals(null, dependentSettings.get("OTHER_LDFLAGS[sdk=*iphone*]"));
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class IjModuleFactoryTest method testCxxLibrary.
@Test
public void testCxxLibrary() {
IjModuleFactory factory = createIjModuleFactory();
String sourceName = "cpp/lib/foo.cpp";
TargetNode<?, ?> cxxLibrary = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//cpp/lib:foo")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath(sourceName)))).build();
Path moduleBasePath = Paths.get("cpp/lib");
IjModule module = factory.createModule(moduleBasePath, ImmutableSet.of(cxxLibrary));
IjFolder cxxLibraryModel = new SourceFolder(Paths.get("cpp/lib"), false, ImmutableSortedSet.of(Paths.get("cpp/lib/foo.cpp")));
assertThat(module.getFolders(), Matchers.contains(cxxLibraryModel));
}
use of com.facebook.buck.cxx.CxxLibraryBuilder in project buck by facebook.
the class LuaBinaryDescriptionTest method transitiveNativeDepsUsingSeparateNativeLinkStrategy.
@Test
public void transitiveNativeDepsUsingSeparateNativeLinkStrategy() throws Exception {
CxxLibraryBuilder transitiveCxxDepBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:transitive_dep")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("transitive_dep.c"))));
CxxLibraryBuilder cxxDepBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("dep.c")))).setDeps(ImmutableSortedSet.of(transitiveCxxDepBuilder.getTarget()));
CxxLibraryBuilder cxxBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:cxx")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("cxx.c")))).setDeps(ImmutableSortedSet.of(cxxDepBuilder.getTarget()));
LuaBinaryBuilder binaryBuilder = new LuaBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), FakeLuaConfig.DEFAULT.withNativeLinkStrategy(NativeLinkStrategy.SEPARATE));
binaryBuilder.setMainModule("main");
binaryBuilder.setDeps(ImmutableSortedSet.of(cxxBuilder.getTarget()));
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(transitiveCxxDepBuilder.build(), cxxDepBuilder.build(), cxxBuilder.build(), binaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
transitiveCxxDepBuilder.build(resolver);
cxxDepBuilder.build(resolver);
cxxBuilder.build(resolver);
LuaBinary binary = binaryBuilder.build(resolver);
assertThat(Iterables.transform(binary.getComponents().getNativeLibraries().keySet(), Object::toString), Matchers.containsInAnyOrder("libtransitive_dep.so", "libdep.so", "libcxx.so"));
}
Aggregations