Search in sources :

Example 1 with ReactNativeLibraryArgs

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();
}
Also used : TargetNode(com.facebook.buck.rules.TargetNode) ReactNativeLibraryArgs(com.facebook.buck.js.ReactNativeLibraryArgs) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath)

Example 2 with ReactNativeLibraryArgs

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();
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) Path(java.nio.file.Path) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) ST(org.stringtemplate.v4.ST) BuildTarget(com.facebook.buck.model.BuildTarget) IOException(java.io.IOException) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ReactNativeLibraryArgs(com.facebook.buck.js.ReactNativeLibraryArgs)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 ReactNativeLibraryArgs (com.facebook.buck.js.ReactNativeLibraryArgs)2 BuildTarget (com.facebook.buck.model.BuildTarget)2 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)1 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)1 SourcePath (com.facebook.buck.rules.SourcePath)1 TargetNode (com.facebook.buck.rules.TargetNode)1 FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ST (org.stringtemplate.v4.ST)1