Skip to content

Commit 85f7734

Browse files
authored
#1 failed to parse rust compiler version (#2)
Co-authored-by: matrixdev <w>
1 parent 54d4b87 commit 85f7734

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

example/app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66

77
android {
88
compileSdk = 33
9+
ndkVersion = "25.2.9519653"
910

1011
defaultConfig {
1112
applicationId = "dev.matrix.rust"

plugin/src/main/java/dev/matrix/agp/rust/AndroidRustPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class AndroidRustPlugin : Plugin<Project> {
2222
val androidExtension = project.getAndroidExtension()
2323
val androidComponents = project.getAndroidComponentsExtension()
2424
val tasksByBuildType = HashMap<String, ArrayList<TaskProvider<RustBuildTask>>>()
25-
val minimumSupportedRustVersion = SemanticVersion(extension.minimumSupportedRustVersion)
2625

2726
androidComponents.finalizeDsl { dsl ->
2827
val allRustAbiSet = mutableSetOf<Abi>()
@@ -82,6 +81,7 @@ class AndroidRustPlugin : Plugin<Project> {
8281
dsl.sourceSets.findByName(buildType.name)?.jniLibs?.srcDir(variantJniLibsDirectory)
8382
}
8483

84+
val minimumSupportedRustVersion = SemanticVersion(extension.minimumSupportedRustVersion)
8585
installRustComponentsIfNeeded(project, minimumSupportedRustVersion, allRustAbiSet)
8686
}
8787

plugin/src/main/java/dev/matrix/agp/rust/RustInstaller.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal fun installRustComponentsIfNeeded(
1313
return
1414
}
1515

16-
if (minimalVersion != null) {
16+
if (minimalVersion != null && minimalVersion.isValid) {
1717
val actualVersion = readRustCompilerVersion(project)
1818
if (actualVersion < minimalVersion) {
1919
installRustUp(project)
@@ -90,10 +90,11 @@ private fun readRustCompilerVersion(project: Project): SemanticVersion {
9090
}.assertNormalExitValue()
9191

9292
val outputText = String(output.toByteArray())
93-
val regex = Regex("^rustc (\\d+\\.\\d+\\.\\d+) .*$", RegexOption.DOT_MATCHES_ALL)
93+
val regex = Regex("^rustc (\\d+\\.\\d+\\.\\d+)(-nightly)? .*$", RegexOption.DOT_MATCHES_ALL)
9494
val match = checkNotNull(regex.matchEntire(outputText)) {
9595
"failed to parse rust compiler version: $outputText"
9696
}
97+
9798
return SemanticVersion(match.groupValues[1])
9899
}
99100

0 commit comments

Comments
 (0)