use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project buck by facebook.
the class NewNativeTargetProjectMutator method addSourcePathToSourcesBuildPhase.
private void addSourcePathToSourcesBuildPhase(SourceWithFlags sourceWithFlags, PBXGroup sourcesGroup, PBXSourcesBuildPhase sourcesBuildPhase) {
SourceTreePath sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(sourcePathResolver.apply(sourceWithFlags.getSourcePath())), Optional.empty());
PBXFileReference fileReference = sourcesGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
PBXBuildFile buildFile = new PBXBuildFile(fileReference);
sourcesBuildPhase.getFiles().add(buildFile);
ImmutableList<String> customLangPreprocessorFlags = ImmutableList.of();
Optional<CxxSource.Type> sourceType = CxxSource.Type.fromExtension(Files.getFileExtension(sourceTreePath.toString()));
if (sourceType.isPresent() && langPreprocessorFlags.containsKey(sourceType.get())) {
customLangPreprocessorFlags = langPreprocessorFlags.get(sourceType.get());
}
ImmutableList<String> customFlags = ImmutableList.copyOf(Iterables.concat(customLangPreprocessorFlags, sourceWithFlags.getFlags()));
if (!customFlags.isEmpty()) {
NSDictionary settings = new NSDictionary();
settings.put("COMPILER_FLAGS", Joiner.on(' ').join(customFlags));
buildFile.setSettings(Optional.of(settings));
}
LOG.verbose("Added source path %s to group %s, flags %s, PBXFileReference %s", sourceWithFlags, sourcesGroup.getName(), customFlags, fileReference);
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project buck by facebook.
the class ProjectGenerator method getSingleCopyFilesBuildPhase.
private PBXCopyFilesBuildPhase getSingleCopyFilesBuildPhase(CopyFilePhaseDestinationSpec destinationSpec, Iterable<TargetNode<?, ?>> targetNodes) {
PBXCopyFilesBuildPhase copyFilesBuildPhase = new PBXCopyFilesBuildPhase(destinationSpec);
HashSet<UnflavoredBuildTarget> frameworkTargets = new HashSet<UnflavoredBuildTarget>();
for (TargetNode<?, ?> targetNode : targetNodes) {
PBXFileReference fileReference = getLibraryFileReference(targetNode);
PBXBuildFile buildFile = new PBXBuildFile(fileReference);
if (fileReference.getExplicitFileType().equals(Optional.of("wrapper.framework"))) {
UnflavoredBuildTarget buildTarget = targetNode.getBuildTarget().getUnflavoredBuildTarget();
if (frameworkTargets.contains(buildTarget)) {
continue;
}
frameworkTargets.add(buildTarget);
NSDictionary settings = new NSDictionary();
settings.put("ATTRIBUTES", new String[] { "CodeSignOnCopy", "RemoveHeadersOnCopy" });
buildFile.setSettings(Optional.of(settings));
}
copyFilesBuildPhase.getFiles().add(buildFile);
}
return copyFilesBuildPhase;
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project buck by facebook.
the class NewNativeTargetProjectMutator method addResourcesBuildPhase.
private PBXBuildPhase addResourcesBuildPhase(PBXNativeTarget target, PBXGroup targetGroup) {
ImmutableSet.Builder<Path> resourceFiles = ImmutableSet.builder();
ImmutableSet.Builder<Path> resourceDirs = ImmutableSet.builder();
ImmutableSet.Builder<Path> variantResourceFiles = ImmutableSet.builder();
collectResourcePathsFromConstructorArgs(recursiveResources, recursiveAssetCatalogs, wrapperResources, resourceFiles, resourceDirs, variantResourceFiles);
final PBXBuildPhase phase = new PBXResourcesBuildPhase();
addResourcesFileReference(targetGroup, resourceFiles.build(), resourceDirs.build(), variantResourceFiles.build(), input -> {
PBXBuildFile buildFile = new PBXBuildFile(input);
phase.getFiles().add(buildFile);
}, input -> {
PBXBuildFile buildFile = new PBXBuildFile(input);
phase.getFiles().add(buildFile);
});
if (!phase.getFiles().isEmpty()) {
target.getBuildPhases().add(phase);
LOG.debug("Added resources build phase %s", phase);
}
return phase;
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile in project buck by facebook.
the class NewNativeTargetProjectMutator method addFrameworksBuildPhase.
private void addFrameworksBuildPhase(PBXProject project, PBXNativeTarget target) {
if (frameworks.isEmpty() && archives.isEmpty()) {
return;
}
PBXGroup sharedFrameworksGroup = project.getMainGroup().getOrCreateChildGroupByName("Frameworks");
PBXFrameworksBuildPhase frameworksBuildPhase = new PBXFrameworksBuildPhase();
target.getBuildPhases().add(frameworksBuildPhase);
for (FrameworkPath framework : frameworks) {
SourceTreePath sourceTreePath;
if (framework.getSourceTreePath().isPresent()) {
sourceTreePath = framework.getSourceTreePath().get();
} else if (framework.getSourcePath().isPresent()) {
sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputPathToSourcePath(framework.getSourcePath().get()), Optional.empty());
} else {
throw new RuntimeException();
}
PBXFileReference fileReference = sharedFrameworksGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
frameworksBuildPhase.getFiles().add(new PBXBuildFile(fileReference));
}
for (PBXFileReference archive : archives) {
frameworksBuildPhase.getFiles().add(new PBXBuildFile(archive));
}
}
Aggregations