-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Allow configuring ndk build architectures #31232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -326,6 +326,14 @@ def reactNativeInspectorProxyPort() { | |
| return value != null ? value : reactNativeDevServerPort() | ||
| } | ||
|
|
||
| def reactNativeArchitectures() { | ||
| def isDebug = gradle.startParameter.taskRequests.any { | ||
| it.args.any { it.endsWith("Debug") } | ||
| } | ||
| def value = project.getProperties().get("reactNativeDebugArchitectures") | ||
| return value != null && isDebug ? value : "all" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "all" value valid for the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is only used with ndk-build so the all value is fine. |
||
| } | ||
|
|
||
| def getNdkBuildFullPath() { | ||
| def ndkBuildFullPath = findNdkBuildFullPath() | ||
| if (ndkBuildFullPath == null) { | ||
|
|
@@ -355,6 +363,7 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) { | |
| inputs.dir("src/main/java/com/facebook/react/modules/blob") | ||
| outputs.dir("$buildDir/react-ndk/all") | ||
| commandLine(getNdkBuildFullPath(), | ||
| "APP_ABI=${reactNativeArchitectures()}", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe safeguard the debug version here as well? 🙂
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed since
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, my intention is to avoid hacking the debug check based on the task name and use flags from the build task itself, that's why I am asking about it :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I tried finding a better way to detect wether it was a debug or release build but could not find it. The task is the same for both build types so at that point from what I could see it is not possible to know without the gradle invocation args. One more involved solution that I could see is create a different task per variant for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see it now, didn't realize we always compile the build with NDK_DEBUG set to 0. I guess it doesn't matter much for this module now, as we build everything on the CI anyways and distribute binaries only. |
||
| "NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"), | ||
| "NDK_PROJECT_PATH=null", | ||
| "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,11 @@ def enableFabric = project.ext.react.enableFabric | |
| */ | ||
| def useIntlJsc = false | ||
|
|
||
| /** | ||
| * Architectures to build native code for in debug. | ||
| */ | ||
| def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") | ||
|
|
||
| android { | ||
| compileSdkVersion 29 | ||
| ndkVersion ANDROID_NDK_VERSION | ||
|
|
@@ -176,6 +181,11 @@ android { | |
| debug { | ||
| debuggable true | ||
| signingConfig signingConfigs.release | ||
| if (nativeArchitectures) { | ||
| ndk { | ||
| abiFilters nativeArchitectures.split(',') | ||
| } | ||
| } | ||
| } | ||
| release { | ||
| debuggable false | ||
|
|
@@ -251,7 +261,6 @@ if (enableCodegen) { | |
| defaultConfig { | ||
| externalNativeBuild { | ||
| ndkBuild { | ||
| abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the default already according to https://developer.android.com/ndk/guides/abis. This will use the project wide config added a few lines up. |
||
| arguments "APP_PLATFORM=android-21", | ||
| "APP_STL=c++_shared", | ||
| "NDK_TOOLCHAIN_VERSION=clang", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.