use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method staticPicLinkStyle.
@Test
public void staticPicLinkStyle() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleResolver resolver = new BuildRuleResolver(prepopulateWithSandbox(target), new DefaultTargetNodeToBuildRuleTransformer());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
new CxxBinaryBuilder(target, cxxBuckConfig).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new PathSourcePath(filesystem, Paths.get("test.cpp"))))).build(resolver, filesystem);
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method testBinaryWithStripFlavorHasStripLinkRuleWithCorrectStripStyle.
@Test
public void testBinaryWithStripFlavorHasStripLinkRuleWithCorrectStripStyle() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
CxxPlatform platform = CxxLibraryBuilder.createDefaultPlatform();
CxxBinaryBuilder binaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:foo").withFlavors(platform.getFlavor(), InternalFlavor.of("shared"), StripStyle.ALL_SYMBOLS.getFlavor()), cxxBuckConfig);
binaryBuilder.setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.c"))));
TargetGraph targetGraph = TargetGraphFactory.newInstance(binaryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule resultRule = binaryBuilder.build(resolver, filesystem, targetGraph);
assertThat(resultRule, Matchers.instanceOf(CxxBinary.class));
assertThat(((CxxBinary) resultRule).getLinkRule(), Matchers.instanceOf(CxxStrip.class));
CxxStrip strip = (CxxStrip) ((CxxBinary) resultRule).getLinkRule();
assertThat(strip.getStripStyle(), equalTo(StripStyle.ALL_SYMBOLS));
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method runtimeDepOnDeps.
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget leafBinaryTarget = BuildTargetFactory.newInstance("//:dep");
CxxBinaryBuilder leafCxxBinaryBuilder = new CxxBinaryBuilder(leafBinaryTarget, cxxBuckConfig);
BuildTarget libraryTarget = BuildTargetFactory.newInstance("//:lib");
CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(leafBinaryTarget));
BuildTarget topLevelBinaryTarget = BuildTargetFactory.newInstance("//:bin");
CxxBinaryBuilder topLevelCxxBinaryBuilder = new CxxBinaryBuilder(topLevelBinaryTarget, cxxBuckConfig).setDeps(ImmutableSortedSet.of(libraryTarget));
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(leafCxxBinaryBuilder.build(), cxxLibraryBuilder.build(), topLevelCxxBinaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
BuildRule leafCxxBinary = leafCxxBinaryBuilder.build(resolver, filesystem);
cxxLibraryBuilder.build(resolver, filesystem);
CxxBinary topLevelCxxBinary = topLevelCxxBinaryBuilder.build(resolver, filesystem);
assertThat(BuildRules.getTransitiveRuntimeDeps(topLevelCxxBinary, resolver), Matchers.hasItem(leafCxxBinary.getBuildTarget()));
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CxxBinaryIntegrationTest method testInferCxxBinaryWritesSpecsListFilesOfTransitiveDependencies.
@Test
public void testInferCxxBinaryWritesSpecsListFilesOfTransitiveDependencies() throws IOException {
assumeTrue(Platform.detect() != Platform.WINDOWS);
ProjectWorkspace workspace = InferHelper.setupCxxInferWorkspace(this, tmp, Optional.empty());
workspace.setupCxxSandboxing(sandboxSources);
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget inputBuildTarget = BuildTargetFactory.newInstance("//foo:binary_with_chain_deps").withFlavors(CxxInferEnhancer.InferFlavors.INFER.get());
//Build the given target and check that it succeeds.
workspace.runBuckCommand("build", inputBuildTarget.getFullyQualifiedName()).assertSuccess();
String specsPathList = BuildTargets.getGenPath(filesystem, inputBuildTarget.withFlavors(CxxInferEnhancer.InferFlavors.INFER_ANALYZE.get()), "infer-analysis-%s/specs_path_list.txt").toString();
String out = workspace.getFileContents(specsPathList);
ImmutableList<Path> paths = FluentIterable.from(out.split("\n")).transform(input -> new File(input).toPath()).toList();
assertSame("There must be 2 paths in total", paths.size(), 2);
for (Path path : paths) {
assertTrue("Path must be absolute", path.isAbsolute());
assertTrue("Path must exist", Files.exists(path));
}
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CxxBinaryIntegrationTest method testInferCxxBinaryRunsOnAllFilesWhenBlacklistIsNotSpecified.
@Test
public void testInferCxxBinaryRunsOnAllFilesWhenBlacklistIsNotSpecified() throws IOException {
assumeTrue(Platform.detect() != Platform.WINDOWS);
ProjectWorkspace workspace = InferHelper.setupCxxInferWorkspace(this, tmp, Optional.empty());
workspace.setupCxxSandboxing(sandboxSources);
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget inputBuildTarget = BuildTargetFactory.newInstance("//foo:binary_with_chain_deps");
String inputBuildTargetName = inputBuildTarget.withFlavors(CxxInferEnhancer.InferFlavors.INFER.get()).getFullyQualifiedName();
// Build the given target and check that it succeeds.
workspace.runBuckCommand("build", inputBuildTargetName).assertSuccess();
// Check that all cfgs have been created
assertTrue("Expected cfg for chain_dep_one.c not found", Files.exists(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance("//foo:chain_dep_one#default,infer-capture-" + sanitize("chain_dep_one.c.o")), "infer-out-%s").resolve("captured/chain_dep_one.c_captured/chain_dep_one.c.cfg"))));
assertTrue("Expected cfg for chain_dep_two.c not found", Files.exists(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance("//foo:chain_dep_two#default,infer-capture-" + sanitize("chain_dep_two.c.o")), "infer-out-%s").resolve("captured/chain_dep_two.c_captured/chain_dep_two.c.cfg"))));
assertTrue("Expected cfg for top_chain.c not found", Files.exists(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(filesystem, "//foo:binary_with_chain_deps#infer-analyze"), "infer-analysis-%s").resolve("captured/top_chain.c_captured/top_chain.c.cfg"))));
}
Aggregations