[K/N][build] Fix KT-56495: improve version manifest merge

Add missing input property to stdlib build task. This task should
consider kotlin/build version change.
Add a version check during the stdlib target task build. This check
should be done here instead of the final merge.

Fixes ^KT-56495


Merge-request: KT-MR-12906
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This commit is contained in:
Pavel Punegov
2023-11-13 14:45:06 +00:00
committed by Space Team
parent 5c56f0ef77
commit 6053c94c8a
4 changed files with 17 additions and 1 deletions
@@ -44,6 +44,8 @@ ext.testOutputRoot = rootProject.file("test.output").absolutePath
ext.platformManager = project.project(":kotlin-native").platformManager
ext.target = platformManager.targetManager(project.testTarget).target
ext.buildNumber = rootProject.property("kotlinVersion")
// Add executor to run tests depending on a target
// NOTE: If this persists in a gradle daemon, environment update (e.g. an Xcode update) may lead to execution failures.
project.extensions.executor = ExecutorServiceKt.create(project)
@@ -28,6 +28,7 @@ import kotlin.collections.HashSet
* Copy-pasted from [org.jetbrains.kotlin.library.KLIB_PROPERTY_NATIVE_TARGETS]
*/
private const val KLIB_PROPERTY_NATIVE_TARGETS = "native_targets"
private const val KLIB_PROPERTY_COMPILER_VERSION = "compiler_version"
//region Project properties.
@@ -346,7 +347,7 @@ fun Project.mergeManifestsByTargets(source: File, destination: File) {
val mismatchedProperties = (sourceProperties.keys + destinationProperties.keys)
.asSequence()
.map { it.toString() }
.filter { it != KLIB_PROPERTY_NATIVE_TARGETS }
.filterNot { it == KLIB_PROPERTY_NATIVE_TARGETS || it == KLIB_PROPERTY_COMPILER_VERSION }
.sorted()
.mapNotNull { propertyKey: String ->
val sourceProperty: String? = sourceProperties.getProperty(propertyKey)
@@ -386,6 +387,10 @@ fun Project.mergeManifestsByTargets(source: File, destination: File) {
destinationProperties[KLIB_PROPERTY_NATIVE_TARGETS] = mergedNativeTargets.joinToString(" ")
// Get KLIB_PROPERTY_COMPILER_VERSION source property and override the version
destinationProperties[KLIB_PROPERTY_COMPILER_VERSION] = sourceProperties.getProperty(KLIB_PROPERTY_COMPILER_VERSION)
// Now save the properties to the destination file
destinationFile.saveProperties(destinationProperties)
}
@@ -79,6 +79,8 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
val apiVersion : String?
@Optional @Input get() = project.konanExtension.apiVersion
@Input var buildNumber = project.properties.get("kotlinVersion") ?: error("kotlinVersion property is not specified in the project")
/**
* Is the two-stage compilation enabled.
*
+7
View File
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
import org.jetbrains.kotlin.konan.properties.loadProperties
import org.jetbrains.kotlin.konan.properties.saveProperties
import org.jetbrains.kotlin.konan.target.*
import org.jetbrains.kotlin.library.KLIB_PROPERTY_COMPILER_VERSION
import org.jetbrains.kotlin.library.KLIB_PROPERTY_NATIVE_TARGETS
import org.jetbrains.kotlin.konan.file.File as KFile
import org.jetbrains.kotlin.konan.target.Architecture as TargetArchitecture
@@ -18,6 +19,8 @@ val distDir: File by project
val konanHome: String by extra(distDir.absolutePath)
extra["org.jetbrains.kotlin.native.home"] = konanHome
val kotlinVersion: String by rootProject.extra
plugins {
id("compile-to-bitcode")
id("runtime-testing")
@@ -600,6 +603,10 @@ targetList.forEach { targetName ->
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
val props = loadProperties()
props[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
val version = props[KLIB_PROPERTY_COMPILER_VERSION]
check(version == kotlinVersion) {
"Manifest file ($this) processing: $version was found while $kotlinVersion was expected"
}
saveProperties(props)
}
}