Skip to content

Commit

Permalink
Make the reactNativeArchitectures property more discoverable
Browse files Browse the repository at this point in the history
Summary:
I've unified the function that is responsible of getting the `reactNativeArchitectures` property
to a single one (ideally we could move it inside the Gradle Plugin in the future).
I've also added a property in the `gradle.properties` file. This makes easier for users to customize the
architecture to build without having to specify a CLI flag or edit multiple gradle files.

Changelog:
[Android] [Added] - Make the `reactNativeArchitectures` property more discoverable

Reviewed By: ShikaSD

Differential Revision: D32244997

fbshipit-source-id: 33180544400f9abe63e9b539ff16fefa17a024ba
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 8, 2021
1 parent d70555f commit 0f39a10
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ org.gradle.parallel=true
ANDROID_NDK_VERSION=21.4.7075529
android.useAndroidX=true
kotlin_version=1.5.31

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
9 changes: 5 additions & 4 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ def useIntlJsc = false
/**
* Architectures to build native code for.
*/
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
project.getProperties().get("reactNativeArchitectures").split(",")
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
compileSdkVersion 29
Expand Down Expand Up @@ -185,7 +186,7 @@ android {
enable enableSeparateBuildPerCPUArchitecture
universalApk false
reset()
include (*nativeArchitectures)
include (*reactNativeArchitectures())
}
}
buildTypes {
Expand Down
10 changes: 6 additions & 4 deletions template/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def enableHermes = project.ext.react.get("enableHermes", false);
/**
* Architectures to build native code for.
*/
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
project.getProperties().get("reactNativeArchitectures").split(",")
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
ndkVersion rootProject.ext.ndkVersion

Expand All @@ -143,7 +145,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*nativeArchitectures)
include (*reactNativeArchitectures())
}
}
signingConfigs {
Expand Down
5 changes: 5 additions & 0 deletions template/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.99.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

0 comments on commit 0f39a10

Please sign in to comment.