Search in sources :

Example 6 with ExportFile

use of com.facebook.buck.shell.ExportFile in project buck by facebook.

the class CxxLibraryDescriptionTest method locationMacroExpandedExportedPlatformLinkerFlagNoPlatformMatch.

@Test
public void locationMacroExpandedExportedPlatformLinkerFlagNoPlatformMatch() throws Exception {
    BuildTarget location = BuildTargetFactory.newInstance("//:loc");
    BuildTarget target = BuildTargetFactory.newInstance("//foo:bar").withFlavors(CxxLibraryBuilder.createDefaultPlatform().getFlavor());
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    ExportFileBuilder locBuilder = ExportFileBuilder.newExportFileBuilder(location);
    locBuilder.setOut("somewhere.over.the.rainbow");
    CxxLibraryBuilder libBuilder = new CxxLibraryBuilder(target, cxxBuckConfig);
    libBuilder.setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new PathSourcePath(filesystem, Paths.get("test.cpp")))));
    libBuilder.setExportedPlatformLinkerFlags(PatternMatchedCollection.<ImmutableList<StringWithMacros>>builder().add(Pattern.compile("notarealplatform"), ImmutableList.of(StringWithMacrosUtils.format("-Wl,--version-script=%s", LocationMacro.of(location)))).build());
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build(), locBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    ExportFile loc = locBuilder.build(resolver, filesystem, targetGraph);
    CxxLibrary lib = (CxxLibrary) libBuilder.build(resolver, filesystem, targetGraph);
    NativeLinkableInput nativeLinkableInput = lib.getNativeLinkableInput(CxxLibraryBuilder.createDefaultPlatform(), Linker.LinkableDepType.SHARED);
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    assertThat(FluentIterable.from(nativeLinkableInput.getArgs()).transformAndConcat(arg -> arg.getDeps(ruleFinder)).toSet(), not(hasItem(loc)));
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    assertThat(Arg.stringify(nativeLinkableInput.getArgs(), pathResolver), not(hasItem(containsString(pathResolver.getRelativePath(Preconditions.checkNotNull(loc.getSourcePathToOutput())).toString()))));
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ExportFileBuilder(com.facebook.buck.shell.ExportFileBuilder) PathSourcePath(com.facebook.buck.rules.PathSourcePath) TargetGraph(com.facebook.buck.rules.TargetGraph) StringWithMacros(com.facebook.buck.rules.macros.StringWithMacros) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) ExportFile(com.facebook.buck.shell.ExportFile) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)6 BuildTarget (com.facebook.buck.model.BuildTarget)6 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)6 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)6 PathSourcePath (com.facebook.buck.rules.PathSourcePath)6 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)6 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)6 TargetGraph (com.facebook.buck.rules.TargetGraph)6 ExportFile (com.facebook.buck.shell.ExportFile)6 ExportFileBuilder (com.facebook.buck.shell.ExportFileBuilder)6 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)6 Test (org.junit.Test)6 StringWithMacros (com.facebook.buck.rules.macros.StringWithMacros)4