[MPP] Add preliminary version of platform integer commonizer

Doesn't take target's size_t alias into account just yet

KT-41509
This commit is contained in:
Pavel Kirpichenkov
2022-02-02 12:03:00 +03:00
committed by teamcity
parent b8ee473107
commit 8f4d04dad2
13 changed files with 749 additions and 30 deletions
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.Companion.jsCompi
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_BY_DEFAULT
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_NATIVE_DEPENDENCY_PROPAGATION
@@ -221,6 +222,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
val mppEnableOptimisticNumberCommonization: Boolean
get() = booleanProperty(KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION) ?: true
val mppEnablePlatformIntegerCommonization: Boolean
get() = booleanProperty(KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION) ?: false
val wasmStabilityNoWarn: Boolean
get() = booleanProperty("kotlin.wasm.stability.nowarn") ?: false
@@ -498,6 +502,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
const val KOTLIN_NATIVE_DEPENDENCY_PROPAGATION = "kotlin.native.enableDependencyPropagation"
const val KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION = "kotlin.mpp.enableOptimisticNumberCommonization"
const val KOTLIN_KPM_EXPERIMENTAL_MODEL_MAPPING = "kotlin.kpm.experimentalModelMapping"
const val KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION = "kotlin.mpp.enablePlatformIntegerCommonization"
}
companion object {
@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.gradle.targets.native.internal
import org.gradle.api.Project
import org.jetbrains.kotlin.commonizer.AdditionalCommonizerSetting
import org.jetbrains.kotlin.commonizer.CommonizerLogLevel
import org.jetbrains.kotlin.commonizer.OptimisticNumberCommonizationEnabledKey
import org.jetbrains.kotlin.commonizer.setTo
import org.jetbrains.kotlin.commonizer.*
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
internal val Project.commonizerLogLevel: CommonizerLogLevel
@@ -24,5 +21,6 @@ internal val Project.commonizerLogLevel: CommonizerLogLevel
internal val Project.additionalCommonizerSettings: List<AdditionalCommonizerSetting<*>>
get() = listOf(
OptimisticNumberCommonizationEnabledKey setTo isOptimisticNumberCommonizationEnabled
OptimisticNumberCommonizationEnabledKey setTo isOptimisticNumberCommonizationEnabled,
PlatformIntegerCommonizationEnabledKey setTo isPlatformIntegerCommonizationEnabled,
)
@@ -25,6 +25,9 @@ internal val Project.isIntransitiveMetadataConfigurationEnabled: Boolean
internal val Project.isOptimisticNumberCommonizationEnabled: Boolean
get() = PropertiesProvider(this).mppEnableOptimisticNumberCommonization
internal val Project.isPlatformIntegerCommonizationEnabled: Boolean
get() = PropertiesProvider(this).mppEnablePlatformIntegerCommonization
internal val Project.commonizeTask: TaskProvider<Task>
get() = locateOrRegisterTask(
"commonize",