[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 major: Int
|
||||||
val minor: Int
|
val minor: Int
|
||||||
val maintenance: Int
|
val maintenance: Int
|
||||||
val milestone: Int
|
|
||||||
val build: Int
|
val build: Int
|
||||||
|
|
||||||
fun toString(showMeta: Boolean, showBuild: Boolean): String
|
fun toString(showMeta: Boolean, showBuild: Boolean): String
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// major.minor.patch-meta-build where patch, meta and build are optional.
|
// 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 {
|
fun fromString(version: String): CompilerVersion {
|
||||||
val (major, minor, maintenance, milestone, metaString, build) =
|
val (major, minor, maintenance, metaString, build) =
|
||||||
versionPattern.matchEntire(version)?.destructured
|
versionPattern.matchEntire(version)?.destructured
|
||||||
?: throw IllegalArgumentException("Cannot parse Kotlin/Native version: $version")
|
?: throw IllegalArgumentException("Cannot parse Kotlin/Native version: $version")
|
||||||
|
|
||||||
return CompilerVersionImpl(
|
return CompilerVersionImpl(
|
||||||
MetaVersion.findAppropriate(metaString),
|
MetaVersion.findAppropriate(metaString),
|
||||||
major.toInt(),
|
major.toInt(),
|
||||||
minor.toInt(),
|
minor.toInt(),
|
||||||
maintenance.toIntOrNull() ?: 0,
|
maintenance.toIntOrNull() ?: 0,
|
||||||
milestone.toIntOrNull() ?: -1,
|
|
||||||
build.toIntOrNull() ?: -1
|
build.toIntOrNull() ?: -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -45,7 +43,6 @@ data class CompilerVersionImpl(
|
|||||||
override val major: Int,
|
override val major: Int,
|
||||||
override val minor: Int,
|
override val minor: Int,
|
||||||
override val maintenance: Int,
|
override val maintenance: Int,
|
||||||
override val milestone: Int = 0,
|
|
||||||
override val build: Int = -1
|
override val build: Int = -1
|
||||||
) : CompilerVersion {
|
) : CompilerVersion {
|
||||||
|
|
||||||
@@ -55,10 +52,6 @@ data class CompilerVersionImpl(
|
|||||||
append(minor)
|
append(minor)
|
||||||
append('.')
|
append('.')
|
||||||
append(maintenance)
|
append(maintenance)
|
||||||
if (milestone != -1) {
|
|
||||||
append("-M")
|
|
||||||
append(milestone)
|
|
||||||
}
|
|
||||||
if (showMeta) {
|
if (showMeta) {
|
||||||
append('-')
|
append('-')
|
||||||
append(meta.metaString)
|
append(meta.metaString)
|
||||||
|
|||||||
@@ -13,16 +13,15 @@ package org.jetbrains.kotlin.konan
|
|||||||
enum class MetaVersion(val metaString: String) {
|
enum class MetaVersion(val metaString: String) {
|
||||||
DEV("dev"),
|
DEV("dev"),
|
||||||
EAP("eap"),
|
EAP("eap"),
|
||||||
ALPHA("alpha"),
|
|
||||||
BETA("beta"),
|
BETA("beta"),
|
||||||
RC1("rc1"),
|
M1("M1"),
|
||||||
RC2("rc2"),
|
M2("M2"),
|
||||||
|
RC("RC"),
|
||||||
RELEASE("release");
|
RELEASE("release");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun findAppropriate(metaString: String): MetaVersion {
|
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")
|
?: 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
|
open val meta = (project.findProperty("konanMetaVersion") as? String ?: kotlinNativeProperties["konanMetaVersion"])?.let{ MetaVersion.valueOf(it.toString().toUpperCase()) } ?: MetaVersion.DEV
|
||||||
|
|
||||||
private val versionPattern = Pattern.compile(
|
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() {
|
fun defaultVersionFileLocation() {
|
||||||
@@ -94,8 +94,6 @@ open class VersionGenerator: DefaultTask() {
|
|||||||
val minor = matcher.group(2).toInt()
|
val minor = matcher.group(2).toInt()
|
||||||
val maintenanceStr = matcher.group(3)
|
val maintenanceStr = matcher.group(3)
|
||||||
val maintenance = maintenanceStr?.toInt() ?: 0
|
val maintenance = maintenanceStr?.toInt() ?: 0
|
||||||
val milestoneStr = matcher.group(4)
|
|
||||||
val milestone = milestoneStr?.toInt() ?: -1
|
|
||||||
project.logger.info("BUILD_NUMBER: $buildNumber")
|
project.logger.info("BUILD_NUMBER: $buildNumber")
|
||||||
var build = -1
|
var build = -1
|
||||||
if (buildNumber != null) {
|
if (buildNumber != null) {
|
||||||
@@ -103,10 +101,8 @@ open class VersionGenerator: DefaultTask() {
|
|||||||
build = buildNumberSplit[buildNumberSplit.size - 1].toInt() // //7-dev-buildcount
|
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()
|
versionObject.serialize()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CompilerVersion.serialize() {
|
private fun CompilerVersion.serialize() {
|
||||||
@@ -118,7 +114,7 @@ open class VersionGenerator: DefaultTask() {
|
|||||||
"""|package org.jetbrains.kotlin.konan
|
"""|package org.jetbrains.kotlin.konan
|
||||||
|internal val currentCompilerVersion: CompilerVersion =
|
|internal val currentCompilerVersion: CompilerVersion =
|
||||||
|CompilerVersionImpl($meta, $major, $minor,
|
|CompilerVersionImpl($meta, $major, $minor,
|
||||||
| $maintenance, $milestone, $build)
|
| $maintenance, $build)
|
||||||
|val CompilerVersion.Companion.CURRENT: CompilerVersion
|
|val CompilerVersion.Companion.CURRENT: CompilerVersion
|
||||||
|get() = currentCompilerVersion""".trimMargin()
|
|get() = currentCompilerVersion""".trimMargin()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user