Skip to content

Commit db4fe26

Browse files
committed
Fix incompatibility with rust and ndk
1 parent 20e6ef7 commit db4fe26

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

plugin/src/test/groovy/com/nishtahir/CargoBuildTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ class CargoBuildTest extends AbstractTest {
1313
@Unroll
1414
def "cargoBuild is invoked with #gradleVersion and Android plugin #androidVersion"() {
1515
given:
16+
def ndkVersion = "21.4.7075529"
1617
SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
1718
.withAndroidVersion(androidVersion)
1819
.withKotlinDisabled()
20+
.withNdkVersion(ndkVersion)
1921
// TODO: .withCargo(...)
2022
.build()
2123
.writeProject()
2224

2325
SimpleCargoProject.builder(temporaryFolder.root)
2426
.withTargets(["x86_64"])
27+
.selectChannelFromNdkVersion(ndkVersion)
2528
.build()
2629
.writeProject()
2730

plugin/src/test/groovy/com/nishtahir/CargoTargetTest.groovy

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ class CargoTargetTest extends AbstractTest {
1212
given:
1313
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
1414
def ndkVersion = "21.4.7075529"
15-
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
16-
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
17-
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
18-
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"
1915

2016
SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
2117
.withAndroidVersion(androidVersion)
@@ -27,7 +23,7 @@ class CargoTargetTest extends AbstractTest {
2723

2824
SimpleCargoProject.builder(temporaryFolder.root)
2925
.withTargets([target])
30-
.withChannel(channel)
26+
.selectChannelFromNdkVersion(ndkVersion)
3127
.build()
3228
.writeProject()
3329

plugin/src/test/groovy/com/nishtahir/NdkVersionTest.groovy

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ class NdkVersionTest extends AbstractTest {
1313
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
1414
def target = "x86_64"
1515
def location = "android/x86_64/librust.so"
16-
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
17-
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
18-
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
19-
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"
2016

2117
SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
2218
.withAndroidVersion(androidVersion)
@@ -28,7 +24,7 @@ class NdkVersionTest extends AbstractTest {
2824

2925
SimpleCargoProject.builder(temporaryFolder.root)
3026
.withTargets([target])
31-
.withChannel(channel)
27+
.selectChannelFromNdkVersion(ndkVersion)
3228
.build()
3329
.writeProject()
3430

plugin/src/test/groovy/com/nishtahir/SimpleCargoProject.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ class SimpleCargoProject {
3030
return this
3131
}
3232

33+
def selectChannelFromNdkVersion(ndkVersion) {
34+
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
35+
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
36+
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
37+
this.channel = ndkVersionMajor >= 23 ? "stable" : "1.67"
38+
return this
39+
40+
}
41+
3342
def build() {
3443
if (targets.isEmpty()) {
3544
throw new IllegalStateException("No targets provided")

0 commit comments

Comments
 (0)