use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method nativeLinkableDeps.
@Test
public void nativeLinkableDeps() throws Exception {
PrebuiltCxxLibraryBuilder depBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep"));
PrebuiltCxxLibraryBuilder ruleBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:r")).setDeps(ImmutableSortedSet.of(depBuilder.getTarget()));
TargetGraph targetGraph = TargetGraphFactory.newInstance(depBuilder.build(), ruleBuilder.build());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PrebuiltCxxLibrary dep = (PrebuiltCxxLibrary) depBuilder.build(resolver, filesystem, targetGraph);
PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) ruleBuilder.build(resolver, filesystem, targetGraph);
assertThat(rule.getNativeLinkableDepsForPlatform(CxxLibraryBuilder.createDefaultPlatform()), Matchers.contains(dep));
assertThat(ImmutableList.copyOf(rule.getNativeLinkableExportedDepsForPlatform(CxxLibraryBuilder.createDefaultPlatform())), empty());
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method exportedLinkerFlagsAreUsedToBuildSharedLibrary.
@Test
public void exportedLinkerFlagsAreUsedToBuildSharedLibrary() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget target = BuildTarget.builder(BuildTargetFactory.newInstance("//:lib")).addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).addFlavors(CxxPlatformUtils.DEFAULT_PLATFORM.getFlavor()).build();
PrebuiltCxxLibraryBuilder builder = new PrebuiltCxxLibraryBuilder(target).setExportedLinkerFlags(ImmutableList.of("--some-flag")).setForceStatic(true);
TargetGraph targetGraph = TargetGraphFactory.newInstance(builder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
CxxLink cxxLink = (CxxLink) builder.build(resolver, filesystem, targetGraph);
assertThat(Arg.stringify(cxxLink.getArgs(), pathResolver), Matchers.hasItem("--some-flag"));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method missingSharedLibsAreNotAutoBuiltForHeaderOnlyRules.
@Test
public void missingSharedLibsAreNotAutoBuiltForHeaderOnlyRules() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
ProjectFilesystem filesystem = new FakeProjectFilesystem();
PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET).setHeaderOnly(true);
TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build());
PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) libBuilder.build(resolver, filesystem, targetGraph);
NativeLinkableInput nativeLinkableInput = lib.getNativeLinkableInput(CXX_PLATFORM, Linker.LinkableDepType.SHARED);
assertThat(FluentIterable.from(nativeLinkableInput.getArgs()).transformAndConcat(arg -> arg.getDeps(ruleFinder)).toList(), empty());
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method missingStaticLibIsNotANativeLinkTargetSoname.
@Test
public void missingStaticLibIsNotANativeLinkTargetSoname() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
PrebuiltCxxLibraryBuilder prebuiltCxxLibraryBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule"));
TargetGraph targetGraph = TargetGraphFactory.newInstance(prebuiltCxxLibraryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) prebuiltCxxLibraryBuilder.build(resolver, filesystem, targetGraph);
assertFalse(rule.getNativeLinkTarget(CXX_PLATFORM).isPresent());
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method headerOnlyLibPrefersAnyLinking.
@Test
public void headerOnlyLibPrefersAnyLinking() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
PrebuiltCxxLibraryBuilder prebuiltCxxLibraryBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule")).setHeaderOnly(true);
TargetGraph targetGraph = TargetGraphFactory.newInstance(prebuiltCxxLibraryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) prebuiltCxxLibraryBuilder.build(resolver, filesystem, targetGraph);
assertThat(rule.getPreferredLinkage(CXX_PLATFORM), Matchers.equalTo(NativeLinkable.Linkage.ANY));
}
Aggregations