Skip to content

Commit 0f39a10

Browse files
cortinicofacebook-github-bot
authored andcommitted
Make the reactNativeArchitectures property more discoverable
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
1 parent d70555f commit 0f39a10

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ org.gradle.parallel=true
77
ANDROID_NDK_VERSION=21.4.7075529
88
android.useAndroidX=true
99
kotlin_version=1.5.31
10+
11+
# Use this property to specify which architecture you want to build.
12+
# You can also override it from the CLI using
13+
# ./gradlew <task> -PreactNativeArchitectures=x86_64
14+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

packages/rn-tester/android/app/build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ def useIntlJsc = false
135135
/**
136136
* Architectures to build native code for.
137137
*/
138-
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
139-
project.getProperties().get("reactNativeArchitectures").split(",")
140-
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
138+
def reactNativeArchitectures() {
139+
def value = project.getProperties().get("reactNativeArchitectures")
140+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
141+
}
141142

142143
android {
143144
compileSdkVersion 29
@@ -185,7 +186,7 @@ android {
185186
enable enableSeparateBuildPerCPUArchitecture
186187
universalApk false
187188
reset()
188-
include (*nativeArchitectures)
189+
include (*reactNativeArchitectures())
189190
}
190191
}
191192
buildTypes {

template/android/app/build.gradle

+6-4
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ def enableHermes = project.ext.react.get("enableHermes", false);
123123
/**
124124
* Architectures to build native code for.
125125
*/
126-
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
127-
project.getProperties().get("reactNativeArchitectures").split(",")
128-
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
126+
def reactNativeArchitectures() {
127+
def value = project.getProperties().get("reactNativeArchitectures")
128+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
129+
}
130+
129131
android {
130132
ndkVersion rootProject.ext.ndkVersion
131133

@@ -143,7 +145,7 @@ android {
143145
reset()
144146
enable enableSeparateBuildPerCPUArchitecture
145147
universalApk false // If true, also generate a universal APK
146-
include (*nativeArchitectures)
148+
include (*reactNativeArchitectures())
147149
}
148150
}
149151
signingConfigs {

template/android/gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
2828
FLIPPER_VERSION=0.99.0
29+
30+
# Use this property to specify which architecture you want to build.
31+
# You can also override it from the CLI using
32+
# ./gradlew <task> -PreactNativeArchitectures=x86_64
33+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

0 commit comments

Comments
 (0)