Package builtins with jvm reflect into IDEA plugin only
Leave builtins with common reflect for stand-alone compiler.
This commit is contained in:
committed by
Stanislav Erokhin
parent
0c094b1719
commit
95cc35f22e
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.
|
||||||
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused")
|
@file:Suppress("unused")
|
||||||
|
|
||||||
// usages in build scripts are not tracked properly
|
// usages in build scripts are not tracked properly
|
||||||
@@ -97,9 +102,11 @@ fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): An
|
|||||||
dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-"), classifier)
|
dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-"), classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.kotlinBuiltins(): Any =
|
fun Project.kotlinBuiltins(): Any = kotlinBuiltins(forJvm = false)
|
||||||
|
|
||||||
|
fun Project.kotlinBuiltins(forJvm: Boolean): Any =
|
||||||
if (kotlinBuildProperties.useBootstrapStdlib) "org.jetbrains.kotlin:builtins:$bootstrapKotlinVersion"
|
if (kotlinBuildProperties.useBootstrapStdlib) "org.jetbrains.kotlin:builtins:$bootstrapKotlinVersion"
|
||||||
else dependencies.project(":core:builtins")
|
else dependencies.project(":core:builtins", configuration = "runtimeElementsJvm".takeIf { forJvm })
|
||||||
|
|
||||||
fun DependencyHandler.projectTests(name: String): ProjectDependency = project(name, configuration = "tests-jar")
|
fun DependencyHandler.projectTests(name: String): ProjectDependency = project(name, configuration = "tests-jar")
|
||||||
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
|
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ val builtinsNative = fileFrom(rootDir, "core", "builtins", "native")
|
|||||||
val kotlinReflectCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/reflect/")
|
val kotlinReflectCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/reflect/")
|
||||||
val kotlinReflectJvm = fileFrom(rootDir, "libraries/stdlib/jvm/src/kotlin/reflect")
|
val kotlinReflectJvm = fileFrom(rootDir, "libraries/stdlib/jvm/src/kotlin/reflect")
|
||||||
val builtinsCherryPicked = fileFrom(buildDir, "src")
|
val builtinsCherryPicked = fileFrom(buildDir, "src")
|
||||||
|
val builtinsCherryPickedJvm = fileFrom(buildDir, "src-jvm")
|
||||||
|
|
||||||
val runtimeElements by configurations.creating {
|
val runtimeElements by configurations.creating {
|
||||||
isCanBeResolved = false
|
isCanBeResolved = false
|
||||||
@@ -20,7 +21,24 @@ val runtimeElements by configurations.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val runtimeElementsJvm by configurations.creating {
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
attribute(Attribute.of("builtins.platform", String::class.java), "JVM")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val prepareSources by tasks.registering(Sync::class) {
|
val prepareSources by tasks.registering(Sync::class) {
|
||||||
|
from(kotlinReflectCommon) {
|
||||||
|
exclude("typeOf.kt")
|
||||||
|
exclude("KClasses.kt")
|
||||||
|
}
|
||||||
|
into(builtinsCherryPicked)
|
||||||
|
}
|
||||||
|
|
||||||
|
val prepareSourcesJvm by tasks.registering(Sync::class) {
|
||||||
from(kotlinReflectJvm) {
|
from(kotlinReflectJvm) {
|
||||||
exclude("TypesJVM.kt")
|
exclude("TypesJVM.kt")
|
||||||
exclude("KClassesImpl.kt")
|
exclude("KClassesImpl.kt")
|
||||||
@@ -31,26 +49,29 @@ val prepareSources by tasks.registering(Sync::class) {
|
|||||||
include("KTypeParameter.kt")
|
include("KTypeParameter.kt")
|
||||||
include("KVariance.kt")
|
include("KVariance.kt")
|
||||||
}
|
}
|
||||||
into(builtinsCherryPicked)
|
into(builtinsCherryPickedJvm)
|
||||||
}
|
}
|
||||||
|
|
||||||
val serialize by tasks.registering(NoDebugJavaExec::class) {
|
fun serializeTask(name: String, sourcesTask: TaskProvider<*>, inDirs: List<File>) =
|
||||||
dependsOn(prepareSources)
|
tasks.register(name, NoDebugJavaExec::class) {
|
||||||
val outDir = buildDir.resolve(name)
|
dependsOn(sourcesTask)
|
||||||
val inDirs = arrayOf(builtinsSrc, builtinsNative, builtinsCherryPicked)
|
val outDir = buildDir.resolve(this.name)
|
||||||
inDirs.forEach { inputs.dir(it).withPathSensitivity(RELATIVE) }
|
inDirs.forEach { inputs.dir(it).withPathSensitivity(RELATIVE) }
|
||||||
|
outputs.dir(outDir)
|
||||||
|
outputs.cacheIf { true }
|
||||||
|
|
||||||
outputs.dir(outDir)
|
classpath(rootProject.buildscript.configurations["bootstrapCompilerClasspath"])
|
||||||
outputs.cacheIf { true }
|
main = "org.jetbrains.kotlin.serialization.builtins.RunKt"
|
||||||
|
jvmArgs("-Didea.io.use.nio2=true")
|
||||||
|
args(
|
||||||
|
pathRelativeToWorkingDir(outDir),
|
||||||
|
*inDirs.map(::pathRelativeToWorkingDir).toTypedArray()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
classpath(rootProject.buildscript.configurations["bootstrapCompilerClasspath"])
|
val serialize = serializeTask("serialize", prepareSources, listOf(builtinsSrc, builtinsNative, builtinsCherryPicked))
|
||||||
main = "org.jetbrains.kotlin.serialization.builtins.RunKt"
|
|
||||||
jvmArgs("-Didea.io.use.nio2=true")
|
val serializeJvm = serializeTask("serializeJvm", prepareSourcesJvm, listOf(builtinsSrc, builtinsNative, builtinsCherryPickedJvm))
|
||||||
args(
|
|
||||||
pathRelativeToWorkingDir(outDir),
|
|
||||||
*inDirs.map(::pathRelativeToWorkingDir).toTypedArray()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val builtinsJar by task<Jar> {
|
val builtinsJar by task<Jar> {
|
||||||
dependsOn(serialize)
|
dependsOn(serialize)
|
||||||
@@ -58,11 +79,20 @@ val builtinsJar by task<Jar> {
|
|||||||
destinationDir = File(buildDir, "libs")
|
destinationDir = File(buildDir, "libs")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val builtinsJvmJar by task<Jar> {
|
||||||
|
dependsOn(serializeJvm)
|
||||||
|
from(serializeJvm) { include("kotlin/**") }
|
||||||
|
archiveClassifier.set("jvm")
|
||||||
|
destinationDir = File(buildDir, "libs")
|
||||||
|
}
|
||||||
|
|
||||||
val assemble by tasks.getting {
|
val assemble by tasks.getting {
|
||||||
dependsOn(serialize)
|
dependsOn(serialize)
|
||||||
|
dependsOn(serializeJvm)
|
||||||
}
|
}
|
||||||
|
|
||||||
val builtinsJarArtifact = artifacts.add(runtimeElements.name, builtinsJar)
|
val builtinsJarArtifact = artifacts.add(runtimeElements.name, builtinsJar)
|
||||||
|
artifacts.add(runtimeElementsJvm.name, builtinsJvmJar)
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ dependencies {
|
|||||||
embedded(project(it)) { isTransitive = false }
|
embedded(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
embedded(protobufFull())
|
embedded(protobufFull())
|
||||||
embedded(kotlinBuiltins())
|
embedded(kotlinBuiltins(forJvm = true))
|
||||||
|
|
||||||
libraries(commonDep("org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:${property("versions.kotlinx-collections-immutable")}"))
|
libraries(commonDep("org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:${property("versions.kotlinx-collections-immutable")}"))
|
||||||
libraries(commonDep("javax.inject"))
|
libraries(commonDep("javax.inject"))
|
||||||
|
|||||||
Reference in New Issue
Block a user