Skip to content

Commit

Permalink
Fix incompatibility with rust and ndk
Browse files Browse the repository at this point in the history
  • Loading branch information
emakryo committed Jan 10, 2024
1 parent 20e6ef7 commit db4fe26
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions plugin/src/test/groovy/com/nishtahir/CargoBuildTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ class CargoBuildTest extends AbstractTest {
@Unroll
def "cargoBuild is invoked with #gradleVersion and Android plugin #androidVersion"() {
given:
def ndkVersion = "21.4.7075529"
SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
.withAndroidVersion(androidVersion)
.withKotlinDisabled()
.withNdkVersion(ndkVersion)
// TODO: .withCargo(...)
.build()
.writeProject()

SimpleCargoProject.builder(temporaryFolder.root)
.withTargets(["x86_64"])
.selectChannelFromNdkVersion(ndkVersion)
.build()
.writeProject()

Expand Down
6 changes: 1 addition & 5 deletions plugin/src/test/groovy/com/nishtahir/CargoTargetTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class CargoTargetTest extends AbstractTest {
given:
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
def ndkVersion = "21.4.7075529"
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"

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

SimpleCargoProject.builder(temporaryFolder.root)
.withTargets([target])
.withChannel(channel)
.selectChannelFromNdkVersion(ndkVersion)
.build()
.writeProject()

Expand Down
6 changes: 1 addition & 5 deletions plugin/src/test/groovy/com/nishtahir/NdkVersionTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class NdkVersionTest extends AbstractTest {
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
def target = "x86_64"
def location = "android/x86_64/librust.so"
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"

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

SimpleCargoProject.builder(temporaryFolder.root)
.withTargets([target])
.withChannel(channel)
.selectChannelFromNdkVersion(ndkVersion)
.build()
.writeProject()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class SimpleCargoProject {
return this
}

def selectChannelFromNdkVersion(ndkVersion) {
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
this.channel = ndkVersionMajor >= 23 ? "stable" : "1.67"
return this

}

def build() {
if (targets.isEmpty()) {
throw new IllegalStateException("No targets provided")
Expand Down

0 comments on commit db4fe26

Please sign in to comment.