[native] Support milestones in meta versions
Add milestones to MetaVersion to replace standalone parameter in compiler version generator. This makes native version match Kotlin one.
This commit is contained in:
@@ -12,26 +12,24 @@ 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+))?(?:-M(\\p{Digit}))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?".toRegex()
|
||||
private val versionPattern = "(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?".toRegex()
|
||||
|
||||
fun fromString(version: String): CompilerVersion {
|
||||
val (major, minor, maintenance, milestone, metaString, build) =
|
||||
versionPattern.matchEntire(version)?.destructured
|
||||
?: throw IllegalArgumentException("Cannot parse Kotlin/Native version: $version")
|
||||
val (major, minor, maintenance, metaString, build) =
|
||||
versionPattern.matchEntire(version)?.destructured
|
||||
?: throw IllegalArgumentException("Cannot parse Kotlin/Native version: $version")
|
||||
|
||||
return CompilerVersionImpl(
|
||||
MetaVersion.findAppropriate(metaString),
|
||||
major.toInt(),
|
||||
minor.toInt(),
|
||||
maintenance.toIntOrNull() ?: 0,
|
||||
milestone.toIntOrNull() ?: -1,
|
||||
build.toIntOrNull() ?: -1
|
||||
)
|
||||
}
|
||||
@@ -45,7 +43,6 @@ 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 {
|
||||
|
||||
@@ -55,10 +52,6 @@ data class CompilerVersionImpl(
|
||||
append(minor)
|
||||
append('.')
|
||||
append(maintenance)
|
||||
if (milestone != -1) {
|
||||
append("-M")
|
||||
append(milestone)
|
||||
}
|
||||
if (showMeta) {
|
||||
append('-')
|
||||
append(meta.metaString)
|
||||
|
||||
@@ -13,16 +13,15 @@ package org.jetbrains.kotlin.konan
|
||||
enum class MetaVersion(val metaString: String) {
|
||||
DEV("dev"),
|
||||
EAP("eap"),
|
||||
ALPHA("alpha"),
|
||||
BETA("beta"),
|
||||
RC1("rc1"),
|
||||
RC2("rc2"),
|
||||
M1("M1"),
|
||||
M2("M2"),
|
||||
RC("RC"),
|
||||
RELEASE("release");
|
||||
|
||||
companion object {
|
||||
|
||||
fun findAppropriate(metaString: String): MetaVersion {
|
||||
return MetaVersion.values().find { it.metaString.equals(metaString, ignoreCase = true) }
|
||||
return values().find { it.metaString.equals(metaString, ignoreCase = true) }
|
||||
?: if (metaString.isBlank()) RELEASE else error("Unknown meta version: $metaString")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ open class VersionGenerator: DefaultTask() {
|
||||
open val meta = (project.findProperty("konanMetaVersion") as? String ?: kotlinNativeProperties["konanMetaVersion"])?.let{ MetaVersion.valueOf(it.toString().toUpperCase()) } ?: MetaVersion.DEV
|
||||
|
||||
private val versionPattern = Pattern.compile(
|
||||
"^(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-M(\\p{Digit}))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?$"
|
||||
"^(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?$"
|
||||
)
|
||||
|
||||
fun defaultVersionFileLocation() {
|
||||
@@ -94,8 +94,6 @@ open class VersionGenerator: DefaultTask() {
|
||||
val minor = matcher.group(2).toInt()
|
||||
val maintenanceStr = matcher.group(3)
|
||||
val maintenance = maintenanceStr?.toInt() ?: 0
|
||||
val milestoneStr = matcher.group(4)
|
||||
val milestone = milestoneStr?.toInt() ?: -1
|
||||
project.logger.info("BUILD_NUMBER: $buildNumber")
|
||||
var build = -1
|
||||
if (buildNumber != null) {
|
||||
@@ -103,10 +101,8 @@ open class VersionGenerator: DefaultTask() {
|
||||
build = buildNumberSplit[buildNumberSplit.size - 1].toInt() // //7-dev-buildcount
|
||||
}
|
||||
|
||||
val versionObject = CompilerVersionImpl(meta, major, minor, maintenance, milestone, build)
|
||||
val versionObject = CompilerVersionImpl(meta, major, minor, maintenance, build)
|
||||
versionObject.serialize()
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun CompilerVersion.serialize() {
|
||||
@@ -118,7 +114,7 @@ open class VersionGenerator: DefaultTask() {
|
||||
"""|package org.jetbrains.kotlin.konan
|
||||
|internal val currentCompilerVersion: CompilerVersion =
|
||||
|CompilerVersionImpl($meta, $major, $minor,
|
||||
| $maintenance, $milestone, $build)
|
||||
| $maintenance, $build)
|
||||
|val CompilerVersion.Companion.CURRENT: CompilerVersion
|
||||
|get() = currentCompilerVersion""".trimMargin()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user