use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class ProjectGeneratorTest method testMergedHeaderMap.
@Test
public void testMergedHeaderMap() throws IOException {
BuildTarget lib1Target = BuildTarget.builder(rootPath, "//foo", "lib1").build();
BuildTarget lib2Target = BuildTarget.builder(rootPath, "//bar", "lib2").build();
BuildTarget lib3Target = BuildTarget.builder(rootPath, "//foo", "lib3").build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "test").build();
BuildTarget lib4Target = BuildTarget.builder(rootPath, "//foo", "lib4").build();
TargetNode<?, ?> lib1Node = AppleLibraryBuilder.createBuilder(lib1Target).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("lib1.h"))).setDeps(ImmutableSortedSet.of(lib2Target)).setTests(ImmutableSortedSet.of(testTarget)).build();
TargetNode<?, ?> lib2Node = AppleLibraryBuilder.createBuilder(lib2Target).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("lib2.h"))).build();
TargetNode<?, ?> lib3Node = AppleLibraryBuilder.createBuilder(lib3Target).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("lib3.h"))).build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setDeps(ImmutableSortedSet.of(lib1Target, lib4Target)).build();
TargetNode<?, ?> lib4Node = AppleLibraryBuilder.createBuilder(lib4Target).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("lib4.h"))).build();
final TargetGraph targetGraph = TargetGraphFactory.newInstance(ImmutableSet.of(lib1Node, lib2Node, lib3Node, testNode, lib4Node));
final AppleDependenciesCache cache = new AppleDependenciesCache(targetGraph);
ProjectGenerator projectGeneratorLib2 = new ProjectGenerator(targetGraph, cache, ImmutableSet.of(lib2Target), projectCell, OUTPUT_DIRECTORY, PROJECT_NAME, "BUCK", ImmutableSet.of(ProjectGenerator.Option.MERGE_HEADER_MAPS), Optional.empty(), ImmutableList.of(), false, /* isMainProject */
Optional.of(lib1Target), ImmutableSet.of(lib1Target, lib4Target), Optional.empty(), new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, getBuildRuleResolverNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
projectGeneratorLib2.createXcodeProjects();
// The merged header map should not generated at this point.
Path hmapPath = Paths.get("buck-out/gen/_p/pub-hmap/.hmap");
assertFalse(hmapPath.toString() + " should NOT exist.", projectFilesystem.isFile(hmapPath));
// Checks the content of the header search paths.
PBXProject project2 = projectGeneratorLib2.getGeneratedProject();
PBXTarget testPBXTarget2 = assertTargetExistsAndReturnTarget(project2, "//bar:lib2");
ImmutableMap<String, String> buildSettings2 = getBuildSettings(lib2Target, testPBXTarget2, "Default");
assertEquals("test binary should use header symlink trees for both public and non-public headers " + "of the tested library in HEADER_SEARCH_PATHS", "$(inherited) " + "../buck-out/gen/_p/YAYFR3hXIb-priv/.hmap " + "../buck-out/gen/_p/pub-hmap/.hmap " + "../buck-out", buildSettings2.get("HEADER_SEARCH_PATHS"));
ProjectGenerator projectGeneratorLib1 = new ProjectGenerator(targetGraph, cache, ImmutableSet.of(lib1Target, testTarget), /* lib3Target not included on purpose */
projectCell, OUTPUT_DIRECTORY, PROJECT_NAME, "BUCK", ImmutableSet.of(ProjectGenerator.Option.MERGE_HEADER_MAPS), Optional.empty(), ImmutableList.of(), true, /* isMainProject */
Optional.of(lib1Target), ImmutableSet.of(lib1Target, lib4Target), Optional.empty(), new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, getBuildRuleResolverNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
projectGeneratorLib1.createXcodeProjects();
// The merged header map should not generated at this point.
assertTrue(hmapPath.toString() + " should exist.", projectFilesystem.isFile(hmapPath));
assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/pub-hmap"), ImmutableMap.of("lib1/lib1.h", "buck-out/gen/_p/WNl0jZWMBk-pub/lib1/lib1.h", "lib2/lib2.h", "buck-out/gen/_p/YAYFR3hXIb-pub/lib2/lib2.h", "lib4/lib4.h", "buck-out/gen/_p/nmnbF8ID6C-pub/lib4/lib4.h"));
// Checks the content of the header search paths.
PBXProject project1 = projectGeneratorLib1.getGeneratedProject();
// For //foo:lib1
PBXTarget testPBXTarget1 = assertTargetExistsAndReturnTarget(project1, "//foo:lib1");
ImmutableMap<String, String> buildSettings1 = getBuildSettings(lib1Target, testPBXTarget1, "Default");
assertEquals("test binary should use header symlink trees for both public and non-public headers " + "of the tested library in HEADER_SEARCH_PATHS", "$(inherited) " + "../buck-out/gen/_p/WNl0jZWMBk-priv/.hmap " + "../buck-out/gen/_p/pub-hmap/.hmap " + "../buck-out", buildSettings1.get("HEADER_SEARCH_PATHS"));
// For //foo:test
PBXTarget testPBXTargetTest = assertTargetExistsAndReturnTarget(project1, "//foo:test");
ImmutableMap<String, String> buildSettingsTest = getBuildSettings(testTarget, testPBXTargetTest, "Default");
assertEquals("test binary should use header symlink trees for both public and non-public headers " + "of the tested library in HEADER_SEARCH_PATHS", "$(inherited) " + "../buck-out/gen/_p/LpygK8zq5F-priv/.hmap " + "../buck-out/gen/_p/pub-hmap/.hmap " + "../buck-out/gen/_p/WNl0jZWMBk-priv/.hmap " + "../buck-out", buildSettingsTest.get("HEADER_SEARCH_PATHS"));
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method customRunnableSettings.
@Test
public void customRunnableSettings() throws IOException, InterruptedException {
BuildTarget fooLibTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "FooLib").build();
TargetNode<AppleLibraryDescription.Arg, ?> fooLib = AppleLibraryBuilder.createBuilder(fooLibTarget).build();
TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(BuildTarget.builder(rootCell.getRoot(), "//foo", "workspace").build()).setWorkspaceName(Optional.of("workspace")).setSrcTarget(Optional.of(fooLibTarget)).setExplicitRunnablePath(Optional.of("/some.app")).setLaunchStyle(Optional.of(XCScheme.LaunchAction.LaunchStyle.WAIT)).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(fooLib, workspaceNode);
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), true, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
XCScheme mainScheme = generator.getSchemeGenerators().get("workspace").getOutputScheme().get();
XCScheme.LaunchAction launchAction = mainScheme.getLaunchAction().get();
assertThat(launchAction.getRunnablePath().get(), Matchers.equalTo("/some.app"));
assertThat(launchAction.getLaunchStyle(), Matchers.equalTo(XCScheme.LaunchAction.LaunchStyle.WAIT));
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class ProjectGeneratorTest method createProjectGeneratorForCombinedProject.
private ProjectGenerator createProjectGeneratorForCombinedProject(Collection<TargetNode<?, ?>> nodes, ImmutableSet<ProjectGenerator.Option> projectGeneratorOptions, Function<? super TargetNode<?, ?>, BuildRuleResolver> buildRuleResolverForNode) {
ImmutableSet<BuildTarget> initialBuildTargets = nodes.stream().map(TargetNode::getBuildTarget).collect(MoreCollectors.toImmutableSet());
final TargetGraph targetGraph = TargetGraphFactory.newInstance(ImmutableSet.copyOf(nodes));
final AppleDependenciesCache cache = new AppleDependenciesCache(targetGraph);
return new ProjectGenerator(targetGraph, cache, initialBuildTargets, projectCell, OUTPUT_DIRECTORY, PROJECT_NAME, "BUCK", projectGeneratorOptions, Optional.empty(), ImmutableList.of(), false, Optional.empty(), ImmutableSet.of(), Optional.empty(), new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, buildRuleResolverForNode, getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class AppleCxxPlatformsTest method buildAppleCxxPlatform.
private AppleCxxPlatform buildAppleCxxPlatform(Path root, BuckConfig config) {
AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/iPhoneOS.platform")).setSdkPath(root.resolve("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneSimulator8.0.sdk")).build();
AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.IPHONESIMULATOR).setName("iphonesimulator8.0").setVersion("8.0").setToolchains(ImmutableList.of(toolchain)).build();
return AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "armv7", appleSdkPaths, config, new FakeAppleConfig(config), new AlwaysFoundExecutableFinder(), Optional.empty(), Optional.empty());
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method enablingParallelizeBuild.
@Test
public void enablingParallelizeBuild() throws IOException, InterruptedException {
BuildTarget fooLibTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "FooLib").build();
TargetNode<AppleLibraryDescription.Arg, ?> fooLib = AppleLibraryBuilder.createBuilder(fooLibTarget).build();
TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(BuildTarget.builder(rootCell.getRoot(), "//foo", "workspace").build()).setWorkspaceName(Optional.of("workspace")).setSrcTarget(Optional.of(fooLibTarget)).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(fooLib, workspaceNode);
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), true, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
XCScheme mainScheme = generator.getSchemeGenerators().get("workspace").getOutputScheme().get();
XCScheme.BuildAction mainSchemeBuildAction = mainScheme.getBuildAction().get();
// I wish we could use Hamcrest contains() here, but we hit
// https://code.google.com/p/hamcrest/issues/detail?id=190 if we do that.
assertThat(mainSchemeBuildAction.getBuildActionEntries(), hasSize(1));
assertThat(mainSchemeBuildAction.getBuildActionEntries().get(0), withNameAndBuildingFor("FooLib", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
assertThat(mainSchemeBuildAction.getParallelizeBuild(), is(true));
}
Aggregations