Search in sources :

Example 66 with FakeSourcePath

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

the class ProjectGeneratorTest method testAppleLibraryWithoutHeaderMaps.

@Test
public void testAppleLibraryWithoutHeaderMaps() throws IOException {
    ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.<String, String>of());
    BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setConfigs(configs).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m")))).build();
    BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "xctest").build();
    TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(configs).setInfoPlist(new FakeSourcePath("Info.plist")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("fooTest.m")))).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, testNode), ImmutableSet.of(ProjectGenerator.Option.DISABLE_HEADER_MAPS));
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:xctest");
    ImmutableMap<String, String> settings = getBuildSettings(testTarget, target, "Debug");
    assertEquals("$(inherited) " + "../buck-out/gen/_p/ptQfVNNRRE-priv " + "../buck-out/gen/_p/ptQfVNNRRE-pub " + "../buck-out/gen/_p/CwkbTNOBmb-pub " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 67 with FakeSourcePath

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

the class ProjectGeneratorTest method testSceneKitAssetsRuleAddsReference.

@Test
public void testSceneKitAssetsRuleAddsReference() throws IOException {
    BuildTarget target = BuildTarget.builder(rootPath, "//foo", "scenekitasset").build();
    TargetNode<?, ?> node = SceneKitAssetsBuilder.createBuilder(target).setPath(new FakeSourcePath("foo.scnassets").getRelativePath()).build();
    testRuleAddsReference(target, node, "foo.scnassets");
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 68 with FakeSourcePath

use of com.facebook.buck.rules.FakeSourcePath 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)

Example 69 with FakeSourcePath

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

the class RuleUtilsTest method creatingGroupsFromSourcePathsRemovesLongestCommonPrefix.

@Test
public void creatingGroupsFromSourcePathsRemovesLongestCommonPrefix() {
    ImmutableList<SourcePath> input = ImmutableList.of(new FakeSourcePath("Lib/Foo/File1.h"), new FakeSourcePath("Lib/Foo/File2.h"), new FakeSourcePath("Lib/Bar/File1.h"));
    ImmutableList<GroupedSource> expected = 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.createGroupsFromSourcePaths(resolver::getRelativePath, ImmutableList.of(), ImmutableSortedSet.of(), ImmutableList.of(), input);
    assertEquals(expected, actual);
}
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 70 with FakeSourcePath

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

the class RuleUtilsTest method creatingGroupsFromSourcePaths.

@Test
public void creatingGroupsFromSourcePaths() {
    ImmutableList<SourcePath> input = ImmutableList.of(new FakeSourcePath("File.h"), new FakeSourcePath("Lib/Foo/File2.h"), new FakeSourcePath("App/Foo/File.h"), new FakeSourcePath("Lib/Bar/File1.h"), new FakeSourcePath("App/File.h"), new FakeSourcePath("Lib/Foo/File1.h"), new FakeSourcePath("App/Foo/Bar/File.h"));
    ImmutableList<GroupedSource> expected = ImmutableList.of(GroupedSource.ofSourceGroup("App", Paths.get("App"), ImmutableList.of(GroupedSource.ofSourceGroup("Foo", Paths.get("App/Foo"), ImmutableList.of(GroupedSource.ofSourceGroup("Bar", Paths.get("App/Foo/Bar"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("App/Foo/Bar/File.h")))), GroupedSource.ofPrivateHeader(new FakeSourcePath("App/Foo/File.h")))), GroupedSource.ofPrivateHeader(new FakeSourcePath("App/File.h")))), 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")))))), GroupedSource.ofPrivateHeader(new FakeSourcePath("File.h")));
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromSourcePaths(resolver::getRelativePath, ImmutableList.of(), ImmutableSortedSet.of(), ImmutableList.of(), input);
    assertEquals(expected, actual);
}
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)

Aggregations

FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)318 Test (org.junit.Test)297 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)188 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)188 BuildTarget (com.facebook.buck.model.BuildTarget)182 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)116 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)104 SourcePath (com.facebook.buck.rules.SourcePath)90 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)85 TargetGraph (com.facebook.buck.rules.TargetGraph)84 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)68 Path (java.nio.file.Path)67 BuildRule (com.facebook.buck.rules.BuildRule)52 PathSourcePath (com.facebook.buck.rules.PathSourcePath)48 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)46 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)45 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)45 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)35 CxxLibraryBuilder (com.facebook.buck.cxx.CxxLibraryBuilder)25 NSString (com.dd.plist.NSString)24