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()))));
}
Aggregations