Search in sources :

Example 56 with BuildTarget

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)));
    }
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget)

Example 57 with BuildTarget

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));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) InternalFlavor(com.facebook.buck.model.InternalFlavor) Flavor(com.facebook.buck.model.Flavor) Test(org.junit.Test)

Example 58 with BuildTarget

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"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 59 with BuildTarget

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"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Matchers.containsString(org.hamcrest.Matchers.containsString) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Test(org.junit.Test)

Example 60 with BuildTarget

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));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) InternalFlavor(com.facebook.buck.model.InternalFlavor) Flavor(com.facebook.buck.model.Flavor) Test(org.junit.Test)

Aggregations

BuildTarget (com.facebook.buck.model.BuildTarget)1045 Test (org.junit.Test)758 Path (java.nio.file.Path)323 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)289 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)254 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)248 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)226 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)216 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)209 BuildRule (com.facebook.buck.rules.BuildRule)196 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)178 SourcePath (com.facebook.buck.rules.SourcePath)163 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)161 TargetGraph (com.facebook.buck.rules.TargetGraph)156 PathSourcePath (com.facebook.buck.rules.PathSourcePath)116 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)108 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)91 ImmutableSet (com.google.common.collect.ImmutableSet)90 ImmutableMap (com.google.common.collect.ImmutableMap)78 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)75