use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryConfiguresOutputPaths.
@Test
public void testAppleLibraryConfiguresOutputPaths() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setHeaderPathPrefix(Optional.of("MyHeaderPathPrefix")).setPrefixHeader(Optional.of(new FakeSourcePath("Foo/Foo-Prefix.pch"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
assertThat(target.isa(), equalTo("PBXNativeTarget"));
assertThat(target.getProductType(), equalTo(ProductType.STATIC_LIBRARY));
ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
assertEquals("../Foo/Foo-Prefix.pch", settings.get("GCC_PREFIX_HEADER"));
assertEquals("$SYMROOT/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME", settings.get("BUILT_PRODUCTS_DIR"));
assertEquals("$BUILT_PRODUCTS_DIR", settings.get("CONFIGURATION_BUILD_DIR"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testScriptBuildPhase.
@Test
public void testScriptBuildPhase() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
TargetNode<?, ?> prebuildNode = XcodePrebuildScriptBuilder.createBuilder(BuildTargetFactory.newInstance("//foo:script")).setSrcs(ImmutableSortedSet.of(new FakeSourcePath("script/input.png"))).setOutputs(ImmutableSortedSet.of("helloworld.txt")).setCmd("echo \"hello world!\"").build();
mutator.setPostBuildRunScriptPhasesFromTargetNodes(ImmutableList.of(prebuildNode));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
PBXShellScriptBuildPhase phase = getSingletonPhaseByType(result.target, PBXShellScriptBuildPhase.class);
assertThat("Should set input paths correctly", "../script/input.png", is(equalTo(Iterables.getOnlyElement(phase.getInputPaths()))));
assertThat("Should set output paths correctly", "helloworld.txt", is(equalTo(Iterables.getOnlyElement(phase.getOutputPaths()))));
assertEquals("should set script correctly", "echo \"hello world!\"", phase.getShellScript());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testLibraryHeaderGroups.
@Test
public void testLibraryHeaderGroups() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
SourcePath foo = new FakeSourcePath("HeaderGroup1/foo.h");
SourcePath bar = new FakeSourcePath("HeaderGroup1/bar.h");
SourcePath baz = new FakeSourcePath("HeaderGroup2/baz.h");
mutator.setPublicHeaders(ImmutableSet.of(bar, baz));
mutator.setPrivateHeaders(ImmutableSet.of(foo));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
PBXGroup sourcesGroup = result.targetGroup.get().getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(2));
PBXGroup group1 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("HeaderGroup1", group1.getName());
assertThat(group1.getChildren(), hasSize(2));
PBXFileReference fileRefBar = (PBXFileReference) Iterables.get(group1.getChildren(), 0);
assertEquals("bar.h", fileRefBar.getName());
PBXFileReference fileRefFoo = (PBXFileReference) Iterables.get(group1.getChildren(), 1);
assertEquals("foo.h", fileRefFoo.getName());
PBXGroup group2 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 1);
assertEquals("HeaderGroup2", group2.getName());
assertThat(group2.getChildren(), hasSize(1));
PBXFileReference fileRefBaz = (PBXFileReference) Iterables.get(group2.getChildren(), 0);
assertEquals("baz.h", fileRefBaz.getName());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testResourcesBuildPhase.
@Test
public void testResourcesBuildPhase() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
AppleResourceDescription appleResourceDescription = new AppleResourceDescription();
AppleResourceDescription.Arg arg = createDescriptionArgWithDefaults(appleResourceDescription);
arg.files = ImmutableSet.of(new FakeSourcePath("foo.png"));
mutator.setRecursiveResources(ImmutableSet.of(arg));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
assertHasSingletonPhaseWithEntries(result.target, PBXResourcesBuildPhase.class, ImmutableList.of("$SOURCE_ROOT/../foo.png"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryRule.
@Test
public void testCxxLibraryRule() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> cxxNode = new CxxLibraryBuilder(buildTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.cpp"), ImmutableList.of("-foo")), SourceWithFlags.of(new FakeSourcePath("bar.cpp")))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(cxxNode));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
assertThat(target.isa(), equalTo("PBXNativeTarget"));
assertThat(target.getProductType(), equalTo(ProductType.STATIC_LIBRARY));
assertHasConfigurations(target, "Debug", "Release", "Profile");
assertEquals("Should have exact number of build phases", 1, target.getBuildPhases().size());
assertHasSingletonSourcesPhaseWithSourcesAndFlags(target, ImmutableMap.of("foo.cpp", Optional.of("-foo"), "bar.cpp", Optional.empty()));
}
Aggregations