Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Add support for NDK version 21 (#2728)
Browse files Browse the repository at this point in the history
Co-authored-by: Marces Engel <[email protected]>
  • Loading branch information
bigfootjon and marcesengel authored Oct 28, 2022
1 parent 16dc486 commit 5c6382b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ macos_environment: &macos_environment
TERM: "dumb"
BUCK_NUM_THREADS: 3
BUCK_PEX_LOCATION: "./new_buck.pex"
JAVA_HOME: "/usr/local/Cellar/openjdk@8/1.8.0+322"
JAVA_HOME: "/usr/local/Cellar/openjdk@8/1.8.0+345"

windows_environment: &windows_environment
PLATFORM: "windows"
Expand Down Expand Up @@ -1004,7 +1004,7 @@ jobs:
export PATH="${ANDROID_SDK}/tools/bin:${PATH}"
export PATH="$(pyenv root)/shims:${PATH}"
export GROOVY_HOME="$HOME/.sdkman/candidates/groovy/current"
export JAVA_HOME="/usr/local/Cellar/openjdk@8/1.8.0+322"
export JAVA_HOME="/usr/local/Cellar/openjdk@8/1.8.0+345"
export PATH="${JAVA_HOME}/bin:${PATH}"
source ~/dlang/dmd-2.091.0/activate
export PATH="${HOME}/.cargo/bin:${PATH}"
Expand Down Expand Up @@ -1062,7 +1062,7 @@ jobs:
command: |
export NDK_HOME="${HOME}/android-ndk-${PLATFORM}"
export ANDROID_HOME="${ANDROID_SDK}"
export JAVA_HOME="/usr/local/Cellar/openjdk@8/1.8.0+322"
export JAVA_HOME="/usr/local/Cellar/openjdk@8/1.8.0+345"
export PATH="${JAVA_HOME}/bin:${PATH}"
source ~/dlang/dmd-2.091.0/activate
export PATH="${HOME}/.cargo/bin:${PATH}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public class NdkCxxPlatforms {
"-Wl,--as-needed");

private static final Pattern NDK_MAJOR_VERSION_PATTERN = Pattern.compile("^[rR]?(\\d+).*");
private static final Pattern NDK_MINOR_VERSION_PATTERN = Pattern.compile("^[rR]?\\d+\\.(\\d+).*");

// Utility class, do not instantiate.
private NdkCxxPlatforms() {}
Expand All @@ -158,6 +159,15 @@ static int getNdkMajorVersion(String ndkVersion) {
return Integer.parseInt(NDK_MAJOR_VERSION_PATTERN.matcher(ndkVersion).replaceAll("$1"));
}

static int getNdkMinorVersion(String ndkVersion) {
String minorVersion = NDK_MINOR_VERSION_PATTERN.matcher(ndkVersion).replaceAll("$1");
if (minorVersion.startsWith("r") || minorVersion.startsWith("R")) {
// Failed to find a minor version, 0 is a safe fallback.
return 0;
}
return Integer.parseInt(minorVersion);
}

public static NdkCompilerType getDefaultCompilerTypeForNdk(String ndkVersion) {
return getNdkMajorVersion(ndkVersion) < 18 ? NdkCompilerType.GCC : NdkCompilerType.CLANG;
}
Expand All @@ -172,6 +182,8 @@ public static String getDefaultGccVersionForNdk(String ndkVersion) {

public static String getDefaultClangVersionForNdk(String ndkVersion) {
int ndkMajorVersion = getNdkMajorVersion(ndkVersion);
int ndkMinorVersion = getNdkMinorVersion(ndkVersion);

if (ndkMajorVersion < 11) {
return "3.5";
} else if (ndkMajorVersion < 15) {
Expand All @@ -186,8 +198,10 @@ public static String getDefaultClangVersionForNdk(String ndkVersion) {
return "8.0.2";
} else if (ndkMajorVersion < 21) {
return "8.0.7";
} else {
} else if (ndkMajorVersion == 21 && ndkMinorVersion <= 3) {
return "9.0.8";
} else {
return "9.0.9";
}
}

Expand Down

0 comments on commit 5c6382b

Please sign in to comment.