Search in sources :

Example 46 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class AppleDescriptionsTest method parseAppleHeadersForUseFromTheSameTargetFromMap.

@Test
public void parseAppleHeadersForUseFromTheSameTargetFromMap() {
    ImmutableSortedMap<String, SourcePath> headerMap = ImmutableSortedMap.of("virtual/path.h", new FakeSourcePath("path/to/some_file.h"), "another/path.h", new FakeSourcePath("path/to/another_file.h"), "another/file.h", new FakeSourcePath("different/path/to/a_file.h"), "file.h", new FakeSourcePath("file.h"));
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    assertEquals(ImmutableMap.of(), AppleDescriptions.parseAppleHeadersForUseFromTheSameTarget(resolver::getRelativePath, SourceList.ofNamedSources(headerMap)));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 47 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class RuleUtilsTest method creatingGroupsFromEntryMapsKeepsLongestCommonPrefix.

@Test
public void creatingGroupsFromEntryMapsKeepsLongestCommonPrefix() {
    ImmutableMultimap<Path, String> subgroups = ImmutableMultimap.<Path, String>builder().put(Paths.get("root"), "Lib").put(Paths.get("root/Lib"), "Bar").put(Paths.get("root/Lib"), "Foo").build();
    ImmutableMultimap<Path, GroupedSource> entries = ImmutableMultimap.<Path, GroupedSource>builder().put(Paths.get("root/Lib/Foo"), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File2.h"))).put(Paths.get("root/Lib/Bar"), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Bar/File1.h"))).put(Paths.get("root/Lib/Foo"), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File1.h"))).build();
    ImmutableList<GroupedSource> expected = ImmutableList.of(GroupedSource.ofSourceGroup("Lib", Paths.get("Lib"), ImmutableList.of(GroupedSource.ofSourceGroup("Bar", Paths.get("Lib/Bar"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Bar/File1.h")))), GroupedSource.ofSourceGroup("Foo", Paths.get("Lib/Foo"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File1.h")), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File2.h")))))));
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromEntryMaps(subgroups, entries, new RuleUtils.GroupedSourceNameComparator(resolver::getRelativePath), Paths.get("root"), Paths.get("root"));
    assertEquals(expected, actual);
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 48 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class NewNativeTargetProjectMutatorTest method setUp.

@Before
public void setUp() {
    assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
    generatedProject = new PBXProject("TestProject");
    sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    pathRelativizer = new PathRelativizer(Paths.get("_output"), sourcePathResolver::getRelativePath);
}
Also used : PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Before(org.junit.Before)

Example 49 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class RuleUtilsTest method creatingGroupsFromNoSourcePaths.

@Test
public void creatingGroupsFromNoSourcePaths() {
    ImmutableList<GroupedSource> expected = ImmutableList.of();
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromSourcePaths(resolver::getRelativePath, ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of());
    assertEquals(expected, actual);
}
Also used : DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 50 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class RuleUtilsTest method creatingGroupsFromSingleFileEntryMaps.

@Test
public void creatingGroupsFromSingleFileEntryMaps() {
    ImmutableMultimap<Path, String> subgroups = ImmutableMultimap.of();
    ImmutableMultimap<Path, GroupedSource> entries = ImmutableMultimap.of(Paths.get("root"), GroupedSource.ofPrivateHeader(new FakeSourcePath("File1.h")));
    ImmutableList<GroupedSource> expected = ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("File1.h")));
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromEntryMaps(subgroups, entries, new RuleUtils.GroupedSourceNameComparator(resolver::getRelativePath), Paths.get("root"), Paths.get("root"));
    assertEquals(expected, actual);
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Aggregations

SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)486 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)468 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)376 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)350 Test (org.junit.Test)330 BuildTarget (com.facebook.buck.model.BuildTarget)228 BuildRule (com.facebook.buck.rules.BuildRule)161 Path (java.nio.file.Path)154 SourcePath (com.facebook.buck.rules.SourcePath)148 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)138 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)126 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)119 PathSourcePath (com.facebook.buck.rules.PathSourcePath)86 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)82 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)79 TargetGraph (com.facebook.buck.rules.TargetGraph)76 RuleKey (com.facebook.buck.rules.RuleKey)72 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)70 ExecutionContext (com.facebook.buck.step.ExecutionContext)57 ImmutableList (com.google.common.collect.ImmutableList)55