use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method generatedGidsForTargetsAreStable.
@Test
public void generatedGidsForTargetsAreStable() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "foo").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:foo");
String expectedGID = String.format("%08X%08X%08X", target.isa().hashCode(), target.getName().hashCode(), 0);
assertEquals("expected GID has correct value (value from which it's derived have not changed)", "E66DC04E2245423200000000", expectedGID);
assertEquals("generated GID is same as expected", expectedGID, target.getGlobalID());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryCompilerAndPreprocessorFlags.
@Test
public void testCxxLibraryCompilerAndPreprocessorFlags() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setCompilerFlags(ImmutableList.of("-ffoo")).setPreprocessorFlags(ImmutableList.of("-fbar")).setLinkerFlags(ImmutableList.of(StringWithMacrosUtils.format("-lbaz"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
assertHasConfigurations(target, "Debug", "Release", "Profile");
ImmutableMap<String, String> settings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Debug");
assertEquals("-Wno-deprecated -Wno-conversion -ffoo -fbar " + "-Wno-deprecated -Wno-conversion -ffoo -fbar", settings.get("OTHER_CFLAGS"));
assertEquals("-Wundeclared-selector -Wno-objc-designated-initializers -ffoo -fbar " + "-Wundeclared-selector -Wno-objc-designated-initializers -ffoo -fbar", settings.get("OTHER_CPLUSPLUSFLAGS"));
assertEquals("-lbaz -lbaz", settings.get("OTHER_LDFLAGS"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAggregateTargetForBundleForBuildWithBuck.
@Test
public void testAggregateTargetForBundleForBuildWithBuck() throws IOException {
BuildTarget binaryTarget = BuildTarget.builder(rootPath, "//foo", "binary").build();
TargetNode<?, ?> binaryNode = AppleBinaryBuilder.createBuilder(binaryTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).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(binaryTarget).build();
ImmutableSet<TargetNode<?, ?>> nodes = ImmutableSet.of(bundleNode, binaryNode);
final TargetGraph targetGraph = TargetGraphFactory.newInstance(nodes);
final AppleDependenciesCache cache = new AppleDependenciesCache(targetGraph);
ProjectGenerator projectGenerator = new ProjectGenerator(targetGraph, cache, nodes.stream().map(TargetNode::getBuildTarget).collect(MoreCollectors.toImmutableSet()), projectCell, OUTPUT_DIRECTORY, PROJECT_NAME, "BUCK", ImmutableSet.of(), Optional.of(bundleTarget), ImmutableList.of("--flag", "value with spaces"), false, Optional.empty(), ImmutableSet.of(), Optional.empty(), new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, getBuildRuleResolverNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
projectGenerator.createXcodeProjects();
PBXTarget buildWithBuckTarget = null;
for (PBXTarget target : projectGenerator.getGeneratedProject().getTargets()) {
if (target.getProductName() != null && target.getProductName().endsWith("-Buck")) {
buildWithBuckTarget = target;
}
}
assertThat(buildWithBuckTarget, is(notNullValue()));
assertHasConfigurations(buildWithBuckTarget, "Debug");
assertKeepsConfigurationsInMainGroup(projectGenerator.getGeneratedProject(), buildWithBuckTarget);
ProjectFilesystem filesystem = new FakeProjectFilesystem();
assertEquals("Should have exact number of build phases", 2, buildWithBuckTarget.getBuildPhases().size());
PBXBuildPhase buildPhase = Iterables.get(buildWithBuckTarget.getBuildPhases(), 0);
assertThat(buildPhase, instanceOf(PBXShellScriptBuildPhase.class));
PBXShellScriptBuildPhase shellScriptBuildPhase = (PBXShellScriptBuildPhase) buildPhase;
assertThat(shellScriptBuildPhase.getShellScript(), containsString("-- \"--show-output --report-absolute-paths --flag 'value with spaces'\" " + bundleTarget.getFullyQualifiedName() + " dwarf dwarf-and-dsym"));
Path fixUUIDScriptPath = ProjectGenerator.getFixUUIDScriptPath(filesystem);
assertThat(shellScriptBuildPhase.getShellScript(), containsString("python " + fixUUIDScriptPath + " --verbose " + filesystem.resolve(filesystem.getBuckPaths().getBuckOut()).resolve("bin/foo/bundle-unsanitised/bundle.app") + " " + filesystem.resolve(filesystem.getBuckPaths().getBuckOut()).resolve("bin/foo/bundle-unsanitised/bundle.dSYM") + " " + bundleTarget.getShortName()));
assertThat(shellScriptBuildPhase.getShellScript(), containsString("machoutils absolutify_object_paths --binary $BUCK_BUNDLE_OUTPUT_PATH/bundle " + "--output " + filesystem.resolve(filesystem.getBuckPaths().getBuckOut()).resolve("bin/foo/bundle-unsanitised/bundle.app/bundle") + " --old_compdir " + "\"./////////////////////"));
// skipping some slashes: ".//////////// ..... ///////"
assertThat(shellScriptBuildPhase.getShellScript(), containsString("////////\" --new_compdir \"" + filesystem.getRootPath().toString() + "\""));
PBXBuildPhase codesignPhase = buildWithBuckTarget.getBuildPhases().get(1);
assertThat(codesignPhase, instanceOf(PBXShellScriptBuildPhase.class));
PBXShellScriptBuildPhase codesignShellScriptPhase = (PBXShellScriptBuildPhase) codesignPhase;
Path codesignScriptPath = ProjectGenerator.getCodesignScriptPath(filesystem);
assertThat(codesignShellScriptPhase.getShellScript(), containsString("python " + codesignScriptPath + " /usr/bin/codesign " + filesystem.resolve(filesystem.getBuckPaths().getBuckOut()).resolve("bin/foo/bundle-unsanitised/bundle.app")));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryDependentsInheritSearchPaths.
@Test
public void testAppleLibraryDependentsInheritSearchPaths() throws IOException {
ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.of("HEADER_SEARCH_PATHS", "headers", "USER_HEADER_SEARCH_PATHS", "user_headers", "LIBRARY_SEARCH_PATHS", "libraries", "FRAMEWORK_SEARCH_PATHS", "frameworks"));
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setConfigs(configs).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Library.framework"), Optional.empty())))).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")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Test.framework"), Optional.empty())))).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:xctest");
ImmutableMap<String, String> settings = getBuildSettings(testTarget, target, "Debug");
assertEquals("headers " + "../buck-out/gen/_p/ptQfVNNRRE-priv/.hmap " + "../buck-out/gen/_p/ptQfVNNRRE-pub/.hmap " + "../buck-out/gen/_p/CwkbTNOBmb-pub/.hmap " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
assertEquals("user_headers", settings.get("USER_HEADER_SEARCH_PATHS"));
assertEquals("libraries $BUILT_PRODUCTS_DIR", settings.get("LIBRARY_SEARCH_PATHS"));
assertEquals("frameworks $BUILT_PRODUCTS_DIR $SDKROOT", settings.get("FRAMEWORK_SEARCH_PATHS"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryCompilerAndPreprocessorFlagsDontPropagate.
@Test
public void testAppleLibraryCompilerAndPreprocessorFlagsDontPropagate() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setCompilerFlags(ImmutableList.of("-fhello")).setPreprocessorFlags(ImmutableList.of("-fworld")).build();
BuildTarget dependentBuildTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
TargetNode<?, ?> dependentNode = AppleBinaryBuilder.createBuilder(dependentBuildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setDeps(ImmutableSortedSet.of(buildTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node, dependentNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bin");
ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
assertEquals("$(inherited) -Wno-deprecated -Wno-conversion", settings.get("OTHER_CFLAGS"));
}
Aggregations