use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project bazel by bazelbuild.
the class PBXBuildFiles method get.
/**
* Returns new or cached instances of PBXBuildFiles corresponding to files that may or may not
* belong to an aggregate reference (see {@link AggregateReferenceType}). Files specified by the
* {@code paths} argument are grouped into individual PBXBuildFiles using the given
* {@link AggregateReferenceType}. Files that are standalone are not put in an aggregate
* reference, but are put in a standalone PBXBuildFile in the returned sequence.
*/
public Iterable<PBXBuildFile> get(AggregateReferenceType type, Iterable<Path> paths) {
ImmutableList.Builder<PBXBuildFile> result = new ImmutableList.Builder<>();
SetMultimap<AggregateKey, Path> keyedPaths = type.aggregates(paths);
for (Map.Entry<AggregateKey, Collection<Path>> aggregation : keyedPaths.asMap().entrySet()) {
if (!aggregation.getKey().isStandalone()) {
ImmutableSet<Path> itemPaths = ImmutableSet.copyOf(aggregation.getValue());
result.add(aggregateBuildFile(itemPaths, type.create(aggregation.getKey(), fileReferences(itemPaths))));
}
}
for (Path generalResource : keyedPaths.get(AggregateKey.standalone())) {
result.add(getStandalone(FileReference.of(generalResource.toString(), SourceTree.GROUP)));
}
return result.build();
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project bazel by bazelbuild.
the class Resources method fromTargetControls.
public static Resources fromTargetControls(FileSystem fileSystem, PBXBuildFiles pbxBuildFiles, Iterable<TargetControl> targetControls) {
ImmutableSetMultimap.Builder<TargetControl, PBXBuildFile> buildFiles = new ImmutableSetMultimap.Builder<>();
for (TargetControl targetControl : targetControls) {
List<PBXBuildFile> targetBuildFiles = new ArrayList<>();
Iterable<String> simpleImports = Iterables.concat(targetControl.getXcassetsDirList(), targetControl.getBundleImportList());
// bundle and link it properly, and add the {@code lastKnownFileType} property.
for (String simpleImport : simpleImports) {
targetBuildFiles.add(pbxBuildFiles.getStandalone(FileReference.of(simpleImport, SourceTree.GROUP)));
}
Iterables.addAll(targetBuildFiles, pbxBuildFiles.get(AggregateReferenceType.PBXVariantGroup, RelativePaths.fromStrings(fileSystem, targetControl.getGeneralResourceFileList())));
// references we generated with fileObjects will be added to the main group later.
if (!Equaling.of(ProductType.STATIC_LIBRARY, XcodeprojGeneration.productType(targetControl))) {
buildFiles.putAll(targetControl, targetBuildFiles);
}
}
return new Resources(buildFiles.build());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project bazel by bazelbuild.
the class PBXBuildFiles method aggregateBuildFile.
private PBXBuildFile aggregateBuildFile(ImmutableSet<Path> paths, PBXReference reference) {
Preconditions.checkArgument(!paths.isEmpty(), "paths must be non-empty");
for (PBXBuildFile cached : Mapping.of(aggregateBuildFiles, paths).asSet()) {
return cached;
}
PBXBuildFile buildFile = new PBXBuildFile(reference);
mainGroupReferences.add(reference);
aggregateBuildFiles.put(paths, buildFile);
return buildFile;
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project bazel by bazelbuild.
the class PBXBuildFiles method getStandalone.
/**
* Returns a new or cached instance of a PBXBuildFile for a file that is not part of a variant
* group.
*/
public PBXBuildFile getStandalone(FileReference file) {
for (PBXBuildFile cached : Mapping.of(standaloneBuildFiles, file).asSet()) {
return cached;
}
PBXBuildFile buildFile = new PBXBuildFile(pbxReferences.get(file));
mainGroupReferences.add(pbxReferences.get(file));
standaloneBuildFiles.put(file, buildFile);
return buildFile;
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project buck by facebook.
the class ProjectGeneratorTest method cxxFlagsPropagatedToConfig.
@Test
public void cxxFlagsPropagatedToConfig() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setLangPreprocessorFlags(ImmutableMap.of(CxxSource.Type.C, ImmutableList.of("-std=gnu11"), CxxSource.Type.OBJC, ImmutableList.of("-std=gnu11", "-fobjc-arc"), CxxSource.Type.CXX, ImmutableList.of("-std=c++11", "-stdlib=libc++"), CxxSource.Type.OBJCXX, ImmutableList.of("-std=c++11", "-stdlib=libc++", "-fobjc-arc"))).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo1.m")), SourceWithFlags.of(new FakeSourcePath("foo2.mm")), SourceWithFlags.of(new FakeSourcePath("foo3.c")), SourceWithFlags.of(new FakeSourcePath("foo4.cc")))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
PBXSourcesBuildPhase sourcesBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXSourcesBuildPhase.class);
ImmutableMap<String, String> expected = ImmutableMap.of("foo1.m", "-std=gnu11 -fobjc-arc", "foo2.mm", "-std=c++11 -stdlib=libc++ -fobjc-arc", "foo3.c", "-std=gnu11", "foo4.cc", "-std=c++11 -stdlib=libc++");
for (PBXBuildFile file : sourcesBuildPhase.getFiles()) {
String fileName = file.getFileRef().getName();
NSDictionary buildFileSettings = file.getSettings().get();
NSString compilerFlags = (NSString) buildFileSettings.get("COMPILER_FLAGS");
assertNotNull("Build file settings should have COMPILER_FLAGS entry", compilerFlags);
assertEquals(compilerFlags.toString(), expected.get(fileName));
}
}
Aggregations