mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
Codegen Android: build react-native-codegen via yarn when building from source
Summary: The Gradle codegen integration requires the JS CLI to be first built via `yarn run build`. This commit puts that logic in a `build.sh` script, then defines a Gradle task to build it. Changelog: [Internal] Reviewed By: hramos Differential Revision: D24556992 fbshipit-source-id: 7092de7c1126edc157b122f4b2243e55f7188846
This commit is contained in:
parent
3ddba567a8
commit
f2ba978cad
@ -23,3 +23,24 @@ allprojects {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
// This task is required when using react-native-codegen from source, instead of npm.
|
||||
task('buildCodegenCLI', type: Exec) {
|
||||
def codegenRoot = "$projectDir/.."
|
||||
|
||||
inputs.files(
|
||||
file("$codegenRoot/scripts"),
|
||||
file("$codegenRoot/src"),
|
||||
file("$codegenRoot/package.json"),
|
||||
file("$codegenRoot/.babelrc"),
|
||||
file("$codegenRoot/.prettierrc"),
|
||||
)
|
||||
|
||||
def libDir = file("$codegenRoot/lib")
|
||||
libDir.mkdirs()
|
||||
def nodeModulesDir = file("$codegenRoot/node_modules")
|
||||
nodeModulesDir.mkdirs();
|
||||
outputs.dirs(libDir, nodeModulesDir)
|
||||
|
||||
commandLine("$codegenRoot/scripts/oss/build.sh")
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ public class CodegenPlugin implements Plugin<Project> {
|
||||
return;
|
||||
}
|
||||
|
||||
// This is needed when using codegen from source, not from npm.
|
||||
task.dependsOn(":packages:react-native-codegen:android:buildCodegenCLI");
|
||||
|
||||
task.doFirst(
|
||||
s -> {
|
||||
generatedSrcDir.delete();
|
||||
|
19
packages/react-native-codegen/scripts/oss/build.sh
Executable file
19
packages/react-native-codegen/scripts/oss/build.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
# This script assumes yarn is already installed.
|
||||
|
||||
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pushd "$THIS_DIR/../.." >/dev/null
|
||||
|
||||
yarn install 2> >(grep -v '^warning' 1>&2)
|
||||
yarn run build
|
||||
|
||||
popd >/dev/null
|
@ -15,6 +15,7 @@ pluginManagement {
|
||||
|
||||
include(
|
||||
":ReactAndroid",
|
||||
":packages:react-native-codegen:android",
|
||||
":packages:rn-tester:android:app"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user