Search in sources :

Example 1 with HalideLibraryBuilder

use of com.facebook.buck.halide.HalideLibraryBuilder in project buck by facebook.

the class ProjectGeneratorTest method testHalideLibraryRule.

@Test
public void testHalideLibraryRule() throws IOException {
    BuildTarget compilerTarget = BuildTarget.builder(rootPath, "//foo", "lib").addFlavors(HalideLibraryDescription.HALIDE_COMPILER_FLAVOR).build();
    TargetNode<?, ?> compiler = new HalideLibraryBuilder(compilerTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("main.cpp")), SourceWithFlags.of(new FakeSourcePath("filter.cpp")))).build();
    BuildTarget libTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> lib = new HalideLibraryBuilder(libTarget).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(compiler, lib));
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
    assertThat(target.isa(), equalTo("PBXNativeTarget"));
    assertHasConfigurations(target, "Debug", "Release", "Profile");
    assertEquals(1, target.getBuildPhases().size());
    PBXShellScriptBuildPhase scriptPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXShellScriptBuildPhase.class);
    assertEquals(0, scriptPhase.getInputPaths().size());
    assertEquals(0, scriptPhase.getOutputPaths().size());
    // Note that we require that both the Halide "compiler" and the unflavored
    // library target are present in the requiredBuildTargets, so that both the
    // compiler and the generated header for the pipeline will be available for
    // use by the Xcode compilation step.
    ImmutableSet<BuildTarget> requiredBuildTargets = projectGenerator.getRequiredBuildTargets();
    assertTrue(requiredBuildTargets.contains(compilerTarget));
    assertThat(requiredBuildTargets, hasItem(libTarget.withFlavors(HalideLibraryDescription.HALIDE_COMPILE_FLAVOR, DEFAULT_PLATFORM.getFlavor())));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) PBXShellScriptBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase) BuildTarget(com.facebook.buck.model.BuildTarget) HalideLibraryBuilder(com.facebook.buck.halide.HalideLibraryBuilder) Test(org.junit.Test)

Aggregations

PBXShellScriptBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase)1 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)1 HalideLibraryBuilder (com.facebook.buck.halide.HalideLibraryBuilder)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)1 Test (org.junit.Test)1