[K/N][gradle] Supported IC for caches
This commit is contained in:
+8
@@ -51,6 +51,14 @@ internal fun Project.getKonanCacheOrchestration(): NativeCacheOrchestration {
|
||||
return PropertiesProvider(this).nativeCacheOrchestration ?: NativeCacheOrchestration.Compiler
|
||||
}
|
||||
|
||||
internal fun Project.isKonanIncrementalCompilationEnabled(): Boolean {
|
||||
return PropertiesProvider(this).incrementalNative ?: false
|
||||
}
|
||||
|
||||
internal fun Project.getKonanParallelThreads(): Int {
|
||||
return PropertiesProvider(this).nativeParallelThreads ?: 4
|
||||
}
|
||||
|
||||
private val Project.kotlinNativeCompilerJar: String
|
||||
get() = if (nativeUseEmbeddableCompilerJar)
|
||||
"$konanHome/konan/lib/kotlin-native-compiler-embeddable.jar"
|
||||
|
||||
+11
@@ -153,6 +153,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val incrementalJsIr: Boolean
|
||||
get() = booleanProperty("kotlin.incremental.js.ir") ?: true
|
||||
|
||||
val incrementalNative: Boolean?
|
||||
get() = booleanProperty(PropertyNames.KOTLIN_NATIVE_INCREMENTAL_COMPILATION)
|
||||
|
||||
val jsIrOutputGranularity: KotlinJsIrOutputGranularity
|
||||
get() = this.property("kotlin.js.ir.output.granularity")?.let { KotlinJsIrOutputGranularity.byArgument(it) }
|
||||
?: KotlinJsIrOutputGranularity.PER_MODULE
|
||||
@@ -438,6 +441,12 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val nativeCacheOrchestration: NativeCacheOrchestration?
|
||||
get() = this.property(PropertyNames.KOTLIN_NATIVE_CACHE_ORCHESTRATION)?.let { NativeCacheOrchestration.byCompilerArgument(it) }
|
||||
|
||||
/**
|
||||
* Native backend threads.
|
||||
*/
|
||||
val nativeParallelThreads: Int?
|
||||
get() = this.property(PropertyNames.KOTLIN_NATIVE_PARALLEL_THREADS)?.toInt()
|
||||
|
||||
/**
|
||||
* Ignore overflow in [org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessageOutputStreamHandler]
|
||||
*/
|
||||
@@ -610,6 +619,8 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
const val KOTLIN_MPP_ENABLE_INTRANSITIVE_METADATA_CONFIGURATION = "kotlin.mpp.enableIntransitiveMetadataConfiguration"
|
||||
const val KOTLIN_NATIVE_DEPENDENCY_PROPAGATION = "kotlin.native.enableDependencyPropagation"
|
||||
const val KOTLIN_NATIVE_CACHE_ORCHESTRATION = "kotlin.native.cacheOrchestration"
|
||||
const val KOTLIN_NATIVE_PARALLEL_THREADS = "kotlin.native.parallelThreads"
|
||||
const val KOTLIN_NATIVE_INCREMENTAL_COMPILATION = "kotlin.incremental.native"
|
||||
const val KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION = "kotlin.mpp.enableOptimisticNumberCommonization"
|
||||
const val KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION = "kotlin.mpp.enablePlatformIntegerCommonization"
|
||||
const val KOTLIN_ABI_SNAPSHOT = "kotlin.incremental.classpath.snapshot.enabled"
|
||||
|
||||
+17
-2
@@ -186,10 +186,14 @@ constructor(
|
||||
CacheBuilder.Settings.createWithProject(project, binary, konanTarget, toolOptions, externalDependenciesArgs)
|
||||
}
|
||||
|
||||
private class CacheSettings(val orchestration: NativeCacheOrchestration, val kind: NativeCacheKind, val gradleUserHomeDir: File)
|
||||
private class CacheSettings(val orchestration: NativeCacheOrchestration, val kind: NativeCacheKind,
|
||||
val icEnabled: Boolean, val threads: Int,
|
||||
val gradleUserHomeDir: File, val gradleBuildDir: File)
|
||||
|
||||
private val cacheSettings by lazy {
|
||||
CacheSettings(project.getKonanCacheOrchestration(), project.getKonanCacheKind(konanTarget), project.gradle.gradleUserHomeDir)
|
||||
CacheSettings(project.getKonanCacheOrchestration(), project.getKonanCacheKind(konanTarget),
|
||||
project.isKonanIncrementalCompilationEnabled(), project.getKonanParallelThreads(),
|
||||
project.gradle.gradleUserHomeDir, project.buildDir)
|
||||
}
|
||||
|
||||
override fun createCompilerArguments(context: CreateCompilerArgumentsContext) = context.create<K2NativeCompilerArguments> {
|
||||
@@ -342,9 +346,20 @@ constructor(
|
||||
&& konanPropertiesService.get().cacheWorksFor(konanTarget)
|
||||
) {
|
||||
add("-Xauto-cache-from=${cacheSettings.gradleUserHomeDir}")
|
||||
add("-Xbackend-threads=${cacheSettings.threads}")
|
||||
if (cacheSettings.icEnabled) {
|
||||
val icCacheDir = cacheSettings.gradleBuildDir.resolve("kotlin-native-ic-cache")
|
||||
icCacheDir.mkdirs()
|
||||
add("-Xenable-incremental-compilation")
|
||||
add("-Xic-cache-dir=$icCacheDir")
|
||||
}
|
||||
}
|
||||
}
|
||||
NativeCacheOrchestration.Gradle -> {
|
||||
if (cacheSettings.icEnabled) {
|
||||
executionContext.logger.warn(
|
||||
"K/N incremental compilation only works in conjunction with kotlin.native.cacheOrchestration=compiler")
|
||||
}
|
||||
val cacheBuilder = CacheBuilder(
|
||||
executionContext = executionContext,
|
||||
settings = cacheBuilderSettings,
|
||||
|
||||
Reference in New Issue
Block a user