[build] joint (step 1)
(cherry picked from commit 7d0775f7e69ab900200bcf1fa78b94d68e6bd4f6)
This commit is contained in:
@@ -81,12 +81,15 @@ extra["intellijReleaseType"] = when {
|
||||
else -> "releases"
|
||||
}
|
||||
|
||||
extra["versions.androidDxSources"] = "5.0.0_r2"
|
||||
extra["customDepsOrg"] = "kotlin.build"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
|
||||
maven("https://kotlin.bintray.com/kotlinx")
|
||||
maven("https://kotlin.bintray.com/kotlin-dev")
|
||||
gradlePluginPortal()
|
||||
|
||||
extra["bootstrapKotlinRepo"]?.let {
|
||||
@@ -94,6 +97,21 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
|
||||
kotlin.srcDir("src/main/kotlin")
|
||||
kotlin.srcDir("src/generated/kotlin")
|
||||
kotlin.srcDir("src/to_bootstrap/kotlin")
|
||||
kotlin.srcDir("../kotlin-native/shared/src/library/kotlin")
|
||||
kotlin.srcDir("../kotlin-native/shared/src/main/kotlin")
|
||||
kotlin.srcDir("../kotlin-native/build-tools/src/main/kotlin")
|
||||
kotlin.srcDir("../kotlin-native/build-tools/src/tmp/kotlin")
|
||||
kotlin.srcDir("../kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin")
|
||||
}
|
||||
|
||||
tasks.validatePlugins.configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib", embeddedKotlinVersion))
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
|
||||
@@ -113,6 +131,26 @@ dependencies {
|
||||
|
||||
implementation("org.gradle:test-retry-gradle-plugin:1.1.9")
|
||||
implementation("com.gradle.enterprise:test-distribution-gradle-plugin:1.2.1")
|
||||
|
||||
compileOnly(gradleApi())
|
||||
|
||||
val kotlinVersion = project.bootstrapKotlinVersion
|
||||
val ktorVersion = "1.2.1"
|
||||
val slackApiVersion = "1.2.0"
|
||||
val metadataVersion = "0.0.1-dev-10"
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||
implementation("com.ullink.slack:simpleslackapi:$slackApiVersion")
|
||||
|
||||
implementation("io.ktor:ktor-client-auth:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
|
||||
api("org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion")
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion")
|
||||
}
|
||||
|
||||
samWithReceiver {
|
||||
@@ -134,6 +172,14 @@ tasks.withType<KotlinCompile>().configureEach {
|
||||
}
|
||||
|
||||
tasks["build"].dependsOn(":prepare-deps:build")
|
||||
sourceSets["main"].withConvention(org.gradle.api.tasks.GroovySourceSet::class) {
|
||||
groovy.srcDir("../kotlin-native/build-tools/src/main/groovy")
|
||||
}
|
||||
|
||||
tasks.named("compileGroovy", GroovyCompile::class.java) {
|
||||
classpath += project.files(tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java))
|
||||
dependsOn(tasks.named("compileKotlin"))
|
||||
}
|
||||
|
||||
allprojects {
|
||||
tasks.register("checkBuild")
|
||||
@@ -142,3 +188,42 @@ allprojects {
|
||||
apply(from = "$rootDir/../gradle/cacheRedirector.gradle.kts")
|
||||
}
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("benchmarkPlugin") {
|
||||
id = "benchmarking"
|
||||
implementationClass = "org.jetbrains.kotlin.benchmark.KotlinNativeBenchmarkingPlugin"
|
||||
}
|
||||
create("compileBenchmarking") {
|
||||
id = "compile-benchmarking"
|
||||
implementationClass = "org.jetbrains.kotlin.benchmark.CompileBenchmarkingPlugin"
|
||||
}
|
||||
create("swiftBenchmarking") {
|
||||
id = "swift-benchmarking"
|
||||
implementationClass = "org.jetbrains.kotlin.benchmark.SwiftBenchmarkingPlugin"
|
||||
}
|
||||
create("compileToBitcode") {
|
||||
id = "compile-to-bitcode"
|
||||
implementationClass = "org.jetbrains.kotlin.bitcode.CompileToBitcodePlugin"
|
||||
}
|
||||
create("runtimeTesting") {
|
||||
id = "runtime-testing"
|
||||
implementationClass = "org.jetbrains.kotlin.testing.native.RuntimeTestingPlugin"
|
||||
}
|
||||
create("konan") {
|
||||
id = "konan"
|
||||
implementationClass = "org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin"
|
||||
}
|
||||
// We bundle a shaded version of kotlinx-serialization plugin
|
||||
create("kotlinx-serialization-native") {
|
||||
id = "kotlinx-serialization-native"
|
||||
implementationClass = "shadow.org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin"
|
||||
}
|
||||
|
||||
create("org.jetbrains.kotlin.konan") {
|
||||
id = "org.jetbrains.kotlin.konan"
|
||||
implementationClass = "org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.konan
|
||||
|
||||
internal val currentCompilerVersion: CompilerVersion =
|
||||
CompilerVersionImpl(
|
||||
MetaVersion.DEV, 1, 4,
|
||||
30, -1, -1)
|
||||
|
||||
val CompilerVersion.Companion.CURRENT: CompilerVersion
|
||||
get() = currentCompilerVersion
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.*
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.PrintWriter
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
open class VersionGenerator: DefaultTask() {
|
||||
@OutputDirectory
|
||||
fun getVersionSourceDirectory(): File {
|
||||
return getProject().file("build/generated")
|
||||
}
|
||||
|
||||
@OutputFile
|
||||
open fun getVersionFile(): File? {
|
||||
return getProject().file(getVersionSourceDirectory().path + "/src/generated/org/jetbrains/kotlin/konan/CompilerVersionGenerated.kt")
|
||||
}
|
||||
|
||||
@Input
|
||||
open fun getKonanVersion(): String? {
|
||||
return getProject().getProperties().get("konanVersion").toString()
|
||||
}
|
||||
|
||||
|
||||
// TeamCity passes all configuration parameters into a build script as project properties.
|
||||
// Thus we can use them here instead of environment variables.
|
||||
@Optional
|
||||
@Input
|
||||
open fun getBuildNumber(): String? {
|
||||
val property: Any = getProject().findProperty("build.number") ?: return null
|
||||
return property.toString()
|
||||
}
|
||||
|
||||
@Input
|
||||
open fun getMeta(): String {
|
||||
val konanMetaVersionProperty: Any = getProject().getProperties().get("konanMetaVersion") ?: return "MetaVersion.DEV"
|
||||
return "MetaVersion." + konanMetaVersionProperty.toString().toUpperCase()
|
||||
}
|
||||
|
||||
private val versionPattern = Pattern.compile(
|
||||
"^(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-M(\\p{Digit}))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?$"
|
||||
)
|
||||
|
||||
@TaskAction
|
||||
open fun generateVersion() {
|
||||
val matcher = versionPattern.matcher(getKonanVersion())
|
||||
require(matcher.matches()) { "Cannot parse Kotlin/Native version: \$konanVersion" }
|
||||
val major = matcher.group(1).toInt()
|
||||
val minor = matcher.group(2).toInt()
|
||||
val maintenanceStr = matcher.group(3)
|
||||
val maintenance = maintenanceStr?.toInt() ?: 0
|
||||
val milestoneStr = matcher.group(4)
|
||||
val milestone = milestoneStr?.toInt() ?: -1
|
||||
val buildNumber = getBuildNumber()
|
||||
getProject().getLogger().info("BUILD_NUMBER: " + getBuildNumber())
|
||||
var build = -1
|
||||
if (buildNumber != null) {
|
||||
val buildNumberSplit = buildNumber.split("-".toRegex()).toTypedArray()
|
||||
build = buildNumberSplit[buildNumberSplit.size - 1].toInt() // //7-dev-buildcount
|
||||
}
|
||||
try {
|
||||
PrintWriter(getVersionFile()).use { printWriter ->
|
||||
printWriter.println(
|
||||
"""package org.jetbrains.kotlin.konan
|
||||
internal val currentCompilerVersion: CompilerVersion =
|
||||
CompilerVersionImpl(${getMeta()}, $major, $minor,
|
||||
$maintenance, $milestone, $build)
|
||||
val CompilerVersion.Companion.CURRENT: CompilerVersion
|
||||
get() = currentCompilerVersion"""
|
||||
)
|
||||
}
|
||||
} catch (e: FileNotFoundException) {
|
||||
throw IllegalStateException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user