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