Search in sources :

Example 61 with BuildTarget

use of com.facebook.buck.model.BuildTarget in project buck by facebook.

the class AppleBinaryIntegrationTest method testFlavoredAppleBundleBuildsWithDwarfDebugFormatAndBinaryIsUnstripped.

@Test
public void testFlavoredAppleBundleBuildsWithDwarfDebugFormatAndBinaryIsUnstripped() 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");
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    BuildTarget appTarget = target.withFlavors(AppleDebugFormat.DWARF.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
    Path output = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app").resolve(target.getShortName()));
    assertThat(Files.exists(output), equalTo(true));
    ProcessExecutor.Result hasSymbol = workspace.runCommand("nm", output.toString());
    String stdout = hasSymbol.getStdout().orElse("");
    assertThat(stdout, 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 62 with BuildTarget

use of com.facebook.buck.model.BuildTarget in project buck by facebook.

the class AppleBinaryIntegrationTest method testAppleBinaryUsesDefaultsFromArgs.

@Test
public void testAppleBinaryUsesDefaultsFromArgs() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_binary_with_platform", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//Apps/TestApp:TestApp").withAppendedFlavors(InternalFlavor.of("iphoneos-arm64"));
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"));
    assertThat(Files.exists(outputPath), is(true));
    assertThat(Files.exists(Paths.get(outputPath.toString() + "-LinkMap.txt")), is(true));
    assertThat(workspace.runCommand("file", outputPath.toString()).getStdout().get(), containsString("executable"));
    assertThat(workspace.runCommand("otool", "-hv", outputPath.toString()).getStdout().get(), containsString("ARM64"));
}
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 63 with BuildTarget

use of com.facebook.buck.model.BuildTarget in project buck by facebook.

the class AppleBinaryIntegrationTest method testAppleBinaryBuildsBinaryWithoutLinkerMap.

@Test
public void testAppleBinaryBuildsBinaryWithoutLinkerMap() 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:TestApp").withFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor());
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"));
    assertThat(Files.exists(outputPath), is(true));
    assertThat(Files.exists(Paths.get(outputPath.toString() + "-LinkMap.txt")), is(false));
    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 64 with BuildTarget

use of com.facebook.buck.model.BuildTarget in project buck by facebook.

the class NdkCxxPlatformIntegrationTest method testWorkingDirectoryAndNdkHeaderPathsAreSanitized.

@Test
public void testWorkingDirectoryAndNdkHeaderPathsAreSanitized() throws IOException {
    ProjectWorkspace workspace = setupWorkspace("ndk_debug_paths");
    workspace.writeContentsToPath("[ndk]\n" + "  cpu_abis = arm, armv7, arm64, x86, x86_64\n" + "  gcc_version = 4.9\n" + "  app_platform = android-21\n", ".buckconfig");
    ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
    BuildTarget target = BuildTargetFactory.newInstance(String.format("//:lib#android-%s,static", arch));
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    Path lib = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/lib" + target.getShortName() + ".a"));
    String contents = MorePaths.asByteSource(lib).asCharSource(Charsets.ISO_8859_1).read();
    // Verify that the working directory is sanitized.
    assertFalse(contents.contains(tmp.getRoot().toString()));
    // Verify that we don't have any references to the build toolchain in the debug info.
    for (NdkCxxPlatforms.Host host : NdkCxxPlatforms.Host.values()) {
        assertFalse(contents.contains(host.toString()));
    }
    // Verify that the NDK path is sanitized.
    assertFalse(contents.contains(getNdkRoot().toString()));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 65 with BuildTarget

use of com.facebook.buck.model.BuildTarget in project buck by facebook.

the class NdkLibraryDescriptionTest method transitiveCxxLibraryDepsBecomeFirstOrderDepsOfNdkBuildRule.

@Test
public void transitiveCxxLibraryDepsBecomeFirstOrderDepsOfNdkBuildRule() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    FakeBuildRule transitiveInput = resolver.addToIndex(new FakeBuildRule("//:transitive_input", pathResolver));
    transitiveInput.setOutputFile("out");
    FakeNativeLinkable transitiveDep = resolver.addToIndex(new FakeNativeLinkable("//:transitive_dep", pathResolver, transitiveInput.getSourcePathToOutput()));
    FakeBuildRule firstOrderInput = resolver.addToIndex(new FakeBuildRule("//:first_order_input", pathResolver));
    firstOrderInput.setOutputFile("out");
    FakeNativeLinkable firstOrderDep = resolver.addToIndex(new FakeNativeLinkable("//:first_order_dep", pathResolver, firstOrderInput.getSourcePathToOutput(), transitiveDep));
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildRule ndkLibrary = new NdkLibraryBuilder(target).addDep(firstOrderDep.getBuildTarget()).build(resolver);
    assertThat(ndkLibrary.getDeps(), Matchers.allOf(Matchers.<BuildRule>hasItem(firstOrderInput), Matchers.<BuildRule>hasItem(transitiveInput)));
}
Also used : FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) 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