use of com.facebook.buck.rules.TargetGraph 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.rules.TargetGraph 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.rules.TargetGraph 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.rules.TargetGraph 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));
}
use of com.facebook.buck.rules.TargetGraph in project buck by facebook.
the class PrebuiltCxxLibraryDescriptionTest method providedDoNotReturnSharedLibs.
@Test
public void providedDoNotReturnSharedLibs() throws Exception {
ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
PrebuiltCxxLibraryBuilder prebuiltCxxLibraryBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule")).setProvided(true);
TargetGraph targetGraph = TargetGraphFactory.newInstance(prebuiltCxxLibraryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) prebuiltCxxLibraryBuilder.build(resolver, filesystem, targetGraph);
assertThat(rule.getSharedLibraries(CXX_PLATFORM).entrySet(), empty());
}
Aggregations