mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RNGP - Fix defaults for PrivateReactExtension
Summary: When building from source, the PrivateReactExtension is getting no defaults (or missing defaults). Specifically root should point to ../../ (as the build from source will originate from `./node_modules/react-native`). Without that root specified, all the subsequent paths are broken, specifically, the default being `../` causes the codegen to be searched inside: ``` project/node_modules/node_modules/react-native/codegen ``` which is broken Changelog: [Internal] [Changed] - RNGP - Fix defaults for PrivateReactExtension Reviewed By: cipolleschi Differential Revision: D43435590 fbshipit-source-id: 2ed5e26c1d63fd808fc2d559ea83d6d39d106ff6
This commit is contained in:
committed by
Lorenzo Sciandra
parent
f2bfe912cf
commit
cbaf4c8da2
+25
-4
@@ -25,11 +25,32 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
|
||||
|
||||
private val objects = project.objects
|
||||
|
||||
val root: DirectoryProperty = objects.directoryProperty()
|
||||
val root: DirectoryProperty =
|
||||
objects
|
||||
.directoryProperty()
|
||||
.convention(
|
||||
// This is the default for the project root if the users hasn't specified anything.
|
||||
// If the project is called "react-native-github"
|
||||
// - We're inside the Github Repo -> root is defined by RN Tester (so no default
|
||||
// needed)
|
||||
// - We're inside an includedBuild as we're performing a build from source
|
||||
// (then we're inside `node_modules/react-native`, so default should be ../../)
|
||||
// If the project is called in any other name
|
||||
// - We're inside a user project, so inside the ./android folder. Default should be
|
||||
// ../
|
||||
// User can always override this default by setting a `root =` inside the template.
|
||||
if (project.rootProject.name == "react-native-github") {
|
||||
project.rootProject.layout.projectDirectory.dir("../../")
|
||||
} else {
|
||||
project.rootProject.layout.projectDirectory.dir("../")
|
||||
})
|
||||
|
||||
val reactNativeDir: DirectoryProperty = objects.directoryProperty()
|
||||
val reactNativeDir: DirectoryProperty =
|
||||
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
|
||||
|
||||
val nodeExecutableAndArgs: ListProperty<String> = objects.listProperty(String::class.java)
|
||||
val nodeExecutableAndArgs: ListProperty<String> =
|
||||
objects.listProperty(String::class.java).convention(listOf("node"))
|
||||
|
||||
val codegenDir: DirectoryProperty = objects.directoryProperty()
|
||||
val codegenDir: DirectoryProperty =
|
||||
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user