[K/N][build] Change MetaVersion to inline class from enum
Support meta versions strings other than pre-defined. All enum entries were left for source-level compatibility.
This commit is contained in:
@@ -19,7 +19,7 @@ tasks {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
languageVersion = "1.4"
|
languageVersion = "1.4"
|
||||||
apiVersion = "1.4"
|
apiVersion = "1.4"
|
||||||
freeCompilerArgs += "-Xsuppress-version-warnings"
|
freeCompilerArgs += listOf("-Xsuppress-version-warnings", "-Xinline-classes")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.konan
|
package org.jetbrains.kotlin.konan
|
||||||
|
|
||||||
enum class MetaVersion(val metaString: String) {
|
inline class MetaVersion(val metaString: String) {
|
||||||
DEV("dev"),
|
|
||||||
DEV_GOOGLE("dev-google-pr"),
|
|
||||||
EAP("eap"),
|
|
||||||
BETA("beta"),
|
|
||||||
M1("M1"),
|
|
||||||
M2("M2"),
|
|
||||||
RC("RC"),
|
|
||||||
PUB("PUB"),
|
|
||||||
RELEASE("release");
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun findAppropriate(metaString: String): MetaVersion {
|
// Following meta versions are left for source-level compatibility
|
||||||
return values().find { it.metaString.equals(metaString, ignoreCase = true) }
|
val DEV = MetaVersion("dev")
|
||||||
?: if (metaString.isBlank()) RELEASE else error("Unknown meta version: $metaString")
|
val DEV_GOOGLE = MetaVersion("dev-google-pr")
|
||||||
}
|
val EAP = MetaVersion("eap")
|
||||||
|
val BETA = MetaVersion("Beta")
|
||||||
|
val M1 = MetaVersion("M1")
|
||||||
|
val M2 = MetaVersion("M2")
|
||||||
|
val RC = MetaVersion("RC")
|
||||||
|
val PUB = MetaVersion("PUB")
|
||||||
|
val RELEASE = MetaVersion("release")
|
||||||
|
|
||||||
|
fun findAppropriate(metaString: String): MetaVersion =
|
||||||
|
listOf(DEV, DEV_GOOGLE, EAP, BETA, M1, M2, RC, PUB, RELEASE)
|
||||||
|
.find { it.metaString.equals(metaString, ignoreCase = true) }
|
||||||
|
?: if (metaString.isBlank()) RELEASE else MetaVersion(metaString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ class NativeCompilerVersionTest {
|
|||||||
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30-M1-dev-123") }
|
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30-M1-dev-123") }
|
||||||
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30-M1-release-123") }
|
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30-M1-release-123") }
|
||||||
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30.40-release-123") }
|
assertFailsWith<IllegalArgumentException> { CompilerVersion.fromString("1.5.30.40-release-123") }
|
||||||
assertFailsWith<IllegalStateException> { CompilerVersion.fromString("1.6.0-M3-123") }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -123,4 +122,43 @@ class NativeCompilerVersionTest {
|
|||||||
}
|
}
|
||||||
assertEquals("1.5.30-PUB-140", CompilerVersionImpl(MetaVersion.PUB, 1, 5, 30, -1, 140).toString())
|
assertEquals("1.5.30-PUB-140", CompilerVersionImpl(MetaVersion.PUB, 1, 5, 30, -1, 140).toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun betasAndRCs() {
|
||||||
|
"1.7.0-RC".parseCompilerVersion().apply {
|
||||||
|
assertEquals(1, major)
|
||||||
|
assertEquals(7, minor)
|
||||||
|
assertEquals(0, maintenance)
|
||||||
|
assertEquals(MetaVersion.RC, meta)
|
||||||
|
assertEquals(-1, build)
|
||||||
|
}
|
||||||
|
"1.7.0-RC2".parseCompilerVersion().apply {
|
||||||
|
assertEquals(1, major)
|
||||||
|
assertEquals(7, minor)
|
||||||
|
assertEquals(0, maintenance)
|
||||||
|
assertEquals(MetaVersion("RC2"), meta)
|
||||||
|
assertEquals(-1, build)
|
||||||
|
}
|
||||||
|
"1.7.0-RC2-123".parseCompilerVersion().apply {
|
||||||
|
assertEquals(1, major)
|
||||||
|
assertEquals(7, minor)
|
||||||
|
assertEquals(0, maintenance)
|
||||||
|
assertEquals(MetaVersion("RC2"), meta)
|
||||||
|
assertEquals(123, build)
|
||||||
|
}
|
||||||
|
"1.7.0-Beta".parseCompilerVersion().apply {
|
||||||
|
assertEquals(1, major)
|
||||||
|
assertEquals(7, minor)
|
||||||
|
assertEquals(0, maintenance)
|
||||||
|
assertEquals(MetaVersion.BETA, meta)
|
||||||
|
assertEquals(-1, build)
|
||||||
|
}
|
||||||
|
"1.7.0-Beta2".parseCompilerVersion().apply {
|
||||||
|
assertEquals(1, major)
|
||||||
|
assertEquals(7, minor)
|
||||||
|
assertEquals(0, maintenance)
|
||||||
|
assertEquals(MetaVersion("Beta2"), meta)
|
||||||
|
assertEquals(-1, build)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +81,9 @@ open class VersionGenerator : DefaultTask() {
|
|||||||
@Input
|
@Input
|
||||||
open val buildNumber = project.findProperty("build.number")?.toString()
|
open val buildNumber = project.findProperty("build.number")?.toString()
|
||||||
|
|
||||||
@Input
|
@get:Input
|
||||||
open val meta = (project.findProperty("konanMetaVersion") as? String
|
open val meta = (project.findProperty("konanMetaVersion") as? String
|
||||||
?: kotlinNativeProperties["konanMetaVersion"])?.let { MetaVersion.valueOf(it.toString().toUpperCase()) }
|
?: kotlinNativeProperties["konanMetaVersion"])?.let { MetaVersion.findAppropriate(it.toString()) }
|
||||||
?: MetaVersion.DEV
|
?: MetaVersion.DEV
|
||||||
|
|
||||||
fun defaultVersionFileLocation() {
|
fun defaultVersionFileLocation() {
|
||||||
|
|||||||
Reference in New Issue
Block a user