Search in sources :

Example 11 with ImmutableSet

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableSet in project buck by facebook.

the class ProjectGeneratorTest method testAppBundleContainsAllTransitiveFrameworkDeps.

@Test
public void testAppBundleContainsAllTransitiveFrameworkDeps() throws IOException {
    BuildTarget framework2Target = BuildTarget.builder(rootPath, "//foo", "framework_2").addFlavors(DEFAULT_FLAVOR, CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    BuildTarget framework2BinaryTarget = BuildTarget.builder(rootPath, "//foo", "framework_2_bin").addFlavors(DEFAULT_FLAVOR, CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    TargetNode<?, ?> framework2BinaryNode = AppleLibraryBuilder.createBuilder(framework2BinaryTarget).build();
    TargetNode<?, ?> framework2Node = AppleBundleBuilder.createBuilder(framework2Target).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(framework2BinaryTarget).setProductName(Optional.of("framework_2_override")).build();
    BuildTarget framework1Target = BuildTarget.builder(rootPath, "//foo", "framework_1").addFlavors(DEFAULT_FLAVOR, CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    BuildTarget framework1BinaryTarget = BuildTarget.builder(rootPath, "//foo", "framework_1_bin").addFlavors(DEFAULT_FLAVOR, CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    TargetNode<?, ?> framework1BinaryNode = AppleLibraryBuilder.createBuilder(framework1BinaryTarget).build();
    TargetNode<?, ?> framework1Node = AppleBundleBuilder.createBuilder(framework1Target).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(framework1BinaryTarget).setDeps(ImmutableSortedSet.of(framework2Target)).build();
    BuildTarget framework1FlavoredTarget = BuildTarget.builder(rootPath, "//foo", "framework_1").addFlavors(DEFAULT_FLAVOR, CxxDescriptionEnhancer.SHARED_FLAVOR, InternalFlavor.of("iphoneos-arm64")).build();
    TargetNode<?, ?> framework1FlavoredNode = AppleBundleBuilder.createBuilder(framework1FlavoredTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(framework1BinaryTarget).setDeps(ImmutableSortedSet.of(framework2Target)).build();
    BuildTarget sharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    TargetNode<?, ?> binaryNode = AppleBinaryBuilder.createBuilder(sharedLibraryTarget).build();
    BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
    TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(sharedLibraryTarget).setDeps(ImmutableSortedSet.of(framework1Target, framework1FlavoredTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(framework1Node, framework1FlavoredNode, framework2Node, framework1BinaryNode, framework2BinaryNode, binaryNode, bundleNode), ImmutableSet.of());
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bundle");
    assertEquals(target.getProductType(), ProductType.APPLICATION);
    assertThat(target.getBuildPhases().size(), Matchers.equalTo(1));
    PBXBuildPhase buildPhase = target.getBuildPhases().get(0);
    assertThat(buildPhase instanceof PBXCopyFilesBuildPhase, Matchers.equalTo(true));
    PBXCopyFilesBuildPhase copyFilesBuildPhase = (PBXCopyFilesBuildPhase) buildPhase;
    assertThat(copyFilesBuildPhase.getFiles().size(), Matchers.equalTo(2));
    ImmutableSet<String> frameworkNames = FluentIterable.from(copyFilesBuildPhase.getFiles()).transform(input -> input.getFileRef().getName()).toSortedSet(Ordering.natural());
    assertThat(frameworkNames, Matchers.equalToObject(ImmutableSortedSet.of("framework_1.framework", "framework_2_override.framework")));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(com.facebook.buck.apple.project_generator.ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget) SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) AppleBundleExtension(com.facebook.buck.apple.AppleBundleExtension) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) AppleLibraryBuilder(com.facebook.buck.apple.AppleLibraryBuilder) InternalFlavor(com.facebook.buck.model.InternalFlavor) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) FlavorDomain(com.facebook.buck.model.FlavorDomain) FluentIterable(com.google.common.collect.FluentIterable) Map(java.util.Map) ReactNativeBuckConfig(com.facebook.buck.js.ReactNativeBuckConfig) Path(java.nio.file.Path) CxxDescriptionEnhancer(com.facebook.buck.cxx.CxxDescriptionEnhancer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSDictionary(com.dd.plist.NSDictionary) FileAttribute(java.nio.file.attribute.FileAttribute) BuildTarget(com.facebook.buck.model.BuildTarget) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Assert.assertFalse(org.junit.Assert.assertFalse) StringWithMacrosUtils(com.facebook.buck.rules.macros.StringWithMacrosUtils) ByteStreams(com.google.common.io.ByteStreams) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuckEventBus(com.facebook.buck.event.BuckEventBus) PBXSourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase) Iterables(com.google.common.collect.Iterables) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) PBXHeadersBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXHeadersBuildPhase) SourcePath(com.facebook.buck.rules.SourcePath) Either(com.facebook.buck.model.Either) XCBuildConfiguration(com.facebook.buck.apple.xcode.xcodeproj.XCBuildConfiguration) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) HalideLibraryDescription(com.facebook.buck.halide.HalideLibraryDescription) BuildTargetFactory(com.facebook.buck.model.BuildTargetFactory) AppleBinaryBuilder(com.facebook.buck.apple.AppleBinaryBuilder) PBXBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase) StringWithMacros(com.facebook.buck.rules.macros.StringWithMacros) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Before(org.junit.Before) AppleAssetCatalogBuilder(com.facebook.buck.apple.AppleAssetCatalogBuilder) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Assert.assertTrue(org.junit.Assert.assertTrue) ProductType(com.facebook.buck.apple.xcode.xcodeproj.ProductType) AppleResourceBuilder(com.facebook.buck.apple.AppleResourceBuilder) Test(org.junit.Test) IOException(java.io.IOException) PBXResourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXResourcesBuildPhase) SceneKitAssetsBuilder(com.facebook.buck.apple.SceneKitAssetsBuilder) CxxSource(com.facebook.buck.cxx.CxxSource) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) HalideLibraryBuilder(com.facebook.buck.halide.HalideLibraryBuilder) Paths(java.nio.file.Paths) AppleLibraryDescription(com.facebook.buck.apple.AppleLibraryDescription) PBXShellScriptBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase) Assert.assertEquals(org.junit.Assert.assertEquals) IosReactNativeLibraryBuilder(com.facebook.buck.js.IosReactNativeLibraryBuilder) CoreMatchers.is(org.hamcrest.CoreMatchers.is) AppleDependenciesCache(com.facebook.buck.apple.AppleDependenciesCache) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PatternMatchedCollection(com.facebook.buck.rules.coercer.PatternMatchedCollection) XcodePostbuildScriptBuilder(com.facebook.buck.apple.XcodePostbuildScriptBuilder) Matchers.hasKey(org.hamcrest.Matchers.hasKey) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) Assert.assertThat(org.junit.Assert.assertThat) AppleConfig(com.facebook.buck.apple.AppleConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) CxxPlatformUtils(com.facebook.buck.cxx.CxxPlatformUtils) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Cell(com.facebook.buck.rules.Cell) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) AppleBundleBuilder(com.facebook.buck.apple.AppleBundleBuilder) ImmutableMap(com.google.common.collect.ImmutableMap) TargetGraph(com.facebook.buck.rules.TargetGraph) Collection(java.util.Collection) Platform(com.facebook.buck.util.environment.Platform) PBXGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXGroup) XcodePrebuildScriptBuilder(com.facebook.buck.apple.XcodePrebuildScriptBuilder) List(java.util.List) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) SourceWithFlags(com.facebook.buck.rules.SourceWithFlags) HalideBuckConfig(com.facebook.buck.halide.HalideBuckConfig) FakeAppleRuleDescriptions(com.facebook.buck.apple.FakeAppleRuleDescriptions) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ExportFileDescription(com.facebook.buck.shell.ExportFileDescription) Optional(java.util.Optional) Assume.assumeTrue(org.junit.Assume.assumeTrue) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Pattern(java.util.regex.Pattern) CoreMatchers.not(org.hamcrest.CoreMatchers.not) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) AbstractBottomUpTraversal(com.facebook.buck.graph.AbstractBottomUpTraversal) PBXVariantGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXVariantGroup) BuckEventBusFactory(com.facebook.buck.event.BuckEventBusFactory) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ImmutableList(com.google.common.collect.ImmutableList) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) NSString(com.dd.plist.NSString) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) ExpectedException(org.junit.rules.ExpectedException) MoreCollectors(com.facebook.buck.util.MoreCollectors) Assert.assertNotNull(org.junit.Assert.assertNotNull) TargetNode(com.facebook.buck.rules.TargetNode) ExportFileBuilder(com.facebook.buck.shell.ExportFileBuilder) Matchers(org.hamcrest.Matchers) PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) PBXReference(com.facebook.buck.apple.xcode.xcodeproj.PBXReference) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) HumanReadableException(com.facebook.buck.util.HumanReadableException) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TimeUnit(java.util.concurrent.TimeUnit) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) Rule(org.junit.Rule) Ordering(com.google.common.collect.Ordering) TargetGraphFactory(com.facebook.buck.testutil.TargetGraphFactory) AppleTestBuilder(com.facebook.buck.apple.AppleTestBuilder) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) CoreDataModelBuilder(com.facebook.buck.apple.CoreDataModelBuilder) CopyFilePhaseDestinationSpec(com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec) Flavor(com.facebook.buck.model.Flavor) HeaderMap(com.facebook.buck.apple.clang.HeaderMap) InputStream(java.io.InputStream) BuildTarget(com.facebook.buck.model.BuildTarget) PBXBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) Test(org.junit.Test)

Example 12 with ImmutableSet

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableSet in project buck by facebook.

the class ProjectGeneratorTest method assertHasSingletonResourcesPhaseWithEntries.

private void assertHasSingletonResourcesPhaseWithEntries(PBXTarget target, String... resources) {
    PBXResourcesBuildPhase buildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXResourcesBuildPhase.class);
    assertEquals("Resources phase should have right number of elements", resources.length, buildPhase.getFiles().size());
    ImmutableSet.Builder<String> expectedResourceSetBuilder = ImmutableSet.builder();
    for (String resource : resources) {
        expectedResourceSetBuilder.add(projectFilesystem.getRootPath().resolve(resource).toAbsolutePath().normalize().toString());
    }
    ImmutableSet<String> expectedResourceSet = expectedResourceSetBuilder.build();
    for (PBXBuildFile file : buildPhase.getFiles()) {
        String source = assertFileRefIsRelativeAndResolvePath(file.getFileRef());
        assertTrue("Resource should be in list of expected resources: " + source, expectedResourceSet.contains(source));
    }
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) PBXResourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXResourcesBuildPhase)

Example 13 with ImmutableSet

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableSet in project buck by facebook.

the class ProjectGeneratorTest method testCxxLibraryWithoutHeadersSymLinks.

@Test
public void testCxxLibraryWithoutHeadersSymLinks() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/bar.h"))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/foo.h"), new FakeSourcePath("foo/dir2/baz.h"))).setSrcs(ImmutableSortedSet.of()).setXcodePublicHeadersSymlinks(false).setXcodePrivateHeadersSymlinks(false).build();
    ImmutableSet.Builder<ProjectGenerator.Option> optionsBuilder = ImmutableSet.builder();
    ImmutableSet<ProjectGenerator.Option> projectGeneratorOptions = optionsBuilder.build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), projectGeneratorOptions);
    projectGenerator.createXcodeProjects();
    List<Path> headerSymlinkTrees = projectGenerator.getGeneratedHeaderSymlinkTrees();
    assertThat(headerSymlinkTrees, hasSize(2));
    assertThat(headerSymlinkTrees.get(0).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-pub")));
    assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-pub"), ImmutableMap.of("foo/dir1/bar.h", "foo/dir1/bar.h"));
    assertThat(headerSymlinkTrees.get(1).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-priv")));
    assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-priv"), ImmutableMap.<String, String>builder().put("foo/dir1/foo.h", "foo/dir1/foo.h").put("foo/dir2/baz.h", "foo/dir2/baz.h").build());
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) ImmutableSet(com.google.common.collect.ImmutableSet) BuildTarget(com.facebook.buck.model.BuildTarget) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 14 with ImmutableSet

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableSet in project buck by facebook.

the class SimctlListOutputParsingTest method simctlListOutputParsesToAppleSimulators.

@Test
public void simctlListOutputParsesToAppleSimulators() throws IOException {
    ImmutableSet.Builder<AppleSimulator> simulatorsBuilder = ImmutableSet.builder();
    try (InputStream in = getClass().getResourceAsStream("testdata/simctl-list.txt");
        InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
        SimctlListOutputParsing.parseOutputFromReader(reader, simulatorsBuilder);
    }
    ImmutableSet<AppleSimulator> expected = ImmutableSet.<AppleSimulator>builder().add(AppleSimulator.builder().setName("iPhone 4s").setUdid("F7C1CC9A-945E-4258-BA84-DEEBE683798B").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 5").setUdid("45BD7164-686C-474F-8C68-3730432BC5F2").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 5s").setUdid("70200ED8-EEF1-4BDB-BCCF-3595B137D67D").setSimulatorState(AppleSimulatorState.BOOTED).build()).add(AppleSimulator.builder().setName("iPhone 6 Plus").setUdid("92340ACF-2C44-455F-BACD-573B133FB20E").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 6").setUdid("A75FF972-FE12-4656-A8CC-99572879D4A3").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPad 2").setUdid("CC1B0BAD-BAE6-4A53-92CF-F79850654057").setSimulatorState(AppleSimulatorState.SHUTTING_DOWN).build()).add(AppleSimulator.builder().setName("iPad Retina").setUdid("137AAA25-54A1-42E8-8202-84DEADD668E1").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPad Air").setUdid("554B2E0F-63F3-4400-8319-5C5062CF4C95").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("Resizable iPhone").setUdid("58E3748F-F7E6-4A45-B52C-A136B59F7A42").setSimulatorState(AppleSimulatorState.CREATING).build()).add(AppleSimulator.builder().setName("Resizable iPad").setUdid("56FE1CBC-61FF-443D-8E23-19D05864C6DB").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).build();
    assertThat(simulatorsBuilder.build(), is(equalTo(expected)));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 15 with ImmutableSet

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableSet in project buck by facebook.

the class AbstractCellConfig method getOverridesByPath.

/**
   * Translates the 'cell name'->override map into a 'Path'->override map.
   * @param pathMapping a map containing paths to all of the cells we want to query.
   * @return 'Path'->override map
   */
public ImmutableMap<Path, RawConfig> getOverridesByPath(ImmutableMap<RelativeCellName, Path> pathMapping) throws MalformedOverridesException {
    ImmutableSet<RelativeCellName> relativeNamesOfCellsWithOverrides = FluentIterable.from(getValues().keySet()).filter(Predicates.not(ALL_CELLS_OVERRIDE::equals)).toSet();
    ImmutableSet.Builder<Path> pathsWithOverrides = ImmutableSet.builder();
    for (RelativeCellName cellWithOverride : relativeNamesOfCellsWithOverrides) {
        if (!pathMapping.containsKey(cellWithOverride)) {
            throw new MalformedOverridesException(String.format("Trying to override settings for unknown cell %s", cellWithOverride));
        }
        pathsWithOverrides.add(pathMapping.get(cellWithOverride));
    }
    ImmutableMultimap<Path, RelativeCellName> pathToRelativeName = Multimaps.index(pathMapping.keySet(), Functions.forMap(pathMapping));
    for (Path pathWithOverrides : pathsWithOverrides.build()) {
        ImmutableCollection<RelativeCellName> namesForPath = pathToRelativeName.get(pathWithOverrides);
        if (namesForPath.size() > 1) {
            throw new MalformedOverridesException(String.format("Configuration override is ambiguous: cell rooted at %s is reachable " + "as [%s]. Please override the config by placing a .buckconfig.local file in the " + "cell's root folder.", pathWithOverrides, Joiner.on(',').join(namesForPath)));
        }
    }
    Map<Path, RawConfig> overridesByPath = new HashMap<>();
    for (Map.Entry<RelativeCellName, Path> entry : pathMapping.entrySet()) {
        RelativeCellName cellRelativeName = entry.getKey();
        Path cellPath = entry.getValue();
        RawConfig configFromOtherRelativeName = overridesByPath.get(cellPath);
        RawConfig config = getForCell(cellRelativeName);
        if (configFromOtherRelativeName != null) {
            Preconditions.checkState(configFromOtherRelativeName.equals(config), "Attempting to create cell %s at %s with conflicting overrides [%s] vs [%s].", cellRelativeName, cellPath, configFromOtherRelativeName, config);
        } else {
            overridesByPath.put(cellPath, config);
        }
    }
    return ImmutableMap.copyOf(overridesByPath);
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) RelativeCellName(com.facebook.buck.rules.RelativeCellName) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map) MoreCollectors.toImmutableMap(com.facebook.buck.util.MoreCollectors.toImmutableMap)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)346 Set (java.util.Set)85 ImmutableList (com.google.common.collect.ImmutableList)72 Path (java.nio.file.Path)70 ImmutableMap (com.google.common.collect.ImmutableMap)69 IOException (java.io.IOException)66 Optional (java.util.Optional)65 Map (java.util.Map)63 List (java.util.List)60 BuildTarget (com.facebook.buck.model.BuildTarget)58 Test (org.junit.Test)55 HashMap (java.util.HashMap)42 Collection (java.util.Collection)34 HashSet (java.util.HashSet)33 SourcePath (com.facebook.buck.rules.SourcePath)31 ArrayList (java.util.ArrayList)31 TargetNode (com.facebook.buck.rules.TargetNode)28 BuildRule (com.facebook.buck.rules.BuildRule)26 VisibleForTesting (com.google.common.annotations.VisibleForTesting)25 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)25