use of com.facebook.buck.apple.AppleWrapperResourceArg in project buck by facebook.
the class NewNativeTargetProjectMutator method collectResourcePathsFromConstructorArgs.
private void collectResourcePathsFromConstructorArgs(Set<AppleResourceDescription.Arg> resourceArgs, Set<AppleAssetCatalogDescription.Arg> assetCatalogArgs, Set<AppleWrapperResourceArg> resourcePathArgs, ImmutableSet.Builder<Path> resourceFilesBuilder, ImmutableSet.Builder<Path> resourceDirsBuilder, ImmutableSet.Builder<Path> variantResourceFilesBuilder) {
for (AppleResourceDescription.Arg arg : resourceArgs) {
resourceFilesBuilder.addAll(Iterables.transform(arg.files, sourcePathResolver));
resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver));
variantResourceFilesBuilder.addAll(Iterables.transform(arg.variants, sourcePathResolver));
}
for (AppleAssetCatalogDescription.Arg arg : assetCatalogArgs) {
resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver));
}
for (AppleWrapperResourceArg arg : resourcePathArgs) {
resourceDirsBuilder.add(arg.path);
}
}
use of com.facebook.buck.apple.AppleWrapperResourceArg in project buck by facebook.
the class ProjectGenerator method addSceneKitAssetsIntoTarget.
private void addSceneKitAssetsIntoTarget(TargetNode<? extends CxxLibraryDescription.Arg, ?> targetNode, PBXGroup targetGroup) throws IOException {
ImmutableSet<AppleWrapperResourceArg> allSceneKitAssets = AppleBuildRules.collectTransitiveBuildRules(targetGraph, Optional.of(dependenciesCache), AppleBuildRules.SCENEKIT_ASSETS_DESCRIPTION_CLASSES, ImmutableList.of(targetNode));
for (final AppleWrapperResourceArg sceneKitAssets : allSceneKitAssets) {
PBXGroup resourcesGroup = targetGroup.getOrCreateChildGroupByName("Resources");
resourcesGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(sceneKitAssets.path), Optional.empty()));
}
}
use of com.facebook.buck.apple.AppleWrapperResourceArg in project buck by facebook.
the class ProjectGenerator method addCoreDataModelBuildPhase.
private void addCoreDataModelBuildPhase(PBXGroup targetGroup, Iterable<AppleWrapperResourceArg> dataModels) throws IOException {
for (final AppleWrapperResourceArg dataModel : dataModels) {
// Core data models go in the resources group also.
PBXGroup resourcesGroup = targetGroup.getOrCreateChildGroupByName("Resources");
if (CoreDataModelDescription.isVersionedDataModel(dataModel)) {
// It's safe to do I/O here to figure out the current version because we're returning all
// the versions and the file pointing to the current version from
// getInputsToCompareToOutput(), so the rule will be correctly detected as stale if any of
// them change.
final String currentVersionFileName = ".xccurrentversion";
final String currentVersionKey = "_XCCurrentVersionName";
final XCVersionGroup versionGroup = resourcesGroup.getOrCreateChildVersionGroupsBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(dataModel.path), Optional.empty()));
projectFilesystem.walkRelativeFileTree(dataModel.path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
if (dir.equals(dataModel.path)) {
return FileVisitResult.CONTINUE;
}
versionGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(dir), Optional.empty()));
return FileVisitResult.SKIP_SUBTREE;
}
});
Path currentVersionPath = dataModel.path.resolve(currentVersionFileName);
try (InputStream in = projectFilesystem.newFileInputStream(currentVersionPath)) {
NSObject rootObject;
try {
rootObject = PropertyListParser.parse(in);
} catch (IOException e) {
throw e;
} catch (Exception e) {
rootObject = null;
}
if (!(rootObject instanceof NSDictionary)) {
throw new HumanReadableException("Malformed %s file.", currentVersionFileName);
}
NSDictionary rootDictionary = (NSDictionary) rootObject;
NSObject currentVersionName = rootDictionary.objectForKey(currentVersionKey);
if (!(currentVersionName instanceof NSString)) {
throw new HumanReadableException("Malformed %s file.", currentVersionFileName);
}
PBXFileReference ref = versionGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(dataModel.path.resolve(currentVersionName.toString())), Optional.empty()));
versionGroup.setCurrentVersion(Optional.of(ref));
} catch (NoSuchFileException e) {
if (versionGroup.getChildren().size() == 1) {
versionGroup.setCurrentVersion(Optional.of(Iterables.get(versionGroup.getChildren(), 0)));
}
}
} else {
resourcesGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(dataModel.path), Optional.empty()));
}
}
}
Aggregations