Skip to content

Commit

Permalink
NDK bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mganandraj committed Apr 13, 2022
1 parent 5a8033d commit bea84f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
14 changes: 6 additions & 8 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ android {
ndkVersion System.getenv("LOCAL_ANDROID_NDK_VERSION")
}

if (ndkVersion == null && ndkPath == null && rootProject.ext.ndkVersion != null) {
ndkVersion rootProject.ext.ndkVersion
}

defaultConfig {
minSdkVersion(21)
targetSdkVersion(31)
Expand Down Expand Up @@ -321,15 +325,9 @@ android {

// Note: On Windows there are limits on number of character in file paths and in command lines
// Ref: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Path-Length-Limits
// NDK allows circumventing command line limits using response(RSP) files as inputs using NDK_APP_SHORT_COMMANDS flag.
//
// Windows can support long file paths if configured through registry or by prefixing all file paths with a special character sequence
// The latter requires changes in NDK. And there are tools in NDK (AR) which is not able to handle long paths (>256) even after setting the registry key.
// The new architecutre source tree is too deep, and the object file naming conventions in NDK makes the matters worse, by producing incredibly long file paths.
// Other solutions such as symlinking source code etc. didn't work as expected, and makes the build scripts complicated and hard to manage.
// This change temporarily works around the issue by placing the temporary build outputs as short a path as possible within the project path.
// NDK r23+ can handle long file paths. But we are still limited by the command line limit on Windows.
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
arguments "NDK_OUT=${rootProject.projectDir.getParent()}\\.cxx",
arguments "NDK_OUT=${rootProject.projectDir}\\.cxx",
"NDK_APP_SHORT_COMMANDS=true"
}
}
Expand Down
2 changes: 1 addition & 1 deletion template/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ android {

// Fix for windows limit on number of character in file paths and in command lines
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
arguments "NDK_OUT=${rootProject.projectDir.getParent()}\\.cxx",
arguments "NDK_OUT=${rootProject.projectDir}\\.cxx",
"NDK_APP_SHORT_COMMANDS=true"
}
}
Expand Down
12 changes: 11 additions & 1 deletion template/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
Expand All @@ -6,7 +8,15 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// Note: On Windows there are limits on number of character in file paths and command lines
// Ref: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Path-Length-Limits
// NDK r23+ can handle long file paths. But we are still limited by the command line limit on Windows.
ndkVersion = "23.1.7779620"
} else {
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
Expand Down

0 comments on commit bea84f6

Please sign in to comment.