[K/N] Fix build-tools project compilation
Add necessary subprojects and dependencies Add OptIn annotation for experimental stdlib methods in 1.5 Fix compilation errors and cleanup
This commit is contained in:
@@ -8,12 +8,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
// We explicitly configure versions of plugins in settings.gradle.kts.
|
||||
// due to https://github.com/gradle/gradle/issues/1697.
|
||||
id("kotlin")
|
||||
kotlin
|
||||
groovy
|
||||
`kotlin-dsl`
|
||||
`java-gradle-plugin`
|
||||
}
|
||||
|
||||
buildscript {
|
||||
@@ -52,22 +49,25 @@ version = konanVersion
|
||||
repositories {
|
||||
maven("https://cache-redirector.jetbrains.com/maven-central")
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(gradleApi())
|
||||
api(gradleApi())
|
||||
|
||||
api(kotlinStdlib())
|
||||
implementation(project(":kotlin-gradle-plugin"))
|
||||
implementation(project(":kotlin-reflect"))
|
||||
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}")
|
||||
|
||||
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") {
|
||||
exclude(group = "com.google.code.gson", module = "gson") // Workaround for Gradle dependency resolution error
|
||||
}
|
||||
val versionPropertiesFile = project.rootProject.projectDir.resolve("gradle/versions.properties")
|
||||
val versionProperties = Properties()
|
||||
versionPropertiesFile.inputStream().use { propInput ->
|
||||
project.rootProject.projectDir.resolve("gradle/versions.properties").inputStream().use { propInput ->
|
||||
versionProperties.load(propInput)
|
||||
}
|
||||
implementation(commonDependency("com.google.code.gson:gson"))
|
||||
configurations.all {
|
||||
resolutionStrategy.eachDependency {
|
||||
if (requested.group == "com.google.code.gson" && requested.name == "gson") {
|
||||
@@ -82,12 +82,10 @@ dependencies {
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
|
||||
api(project(":native:kotlin-native-utils"))
|
||||
|
||||
// Located in <repo root>/shared and always provided by the composite build.
|
||||
// api("org.jetbrains.kotlin:kotlin-native-shared:$kotlinVersion")
|
||||
// implementation("gradle.plugin.com.github.johnrengelman:shadow:$shadowVersion")
|
||||
//
|
||||
// implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion")
|
||||
api(project(":kotlin-native:shared"))
|
||||
api(project(":kotlinx-metadata-klib"))
|
||||
api(project(":kotlin-util-klib"))
|
||||
implementation("gradle.plugin.com.github.johnrengelman:shadow:${rootProject.extra["versions.shadow"]}")
|
||||
}
|
||||
|
||||
sourceSets["main"].withConvention(KotlinSourceSet::class) {
|
||||
@@ -98,8 +96,13 @@ val compileKotlin: KotlinCompile by tasks
|
||||
val compileGroovy: GroovyCompile by tasks
|
||||
|
||||
compileKotlin.apply {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.freeCompilerArgs += "-Xskip-prerelease-check"
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xsuppress-version-warnings",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi")
|
||||
}
|
||||
}
|
||||
|
||||
// Add Kotlin classes to a classpath for the Groovy compiler
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
pluginManagement {
|
||||
val rootProperties = java.util.Properties().apply {
|
||||
rootDir.resolve("../gradle.properties").reader().use(::load)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://cache-redirector.jetbrains.com/maven-central")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "kotlin") {
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "kotlin-native-build-tools"
|
||||
|
||||
includeBuild("../shared")
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
||||
|
||||
val projectName: String
|
||||
|
||||
@@ -10,8 +10,6 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompileProgramTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompileTask
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.nio.file.Paths
|
||||
* @property swiftSources Swift-language test sources that use a given framework
|
||||
* @property frameworks names of frameworks
|
||||
*/
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
@Input
|
||||
lateinit var swiftSources: List<String>
|
||||
|
||||
@@ -111,7 +111,7 @@ open class RunJvmTask: JavaExec() {
|
||||
@TaskAction
|
||||
override fun exec() {
|
||||
assert(outputFileName != null) { "Output file name should be always set" }
|
||||
predefinedArgs = args ?: emptyList()
|
||||
predefinedArgs = args
|
||||
val filterArgs = filter.splitCommaSeparatedOption("-f")
|
||||
val filterRegexArgs = filterRegex.splitCommaSeparatedOption("-fr")
|
||||
when (repeatingType) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(ExperimentalStdlibApi::class)
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,6 @@ import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
@@ -79,7 +78,7 @@ open class BenchmarkExtension @Inject constructor(val project: Project) {
|
||||
dependencies.action()
|
||||
|
||||
fun dependencies(action: Closure<*>) {
|
||||
ConfigureUtil.configure(action, dependencies)
|
||||
project.configure(dependencies, action)
|
||||
}
|
||||
|
||||
inner class BenchmarkDependencies {
|
||||
@@ -209,6 +208,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
|
||||
protected open fun Project.collectCodeSize(applicationName: String) =
|
||||
getCodeSizeBenchmark(applicationName, nativeExecutable)
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
protected open fun Project.configureKonanJsonTask(nativeTarget: KotlinNativeTarget): Task {
|
||||
return tasks.create("konanJsonReport") {
|
||||
group = BENCHMARKING_GROUP
|
||||
|
||||
+4
-5
@@ -4,7 +4,6 @@ import groovy.lang.Closure
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.tasks.Delete
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -17,12 +16,12 @@ class BuildStep (private val _name: String): Named {
|
||||
}
|
||||
}
|
||||
|
||||
class BuildStepContainer(project: Project): NamedDomainObjectContainer<BuildStep> by project.container(BuildStep::class.java) {
|
||||
class BuildStepContainer(val project: Project): NamedDomainObjectContainer<BuildStep> by project.container(BuildStep::class.java) {
|
||||
fun step(name: String, configure: Action<BuildStep>) =
|
||||
maybeCreate(name).apply { configure.execute(this) }
|
||||
|
||||
fun step(name: String, configure: Closure<Unit>) =
|
||||
step(name, ConfigureUtil.configureUsing(configure))
|
||||
step(name, { project.configure(this, configure) })
|
||||
}
|
||||
|
||||
open class CompileBenchmarkExtension @Inject constructor(val project: Project) {
|
||||
@@ -32,7 +31,7 @@ open class CompileBenchmarkExtension @Inject constructor(val project: Project) {
|
||||
var compilerOpts: List<String> = emptyList()
|
||||
|
||||
fun buildSteps(configure: Action<BuildStepContainer>): Unit = buildSteps.let { configure.execute(it) }
|
||||
fun buildSteps(configure: Closure<Unit>): Unit = buildSteps(ConfigureUtil.configureUsing(configure))
|
||||
fun buildSteps(configure: Closure<Unit>): Unit = buildSteps { project.configure(this, configure) }
|
||||
}
|
||||
|
||||
open class CompileBenchmarkingPlugin : Plugin<Project> {
|
||||
@@ -70,7 +69,7 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
|
||||
isIgnoreExitValue = true
|
||||
konanRun.dependsOn(this)
|
||||
doLast {
|
||||
exitCodes[name] = execResult!!.exitValue
|
||||
exitCodes[name] = executionResult.get().exitValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
|
||||
val mainCompilation = kotlin.jvm().compilations.getByName("main")
|
||||
val runtimeDependencies = configurations.getByName(mainCompilation.runtimeDependencyConfigurationName)
|
||||
classpath(files(mainCompilation.output.allOutputs, runtimeDependencies))
|
||||
main = "MainKt"
|
||||
mainClass.set("MainKt")
|
||||
|
||||
group = BENCHMARKING_GROUP
|
||||
description = "Runs the benchmark for Kotlin/JVM."
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ExecClang
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import kotlinBuildProperties
|
||||
import isNativeRuntimeDebugInfoEnabled
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.process.ExecOperations
|
||||
@@ -133,7 +132,7 @@ abstract class CompileToBitcode @Inject constructor(
|
||||
val compilerFlags: List<String>
|
||||
get() {
|
||||
val commonFlags = listOfNotNull(
|
||||
"-gdwarf-2".takeIf { project.kotlinBuildProperties.isNativeRuntimeDebugInfoEnabled },
|
||||
"-gdwarf-2".takeIf { project.kotlinBuildProperties.getBoolean("kotlin.native.isNativeRuntimeDebugInfoEnabled", false) },
|
||||
"-c", "-emit-llvm") + headersDirs.map { "-I$it" }
|
||||
val sanitizerFlags = when (sanitizer) {
|
||||
null -> listOf()
|
||||
|
||||
+1
@@ -205,6 +205,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
|
||||
private const val COMPILATION_DATABASE_TASK_NAME = "CompilationDatabase"
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private val String.capitalized: String
|
||||
get() = replaceFirstChar { it.uppercase() }
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import org.jetbrains.kotlin.VersionGenerator
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
@@ -26,46 +25,31 @@ plugins {
|
||||
val rootBuildDirectory by extra(file(".."))
|
||||
apply(from="../gradle/loadRootProperties.gradle")
|
||||
|
||||
val konanVersion: String by extra
|
||||
val kotlinVersion = project.bootstrapKotlinVersion
|
||||
|
||||
group = "org.jetbrains.kotlin"
|
||||
version = konanVersion
|
||||
|
||||
repositories {
|
||||
maven("https://cache-redirector.jetbrains.com/maven-central")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// FIXME(ddol): KLIB-REFACTORING-CLEANUP: drop generation of KonanVersion!
|
||||
val generateCompilerVersion by tasks.registering(VersionGenerator::class) {}
|
||||
|
||||
sourceSets["main"].withConvention(KotlinSourceSet::class) {
|
||||
kotlin.srcDir("src/main/kotlin")
|
||||
kotlin.srcDir("src/library/kotlin")
|
||||
kotlin.srcDir(generateCompilerVersion.get().versionSourceDirectory)
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
dependsOn(generateCompilerVersion)
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.freeCompilerArgs = listOf("-Xskip-prerelease-check")
|
||||
}
|
||||
|
||||
tasks.clean {
|
||||
doFirst {
|
||||
val versionSourceDirectory = generateCompilerVersion.get().versionSourceDirectory
|
||||
if (versionSourceDirectory.exists()) {
|
||||
versionSourceDirectory.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
archiveFileName.set("shared.jar")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:${project.bootstrapKotlinVersion}")
|
||||
kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||
|
||||
@@ -784,4 +784,5 @@ if (buildProperties.isKotlinNativeEnabled) {
|
||||
include ":kotlin-native-compiler-embeddable"
|
||||
project(":kotlin-native-compiler-embeddable").projectDir = "$rootDir/kotlin-native/prepare/kotlin-native-embeddable-compiler" as File
|
||||
include ':kotlin-native:build-tools'
|
||||
include ':kotlin-native:shared'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user