use of com.facebook.buck.js.ReactNativeLibraryArgs in project buck by facebook.
the class AppleResources method collectResourceDirsAndFiles.
public static <T> AppleBundleResources collectResourceDirsAndFiles(final TargetGraph targetGraph, final Optional<AppleDependenciesCache> cache, TargetNode<T, ?> targetNode) {
AppleBundleResources.Builder builder = AppleBundleResources.builder();
Iterable<TargetNode<?, ?>> resourceNodes = AppleBuildRules.getRecursiveTargetNodeDependenciesOfTypes(targetGraph, cache, AppleBuildRules.RecursiveDependenciesMode.COPYING, targetNode, Optional.of(APPLE_RESOURCE_DESCRIPTION_CLASSES));
ProjectFilesystem filesystem = targetNode.getFilesystem();
for (TargetNode<?, ?> resourceNode : resourceNodes) {
Object constructorArg = resourceNode.getConstructorArg();
if (constructorArg instanceof AppleResourceDescription.Arg) {
AppleResourceDescription.Arg appleResource = (AppleResourceDescription.Arg) constructorArg;
builder.addAllResourceDirs(appleResource.dirs);
builder.addAllResourceFiles(appleResource.files);
builder.addAllResourceVariantFiles(appleResource.variants);
} else {
Preconditions.checkState(constructorArg instanceof ReactNativeLibraryArgs);
BuildTarget buildTarget = resourceNode.getBuildTarget();
builder.addDirsContainingResourceDirs(new ExplicitBuildTargetSourcePath(buildTarget, ReactNativeBundle.getPathToJSBundleDir(buildTarget, filesystem)), new ExplicitBuildTargetSourcePath(buildTarget, ReactNativeBundle.getPathToResources(buildTarget, filesystem)));
}
}
return builder.build();
}
use of com.facebook.buck.js.ReactNativeLibraryArgs in project buck by facebook.
the class NewNativeTargetProjectMutator method generateXcodeShellScript.
private String generateXcodeShellScript(TargetNode<?, ?> targetNode) {
Preconditions.checkArgument(targetNode.getConstructorArg() instanceof ReactNativeLibraryArgs);
ST template;
try {
template = new ST(Resources.toString(Resources.getResource(NewNativeTargetProjectMutator.class, REACT_NATIVE_PACKAGE_TEMPLATE), Charsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("There was an error loading 'rn_package.st' template", e);
}
ReactNativeLibraryArgs args = (ReactNativeLibraryArgs) targetNode.getConstructorArg();
template.add("bundle_name", args.bundleName);
ProjectFilesystem filesystem = targetNode.getFilesystem();
BuildTarget buildTarget = targetNode.getBuildTarget();
Path jsOutput = ReactNativeBundle.getPathToJSBundleDir(buildTarget, filesystem).resolve(args.bundleName);
template.add("built_bundle_path", filesystem.resolve(jsOutput));
Path resourceOutput = ReactNativeBundle.getPathToResources(buildTarget, filesystem);
template.add("built_resources_path", filesystem.resolve(resourceOutput));
Path sourceMap = ReactNativeBundle.getPathToSourceMap(buildTarget, filesystem);
template.add("built_source_map_path", filesystem.resolve(sourceMap));
return template.render();
}
Aggregations