[K/N][build] Make kotlin-native shared be included subproject
This commit is contained in:
committed by
Space Team
parent
395e3e0f81
commit
8938d5cc79
@@ -59,6 +59,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation("org.jetbrains.kotlin:kotlin-util-klib:${project.bootstrapKotlinVersion}")
|
implementation("org.jetbrains.kotlin:kotlin-util-klib:${project.bootstrapKotlinVersion}")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-native-utils:${project.bootstrapKotlinVersion}")
|
implementation("org.jetbrains.kotlin:kotlin-native-utils:${project.bootstrapKotlinVersion}")
|
||||||
|
|
||||||
|
api(project(":kotlin-native-shared"))
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -91,8 +93,6 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
kotlin.srcDir("src/main/kotlin")
|
kotlin.srcDir("src/main/kotlin")
|
||||||
kotlin.srcDir("../../kotlin-native/shared/src/library/kotlin")
|
|
||||||
kotlin.srcDir("../../kotlin-native/shared/src/main/kotlin")
|
|
||||||
kotlin.srcDir("../../kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin")
|
kotlin.srcDir("../../kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,3 +12,5 @@ org.gradle.java.installations.fromEnv=\
|
|||||||
JDK_15_0,JDK_15,\
|
JDK_15_0,JDK_15,\
|
||||||
JDK_16_0,\
|
JDK_16_0,\
|
||||||
JDK_17_0
|
JDK_17_0
|
||||||
|
|
||||||
|
kotlin.native.build.composite-bootstrap=true
|
||||||
@@ -26,4 +26,18 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:$buildGradlePluginVersion")
|
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:$buildGradlePluginVersion")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include(":kotlin-native-shared")
|
||||||
|
project(":kotlin-native-shared").projectDir = File("$rootDir/../shared")
|
||||||
|
|
||||||
|
// This code could potentially remove the need of bootstrapping code that use util-klib and util-io
|
||||||
|
// by building them, but it's not possible right now, because they use buildSrc plugins (like JPS) and methods (like commonDependency).
|
||||||
|
// This could be fixed by replacing the buildSrc with the composite build like build-tools, and splitting it to several parts.
|
||||||
|
//include(":native:kotlin-native-utils")
|
||||||
|
//include(":kotlin-util-klib")
|
||||||
|
//include(":kotlin-util-io")
|
||||||
|
|
||||||
|
//project(":native:kotlin-native-utils").projectDir = File("$rootDir/../../native/kotlin-native-utils")
|
||||||
|
//project(":kotlin-util-klib").projectDir = File("$rootDir/../../compiler/util-klib")
|
||||||
|
//project(":kotlin-util-io").projectDir = File("$rootDir/../../compiler/util-io")
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -24,8 +25,6 @@ plugins {
|
|||||||
val rootBuildDirectory by extra(file(".."))
|
val rootBuildDirectory by extra(file(".."))
|
||||||
apply(from = "../gradle/loadRootProperties.gradle")
|
apply(from = "../gradle/loadRootProperties.gradle")
|
||||||
|
|
||||||
val kotlinVersion = project.bootstrapKotlinVersion
|
|
||||||
|
|
||||||
group = "org.jetbrains.kotlin"
|
group = "org.jetbrains.kotlin"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -33,6 +32,12 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
@@ -47,20 +52,37 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||||||
kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check")
|
kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
// TODO: move it somewhere
|
||||||
archiveFileName.set("shared.jar")
|
//projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||||
}
|
// useJUnitPlatform()
|
||||||
|
//}
|
||||||
|
|
||||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
/**
|
||||||
useJUnitPlatform()
|
* Depending on the `kotlin.native.build.composite-bootstrap` property returns either coordinates or project dependency.
|
||||||
|
* This is to use this project in composite build (build-tools) and as a project itself.
|
||||||
|
* Project should depend on a current snapshot builds while build-tools use bootstrap dependencies
|
||||||
|
*/
|
||||||
|
fun compositeDependency(coordinates: String, subproject: String = ""): Any {
|
||||||
|
val bootstrap = project.extraProperties.has("kotlin.native.build.composite-bootstrap")
|
||||||
|
val parts = coordinates.split(':')
|
||||||
|
check(parts.size == 3) {
|
||||||
|
"Full dependency coordinates should be specified group:name:version"
|
||||||
|
}
|
||||||
|
return if (!bootstrap) {
|
||||||
|
// returns dependency on the project specified with coordinates
|
||||||
|
dependencies.project("$subproject:${parts[1]}")
|
||||||
|
} else {
|
||||||
|
// returns full coordinates
|
||||||
|
coordinates
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
|
kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:${project.bootstrapKotlinVersion}")
|
||||||
|
|
||||||
implementation(kotlinStdlib())
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}")
|
||||||
implementation(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
|
api(compositeDependency("org.jetbrains.kotlin:kotlin-native-utils:${project.bootstrapKotlinVersion}", ":native"))
|
||||||
api(project(":native:kotlin-native-utils"))
|
api(compositeDependency("org.jetbrains.kotlin:kotlin-util-klib:${project.bootstrapKotlinVersion}"))
|
||||||
api(project(":kotlin-util-klib"))
|
api(compositeDependency("org.jetbrains.kotlin:kotlin-util-io:${project.bootstrapKotlinVersion}"))
|
||||||
testApiJUnit5()
|
// testApiJUnit5()
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -73,9 +73,11 @@ open class KonanCacheTask: DefaultTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun compile() {
|
fun compile() {
|
||||||
check(klibUniqName == readKlibUniqNameFromManifest()) {
|
// This code uses bootstrap version of util-klib and fails due to the older default ABI than library being used
|
||||||
"klibUniqName mismatch: configured '$klibUniqName', resolved '${readKlibUniqNameFromManifest()}'"
|
// A possible solution is to read it manually from manifest file or this check should be done bu the compiler itself
|
||||||
}
|
// check(klibUniqName == readKlibUniqNameFromManifest()) {
|
||||||
|
// "klibUniqName mismatch: configured '$klibUniqName', resolved '${readKlibUniqNameFromManifest()}'"
|
||||||
|
// }
|
||||||
|
|
||||||
// Compiler doesn't create a cache if the cacheFile already exists. So we need to remove it manually.
|
// Compiler doesn't create a cache if the cacheFile already exists. So we need to remove it manually.
|
||||||
if (cacheFile.exists()) {
|
if (cacheFile.exists()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user