Skip to content

Commit

Permalink
configure to build from source
Browse files Browse the repository at this point in the history
Summary: Configure helloworld to build from source, using a combination of our [How to Build from Source](https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source) guide, as well as using rn-tester's config as a guide.

Differential Revision: D58287748
  • Loading branch information
blakef authored and facebook-github-bot committed Jun 12, 2024
1 parent 913a768 commit 43a531b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/helloworld/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ react {
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
reactNativeDir = file("../../../react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
codegenDir = file("../../../react-native-codegen")
codegenDir = file("$rootDir/node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js,
// but now points to our simplified bundle wrapper.
cliFile = file("../../scripts/bundle.js")
Expand Down
10 changes: 9 additions & 1 deletion packages/helloworld/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
*/

// Autolinking has now moved into the React Native Gradle Plugin
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
pluginManagement { includeBuild("../../react-native-gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }

rootProject.name = 'HelloWorld'
include ':app'
includeBuild('../../react-native-gradle-plugin')
includeBuild('../../react-native') {
dependencySubstitution {
substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
}
}
10 changes: 9 additions & 1 deletion packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,15 @@ react {
// module to apply the plugin to, so it's codegenDir and reactNativeDir won't be evaluated.
if (rootProject.name == "react-native-build-from-source") {
rootProject.extensions.getByType(PrivateReactExtension::class.java).apply {
codegenDir = file("$rootDir/../@react-native/codegen")
// We try to guess where codegen lives. Generally is inside
// node_modules/@react-native/codegen. If the file is not existing, we
// fallback to ../react-native-codegen (used for hello-world app).
codegenDir =
if (file("$rootDir/../@react-native/codegen").exists()) {
file("$rootDir/../@react-native/codegen")
} else {
file("$rootDir/../react-native-codegen")
}
reactNativeDir = file("$rootDir")
}
}
Expand Down

0 comments on commit 43a531b

Please sign in to comment.