[build][native] version with milestone clause
This commit is contained in:
@@ -12,16 +12,17 @@ interface CompilerVersion : Serializable {
|
||||
val major: Int
|
||||
val minor: Int
|
||||
val maintenance: Int
|
||||
val milestone: Int
|
||||
val build: Int
|
||||
|
||||
fun toString(showMeta: Boolean, showBuild: Boolean): String
|
||||
|
||||
companion object {
|
||||
// major.minor.patch-meta-build where patch, meta and build are optional.
|
||||
private val versionPattern = "(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?".toRegex()
|
||||
private val versionPattern = "(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-M(\\p{Digit}))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?".toRegex()
|
||||
|
||||
fun fromString(version: String): CompilerVersion {
|
||||
val (major, minor, maintenance, metaString, build) =
|
||||
val (major, minor, maintenance, milestone, metaString, build) =
|
||||
versionPattern.matchEntire(version)?.destructured
|
||||
?: throw IllegalArgumentException("Cannot parse Kotlin/Native version: $version")
|
||||
|
||||
@@ -30,6 +31,7 @@ interface CompilerVersion : Serializable {
|
||||
major.toInt(),
|
||||
minor.toInt(),
|
||||
maintenance.toIntOrNull() ?: 0,
|
||||
milestone.toIntOrNull() ?: -1,
|
||||
build.toIntOrNull() ?: -1
|
||||
)
|
||||
}
|
||||
@@ -43,6 +45,7 @@ data class CompilerVersionImpl(
|
||||
override val major: Int,
|
||||
override val minor: Int,
|
||||
override val maintenance: Int,
|
||||
override val milestone: Int = 0,
|
||||
override val build: Int = -1
|
||||
) : CompilerVersion {
|
||||
|
||||
@@ -54,6 +57,10 @@ data class CompilerVersionImpl(
|
||||
append('.')
|
||||
append(maintenance)
|
||||
}
|
||||
if (milestone != -1) {
|
||||
append("-M")
|
||||
append(milestone)
|
||||
}
|
||||
if (showMeta) {
|
||||
append('-')
|
||||
append(meta.metaString)
|
||||
|
||||
Reference in New Issue
Block a user