use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AppleBinaryIntegrationTest method runTestAppleBinaryWithDebugFormatIsHermetic.
private void runTestAppleBinaryWithDebugFormatIsHermetic(AppleDebugFormat debugFormat) throws IOException {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_binary_is_hermetic", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance("//Apps/TestApp:TestApp#iphonesimulator-x86_64," + debugFormat.getFlavor().getName());
ProjectWorkspace.ProcessResult first = workspace.runBuckCommand(workspace.getPath("first"), "build", target.getFullyQualifiedName());
first.assertSuccess();
ProjectWorkspace.ProcessResult second = workspace.runBuckCommand(workspace.getPath("second"), "build", target.getFullyQualifiedName());
second.assertSuccess();
Path outputPath = BuildTargets.getGenPath(filesystem, target.withFlavors(InternalFlavor.of("iphonesimulator-x86_64"), InternalFlavor.of("compile-" + sanitize("TestClass.m.o"))), "%s/TestClass.m.o");
MoreAsserts.assertContentsEqual(workspace.getPath(Paths.get("first").resolve(outputPath)), workspace.getPath(Paths.get("second").resolve(outputPath)));
outputPath = BuildTargets.getGenPath(filesystem, target.withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors()), "%s");
MoreAsserts.assertContentsEqual(workspace.getPath(Paths.get("first").resolve(outputPath)), workspace.getPath(Paths.get("second").resolve(outputPath)));
if (debugFormat != AppleDebugFormat.DWARF) {
Path strippedPath = BuildTargets.getGenPath(filesystem, target.withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors()).withAppendedFlavors(StripStyle.NON_GLOBAL_SYMBOLS.getFlavor(), CxxStrip.RULE_FLAVOR), "%s");
MoreAsserts.assertContentsEqual(workspace.getPath(Paths.get("first").resolve(strippedPath)), workspace.getPath(Paths.get("second").resolve(strippedPath)));
}
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AppleBinaryIntegrationTest method testBuildingWithNoDebugDoesNotProduceAllCompileRulesOnDisk.
@Test
public void testBuildingWithNoDebugDoesNotProduceAllCompileRulesOnDisk() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_dwarf_and_dsym", tmp);
workspace.setUp();
workspace.enableDirCache();
Flavor platformFlavor = InternalFlavor.of("iphonesimulator-x86_64");
BuildTarget target = BuildTargetFactory.newInstance("//:DemoApp").withAppendedFlavors(AppleDebugFormat.NONE.getFlavor());
BuildTarget binaryTarget = BuildTargetFactory.newInstance("//:DemoAppBinary").withAppendedFlavors(platformFlavor, AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
BuildTarget appTarget = target.withFlavors(AppleDebugFormat.NONE.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
Path binaryOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app").resolve(target.getShortName()));
Path delegateFileOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, binaryTarget.withFlavors(platformFlavor, InternalFlavor.of("compile-" + sanitize("AppDelegate.m.o")), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR), "%s").resolve("AppDelegate.m.o"));
Path mainFileOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, binaryTarget.withFlavors(platformFlavor, InternalFlavor.of("compile-" + sanitize("main.m.o")), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR), "%s").resolve("main.m.o"));
assertThat(Files.exists(binaryOutput), equalTo(true));
assertThat(Files.exists(delegateFileOutput), equalTo(false));
assertThat(Files.exists(mainFileOutput), equalTo(false));
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AppleBinaryIntegrationTest method testAppleBinaryUsesPlatformLinkerFlags.
@Test
public void testAppleBinaryUsesPlatformLinkerFlags() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_binary_builds_something", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance("//Apps/TestApp:TestAppWithNonstandardMain");
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"));
assertThat(Files.exists(outputPath), is(true));
assertThat(workspace.runCommand("file", outputPath.toString()).getStdout().get(), containsString("executable"));
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AppleBinaryIntegrationTest method testFlavoredAppleBundleBuildsAndDsymFileCreatedAndBinaryIsStripped.
@Test
public void testFlavoredAppleBundleBuildsAndDsymFileCreatedAndBinaryIsStripped() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_dwarf_and_dsym", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance("//:DemoApp#dwarf-and-dsym");
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
workspace.runBuckCommand("build", "--config", "apple.default_debug_info_format_for_binaries=none", target.getFullyQualifiedName()).assertSuccess();
BuildTarget appTarget = target.withFlavors(AppleDebugFormat.DWARF_AND_DSYM.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
Path output = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app.dSYM").resolve("Contents/Resources/DWARF").resolve(target.getShortName()));
assertThat(Files.exists(output), equalTo(true));
AppleDsymTestUtil.checkDsymFileHasDebugSymbolForMain(workspace, output);
Path binaryOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app").resolve(target.getShortName()));
assertThat(Files.exists(binaryOutput), equalTo(true));
ProcessExecutor.Result hasSymbol = workspace.runCommand("nm", binaryOutput.toString());
String stdout = hasSymbol.getStdout().orElse("");
assertThat(stdout, Matchers.not(containsString("t -[AppDelegate window]")));
assertThat(stdout, containsString("U _UIApplicationMain"));
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AppleBinaryIntegrationTest method testBuildingWithDwarfAndDsymDoesNotProduceAllCompileRulesOnDisk.
@Test
public void testBuildingWithDwarfAndDsymDoesNotProduceAllCompileRulesOnDisk() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_dwarf_and_dsym", tmp);
workspace.setUp();
workspace.enableDirCache();
Flavor platformFlavor = InternalFlavor.of("iphonesimulator-x86_64");
BuildTarget target = BuildTargetFactory.newInstance("//:DemoApp").withAppendedFlavors(AppleDebugFormat.DWARF_AND_DSYM.getFlavor());
BuildTarget binaryTarget = BuildTargetFactory.newInstance("//:DemoAppBinary").withAppendedFlavors(platformFlavor, AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
BuildTarget appTarget = target.withFlavors(AppleDebugFormat.DWARF_AND_DSYM.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
Path binaryOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app").resolve(target.getShortName()));
Path delegateFileOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, binaryTarget.withFlavors(platformFlavor, InternalFlavor.of("compile-" + sanitize("AppDelegate.m.o")), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR), "%s").resolve("AppDelegate.m.o"));
Path mainFileOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, binaryTarget.withFlavors(platformFlavor, InternalFlavor.of("compile-" + sanitize("main.m.o")), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR), "%s").resolve("main.m.o"));
assertThat(Files.exists(binaryOutput), equalTo(true));
assertThat(Files.exists(delegateFileOutput), equalTo(false));
assertThat(Files.exists(mainFileOutput), equalTo(false));
}
Aggregations