-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,32 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) { | |
|
||
private val objects = project.objects | ||
|
||
val root: DirectoryProperty = objects.directoryProperty() | ||
|
||
val reactNativeDir: DirectoryProperty = objects.directoryProperty() | ||
|
||
val nodeExecutableAndArgs: ListProperty<String> = objects.listProperty(String::class.java) | ||
|
||
val codegenDir: 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().convention(root.dir("node_modules/react-native")) | ||
|
||
val nodeExecutableAndArgs: ListProperty<String> = | ||
objects.listProperty(String::class.java).convention(listOf("node")) | ||
|
||
val codegenDir: DirectoryProperty = | ||
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen")) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kelset
Contributor
|
||
} |
Seems the path
node_modules/@react-native/codegen
are only for 0.72+, below 0.71 should usenode_modules/react-native-codegen