use of com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference in project bazel by bazelbuild.
the class PBXFileReferences method get.
/**
* Supplies a reference, containing values for fields specified in {@code reference}.
*/
public PBXFileReference get(FileReference reference) {
for (PBXFileReference existing : Mapping.of(cache, reference).asSet()) {
return existing;
}
PBXFileReference result = new PBXFileReference(reference.name(), reference.path().orNull(), reference.sourceTree());
result.setExplicitFileType(reference.explicitFileType());
cache.put(reference, result);
return result;
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference in project bazel by bazelbuild.
the class CurrentVersionSetter method trySetCurrentVersion.
private void trySetCurrentVersion(XCVersionGroup group) {
if (group.getSourceTree() != SourceTree.GROUP) {
return;
}
Path groupPath = workspaceRoot.resolve(group.getPath());
Path currentVersionPlist = groupPath.resolve(".xccurrentversion");
if (!Files.isReadable(currentVersionPlist)) {
return;
}
NSDictionary plist;
try {
plist = PlistMerging.readPlistFile(currentVersionPlist);
} catch (IOException e) {
return;
}
NSString currentVersion = (NSString) plist.get("_XCCurrentVersionName");
if (currentVersion == null) {
return;
}
for (PBXFileReference child : group.getChildren()) {
child.setExplicitFileType(Optional.of("wrapper.xcdatamodel"));
if (child.getName().equals(currentVersion.getContent())) {
group.setCurrentVersion(Optional.of(child));
}
}
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testSourceGroups.
@Test
public void testSourceGroups() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
SourcePath foo = new FakeSourcePath("Group1/foo.m");
SourcePath bar = new FakeSourcePath("Group1/bar.m");
SourcePath baz = new FakeSourcePath("Group2/baz.m");
mutator.setSourcesWithFlags(ImmutableSet.of(SourceWithFlags.of(foo), SourceWithFlags.of(bar, ImmutableList.of("-Wall")), SourceWithFlags.of(baz)));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
PBXGroup sourcesGroup = result.targetGroup.get().getOrCreateChildGroupByName("Sources");
PBXGroup group1 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("Group1", group1.getName());
assertThat(group1.getChildren(), hasSize(2));
PBXFileReference fileRefBar = (PBXFileReference) Iterables.get(group1.getChildren(), 0);
assertEquals("bar.m", fileRefBar.getName());
PBXFileReference fileRefFoo = (PBXFileReference) Iterables.get(group1.getChildren(), 1);
assertEquals("foo.m", fileRefFoo.getName());
PBXGroup group2 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 1);
assertEquals("Group2", group2.getName());
assertThat(group2.getChildren(), hasSize(1));
PBXFileReference fileRefBaz = (PBXFileReference) Iterables.get(group2.getChildren(), 0);
assertEquals("baz.m", fileRefBaz.getName());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testFrameworkBuildPhase.
@Test
public void testFrameworkBuildPhase() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
mutator.setFrameworks(ImmutableSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Foo.framework"), Optional.empty()))));
mutator.setArchives(ImmutableSet.of(new PBXFileReference("libdep.a", "libdep.a", PBXReference.SourceTree.BUILT_PRODUCTS_DIR, Optional.empty())));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
assertHasSingletonFrameworksPhaseWithFrameworkEntries(result.target, ImmutableList.of("$SDKROOT/Foo.framework", "$BUILT_PRODUCTS_DIR/libdep.a"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testPrefixHeaderInSourceGroup.
@Test
public void testPrefixHeaderInSourceGroup() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
SourcePath prefixHeader = new FakeSourcePath("Group1/prefix.pch");
mutator.setPrefixHeader(Optional.of(prefixHeader));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
// No matter where the prefixHeader file is it should always be directly inside Sources
PBXGroup sourcesGroup = result.targetGroup.get().getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(1));
PBXFileReference fileRef = (PBXFileReference) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("prefix.pch", fileRef.getName());
}
Aggregations