[performance] enable project performance
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index f9e20d1..78622ce 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts
@@ -119,13 +119,22 @@ 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") kotlin.srcDir("../compiler/util-klib/src") kotlin.srcDir("../native/utils/src") } kotlin.srcDir(project.kotlinNativeVersionSrc()) - kotlin.exclude("**/benchmark/SwiftBenchmarkingPlugin.kt") + /** + * TODO: mentioned bellow and Co it'd be better to move to :kotlin-native:performance:buildSrc, + * because all this relates to benchmarking. + */ + kotlin.exclude("**/benchmark/*.kt") + kotlin.exclude("**/kotlin/MPPTools.kt") + kotlin.exclude("**/kotlin/RegressionsReporter.kt") + kotlin.exclude("**/kotlin/RunJvmTask.kt") + kotlin.exclude("**/kotlin/RunKotlinNativeTask.kt") + kotlin.exclude("**/kotlin/BuildRegister.kt") + kotlin.exclude("**/kotlin/benchmarkUtils.kt") } tasks.validatePlugins.configure { @@ -219,18 +228,6 @@ 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"
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CoverageTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CoverageTest.kt index 5ebdf1a..715faed 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CoverageTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CoverageTest.kt
@@ -11,7 +11,6 @@ import org.gradle.api.tasks.Input import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.konan.target.AppleConfigurables -import org.jetbrains.kotlin.gradle.plugin.tasks.* /** * Test task for -Xcoverage and -Xlibraries-to-cover flags. Requires a binary to be built by the Konan plugin
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunKotlinNativeTask.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunKotlinNativeTask.kt index b893d2e..e4ce3ec 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunKotlinNativeTask.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunKotlinNativeTask.kt
@@ -62,7 +62,7 @@ executable = "cset" args("shield", "--exec", "--", executable) } else { - this.executable = executable + executable = this@RunKotlinNativeTask.executable } args(argumentsList) @@ -104,7 +104,7 @@ fun run() { val output = ByteArrayOutputStream() project.exec { - executable = executable + executable = this@RunKotlinNativeTask.executable args("list") standardOutput = output }
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt index 14b2ebfb..46d40e9 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt
@@ -20,7 +20,6 @@ import java.net.HttpURLConnection import java.net.URL import java.util.Base64 -import org.jetbrains.report.json.* import java.nio.file.Path import org.jetbrains.kotlin.konan.file.File as KFile import org.gradle.nativeplatform.toolchain.internal.* @@ -97,7 +96,10 @@ "konan.home") val Project.kotlinNativeDist - get() = rootProject.file(validPropertiesNames.firstOrNull{ hasProperty(it) }?.let{ findProperty(it) } ?: "dist") + get() = rootProject.currentKotlinNativeDist + +val Project.currentKotlinNativeDist + get() = file(validPropertiesNames.firstOrNull{ hasProperty(it) }?.let{ findProperty(it) } ?: "dist") val kotlinNativeHome get() = validPropertiesNames.mapNotNull(System::getProperty).first() @@ -255,31 +257,6 @@ val teamCityUrl = "http://buildserver.labs.intellij.net" -// List of commits. -class CommitsList(data: JsonElement): ConvertedFromJson { - - val commits: List<Commit> - - init { - if (data !is JsonObject) { - error("Commits description is expected to be a json object!") - } - val changesElement = data.getOptionalField("change") - commits = changesElement?.let { - if (changesElement !is JsonArray) { - error("Change field is expected to be an array. Please, check source.") - } - changesElement.jsonArray.map { - with(it as JsonObject) { - Commit(elementToString(getRequiredField("version"), "version"), - elementToString(getRequiredField("username"), "username"), - elementToString(getRequiredField("webUrl"), "webUrl") - ) - } - } - } ?: listOf<Commit>() - } -} fun buildsUrl(buildLocator: String) = "$teamCityUrl/app/rest/builds/?locator=$buildLocator" @@ -302,13 +279,6 @@ return connection.inputStream.use { it.reader().use { reader -> reader.readText() } } } -fun getBuildProperty(buildJsonDescription: String, property: String) = - with(JsonTreeParser.parse(buildJsonDescription) as JsonObject) { - if (getPrimitive("count").int == 0) { - error("No build information on TeamCity for $buildJsonDescription!") - } - (getArray("build").getObject(0).getPrimitive(property) as JsonLiteral).unquoted() - } @JvmOverloads fun compileSwift(project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt index 47f902e..f70009a 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt
@@ -125,16 +125,11 @@ protected open fun Project.configureSourceSets(kotlinVersion: String) { with(kotlin.sourceSets) { commonMain.dependencies { - implementation(project(":kotlin-stdlib-common")) + implementation(files("${project.findProperty("kotlin_dist")}/kotlinc/lib/kotlin-stdlib.jar")) } - project.configurations.getByName(nativeMain.implementationConfigurationName).apply { - // Exclude dependencies already included into K/N distribution (aka endorsed libraries). - exclude(mapOf("module" to "kotlinx.cli")) - } - - repositories.maven { - setUrl(kotlinStdlibRepo) + repositories.flatDir { + dir("${project.findProperty("kotlin_dist")}/kotlinc/lib") } additionalConfigurations(this@configureSourceSets) @@ -268,7 +263,13 @@ pluginManager.apply("kotlin-multiplatform") // Use Kotlin compiler version specified by the project property. - dependencies.add("kotlinCompilerClasspath", "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion") + target.logger.info("BenchmarkingPlugin.kt:apply($kotlinVersion)") + dependencies.add( + "kotlinCompilerClasspath", files( + "${project.findProperty("kotlin_dist")}/kotlinc/lib/kotlin-compiler.jar", + "${project.findProperty("kotlin_dist")}/kotlinc/lib/kotlin-daemon.jar" + ) + ) addTimeListener(this) extensions.create(benchmarkExtensionName, benchmarkExtensionClass.java, this)
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt index f9d1cb9..ca7cc0e 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt
@@ -124,7 +124,9 @@ override fun NamedDomainObjectContainer<KotlinSourceSet>.additionalConfigurations(project: Project) { jvmMain.dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.kotlinStdlibVersion}") + implementation(project.files("${project.findProperty("kotlin_dist")}/kotlinc/lib/kotlin-stdlib-jdk8.jar")) + println("implementation(${project.name}: ${project.projectDir}): ${project.currentKotlinNativeDist}/libs/kotlinx.cli-jvm-${project.kotlinVersion}.jar") + implementation(project.files("${project.currentKotlinNativeDist}/libs/kotlinx.cli-jvm-${project.kotlinVersion}.jar")) } }
diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmarkUtils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmarkUtils.kt new file mode 100644 index 0000000..8648fa4 --- /dev/null +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmarkUtils.kt
@@ -0,0 +1,42 @@ +/* + * Copyright 2010-2021 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.jetbrains.report.json.* + +// List of commits. +class CommitsList(data: JsonElement): ConvertedFromJson { + + val commits: List<Commit> + + init { + if (data !is JsonObject) { + error("Commits description is expected to be a json object!") + } + val changesElement = data.getOptionalField("change") + commits = changesElement?.let { + if (changesElement !is JsonArray) { + error("Change field is expected to be an array. Please, check source.") + } + changesElement.jsonArray.map { + with(it as JsonObject) { + Commit(elementToString(getRequiredField("version"), "version"), + elementToString(getRequiredField("username"), "username"), + elementToString(getRequiredField("webUrl"), "webUrl") + ) + } + } + } ?: listOf<Commit>() + } +} + +fun getBuildProperty(buildJsonDescription: String, property: String) = + with(JsonTreeParser.parse(buildJsonDescription) as JsonObject) { + if (getPrimitive("count").int == 0) { + error("No build information on TeamCity for $buildJsonDescription!") + } + (getArray("build").getObject(0).getPrimitive(property) as JsonLiteral).unquoted() + }
diff --git a/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/BenchmarkReport.kt b/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/BenchmarkReport.kt deleted file mode 100644 index fa646df..0000000 --- a/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/BenchmarkReport.kt +++ /dev/null
@@ -1,95 +0,0 @@ -/* - * 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.report.json - -open class JsonSerializable -data class JsonObject(val content: Map<String, JsonElement>) : JsonElement(), Map<String, JsonElement> by content { - fun getOrNull(key: String): JsonElement? = null - fun getObject(key: String): JsonObject = JsonObject(emptyMap<String, JsonElement>()) - fun getArray(key: String): JsonArray = JsonArray(emptyList()) - fun getPrimitive(key: String): JsonPrimitive = JsonNull -} -data class JsonLiteral internal constructor( - private val body: Any, - private val isString: Boolean -) : JsonPrimitive() { - override val content = body.toString() - override val contentOrNull: String = content - constructor(number: Number) : this(number, false) - constructor(boolean: Boolean) : this(boolean, false) - constructor(string: String) : this(string, true) - fun unquoted() = "" -} - -sealed class JsonPrimitive():JsonElement(){ - abstract val content: String - abstract val contentOrNull: String? - val int: Int get() = 0 -} - -object JsonNull : JsonPrimitive() { - override val content: String = "null" - override val contentOrNull: String? = null -} -open class JsonElement:JsonSerializable() { - open val jsonObject: JsonObject - get() = error("JsonObject") - open val jsonArray: JsonArray - get() = error("JsonArray") -} -open class JsonTreeParser:JsonSerializable() { - companion object{ - fun parse(benchDesc:String) = JsonElement() - } -} - -open class JsonArray(val content: List<JsonElement>):JsonElement(), List<JsonElement> by content { - fun getObject(index: Int): JsonObject = JsonObject(emptyMap<String, JsonElement>()) -} - -open class BenchmarksReport(val env: Environment, benchmarksList: List<BenchmarkResult>, val compiler: Compiler) : JsonSerializable() { - constructor() : this(Environment(Environment.Machine("Pentium Pro", "Haiku OS"), Environment.JDKInstance("KaffeJVM", "Kaffe")), - emptyList<BenchmarkResult>(), - Compiler(Compiler.Backend(Compiler.BackendType.NATIVE, "1.0", emptyList()),"1.0")) - companion object { - fun create(data: JsonElement): BenchmarksReport = BenchmarksReport() - } - fun toJson() = "{}" - operator fun plus(other: BenchmarksReport): BenchmarksReport = this -} -open class BenchmarkResult(val name: String, val status: Status, - val score: Double, val metric: Metric, val runtimeInUs: Double, - val repeat: Int, val warmup: Int) : JsonSerializable() { - enum class Status(val value: String) { - PASSED("PASSED"), - FAILED("FAILED") - } - enum class Metric(val suffix: String, val value: String) { - EXECUTION_TIME("", "EXECUTION_TIME"), - CODE_SIZE(".codeSize", "CODE_SIZE"), - COMPILE_TIME(".compileTime", "COMPILE_TIME"), - BUNDLE_SIZE(".bundleSize", "BUNDLE_SIZE") - } -} - -data class Environment(val machine: Machine, val jdk: JDKInstance) : JsonSerializable() { - data class Machine(val cpu: String, val os: String) : JsonSerializable() - data class JDKInstance(val version: String, val vendor: String) : JsonSerializable() -} - -data class Compiler(val backend: Backend, val kotlinVersion: String) : JsonSerializable() { - - enum class BackendType(val type: String) { - JVM("jvm"), - NATIVE("native") - } - data class Backend(val type: BackendType, val version: String, val flags: List<String>) : JsonSerializable() - companion object{ - fun backendTypeFromString(ignored0:String? = null , ignored1:String? = null) = Compiler.BackendType.NATIVE - } -} - -fun parseBenchmarksArray(data: JsonElement): List<BenchmarkResult> = emptyList<BenchmarkResult>()
diff --git a/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/ConvertedFromJson.kt b/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/ConvertedFromJson.kt deleted file mode 100644 index bf33c50..0000000 --- a/kotlin-native/build-tools/src/tmp/kotlin/org/jetbrains/report/json/ConvertedFromJson.kt +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * 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.report.json - -// Entity can be created from json description. -interface ConvertedFromJson { - // Methods for conversion to expected type with checks of possibility of such conversions. - fun elementToDouble(element: JsonElement, name: String): Double = - if (element is JsonPrimitive) - 0.0 - else - error("Field '$name' in '$element' is expected to be a double number. Please, check origin files.") - - fun elementToInt(element: JsonElement, name: String): Int = - if (element is JsonPrimitive) - 0 - else - error("Field '$name' in '$element' is expected to be an integer number. Please, check origin files.") - - fun elementToString(element: JsonElement, name:String): String = - if (element is JsonLiteral) - "" - else - error("Field '$name' in '$element' is expected to be a string. Please, check origin files.") - - fun elementToStringOrNull(element: JsonElement, name:String): String? = - when (element) { - else -> error("Field '$name' in '$element' is expected to be a string. Please, check origin files.") - } -} - -fun JsonObject.getRequiredField(fieldName: String): JsonElement { - error("Field '$fieldName' doesn't exist in '$this'. Please, check origin files.") -} - -fun JsonObject.getOptionalField(fieldName: String): JsonElement? { - return getOrNull(fieldName) -} \ No newline at end of file
diff --git a/kotlin-native/gradle/kotlinGradlePlugin.gradle b/kotlin-native/gradle/kotlinGradlePlugin.gradle index e2b6f87..e7a2281 100644 --- a/kotlin-native/gradle/kotlinGradlePlugin.gradle +++ b/kotlin-native/gradle/kotlinGradlePlugin.gradle
@@ -2,7 +2,7 @@ project.buildscript.repositories { maven { - url project.bootstrapKotlinRepo + url BootstrapKt.getBootstrapKotlinRepo(project) } if (UtilsKt.getCacheRedirectorEnabled(project)) maven { url 'https://cache-redirector.jetbrains.com/maven-central' } @@ -17,6 +17,8 @@ kotlinCompilerClasspath } -project.dependencies { - kotlinCompilerClasspath(project(path: ":kotlin-compiler-embeddable", configuration: "runtimeJar")) +if (!(project.findProperty("withoutEmbedabble")?.toString()?.toBoolean() ?: false)) { + project.dependencies { + kotlinCompilerClasspath(project(path: ":kotlin-compiler-embeddable", configuration: "runtimeJar")) + } }
diff --git a/kotlin-native/performance/build.gradle b/kotlin-native/performance/build.gradle index 01d14c4..c24a488 100644 --- a/kotlin-native/performance/build.gradle +++ b/kotlin-native/performance/build.gradle
@@ -2,36 +2,96 @@ import org.jetbrains.kotlin.RegressionsSummaryReporter import org.jetbrains.kotlin.BuildRegister import org.jetbrains.kotlin.MPPTools +import org.jetbrains.kotlin.UtilsKt +import org.jetbrains.kotlin.konan.CompilerVersionKt buildscript { ext.rootBuildDirectory = file('..') + ext { + def properties = new java.util.Properties() + properties.load(new java.io.FileReader(project.file("../../gradle.properties"))) + properties.each { k, v-> + set(k as String, v) + } + } + ext["withoutEmbedabble"] = true + MiscKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean()) + ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(project) + ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(project) + apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" repositories { - maven { url 'https://cache-redirector.jetbrains.com/jcenter'} - maven { url 'https://cache-redirector.jetbrains.com/maven-central' } mavenCentral() - maven { url buildKotlinCompilerRepo } - maven { url kotlinCompilerRepo } jcenter() maven { url "https://kotlin.bintray.com/kotlinx" } } + repositories { + maven{ url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } + } dependencies { - classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion" + classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + } +} + +def globalProperties = new java.util.Properties() +ext.kotlin_root = project.file("../..").absolutePath +project.logger.info("kotlin_root: $kotlin_root") +globalProperties.load(new java.io.FileReader(project.file("$kotlin_root/gradle.properties"))) +ext.kotlinNativeVersionInResources = true +//TODO: fix VersionGeneratorKt.kotlinNativeVersionValue(project) +def versionString = VersionGeneratorKt.kotlinNativeVersionResourceFile(project).readLines().first() +def kotlinNativeVersionObject = CompilerVersionKt.parseCompilerVersion(versionString) + +subprojects { proj -> + globalProperties.each { k, v-> + proj.logger.info("${proj.name}<<<[$k] = $v>>>") + proj.ext.set(k as String, v) + } + MiscKt.kotlinInit(proj, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false) + proj.ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(proj) + proj.ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(proj) + proj.ext["kotlin.native.home"] = proj.projectDir.relativePath(UtilsKt.getKotlinNativeDist(project)) + proj.ext["konanVersion"] = kotlinNativeVersionObject.toString() + proj.ext["kotlin.native.enabled"] = true + proj.logger.info("${proj.name}<<<[kotlin.native.home] = ${proj.ext["kotlin.native.home"]}") + proj.logger.info("${proj.name}<<<[konanVersion] = ${proj.ext["konanVersion"]}>>>") + + proj.ext["buildNumber"] = findProperty("build.number")?.toString() ?: defaultSnapshotVersion + proj.ext["kotlinVersion"] = findProperty("deployVersion")?.toString()?.identity { deploySnapshotStr -> + if (deploySnapshotStr != "default.snapshot") deploySnapshotStr else defaultSnapshotVersion + } ?: proj.ext["buildNumber"] + + proj.buildscript.repositories { + jcenter() + maven { + url proj.ext["bootstrapKotlinRepo"] + } + } + proj.repositories { + maven { + url proj.ext["bootstrapKotlinRepo"] + } } } def rootBuildDirectory = projectDir.parentFile +task buildAnalyzer { + dependsOn gradle.includedBuild("benchmarksAnalyzer").task(":${getAnalyzerTargetName()}Binaries") +} + task konanRun { + dependsOn buildAnalyzer subprojects.each { dependsOn "${it.path}:konanRun" } } task jvmRun { + dependsOn buildAnalyzer subprojects.each { dependsOn "${it.path}:jvmRun" } @@ -41,6 +101,7 @@ subprojects.each { dependsOn "${it.path}:clean" } + dependsOn gradle.includedBuild("benchmarksAnalyzer").task(":clean") doLast { delete "${buildDir.absolutePath}" } @@ -60,9 +121,6 @@ private String findAnalyzerBinary() { String result = "${projectDir}/../${analyzerToolDirectory}/${getAnalyzerTargetName()}/" + "${analyzerTool}ReleaseExecutable/${analyzerTool}${MPPTools.getNativeProgramExtension()}" - - if (file(result).exists()) return result - else return null } // Produce and send slack report. @@ -247,59 +305,65 @@ task teamCityStat(type:Exec) { def analyzer = findAnalyzerBinary() - if (analyzer != null) { - commandLine "${analyzer}", "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}" - } else { - println("No analyzer $analyzerTool found in subdirectories of ${rootBuildDirectory}/${analyzerToolDirectory}") - } + commandLine analyzer, "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}" } task cinterop { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'cinterop:konanRun' } task framework { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'framework:konanRun' } task helloworld { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'helloworld:konanRun' } task objcinterop { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'objcinterop:konanRun' } task ring { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'ring:konanRun' } task numerical { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'numerical:konanRun' } task startup { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'startup:konanRun' } task swiftinterop { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'swiftinterop:konanRun' } task videoplayer { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'videoplayer:konanRun' } task KotlinVsSwift { dependsOn 'clean' + dependsOn buildAnalyzer dependsOn 'KotlinVsSwift:konanRun' } \ No newline at end of file
diff --git a/kotlin-native/performance/buildSrc/build.gradle.kts b/kotlin-native/performance/buildSrc/build.gradle.kts new file mode 100644 index 0000000..5710a23 --- /dev/null +++ b/kotlin-native/performance/buildSrc/build.gradle.kts
@@ -0,0 +1,134 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.util.Properties +import java.io.FileReader + +extra["versions.native-platform"] = "0.14" + + + +buildscript { + java.util.Properties().also { + it.load(java.io.FileReader(project.file("../../../gradle.properties"))) + }.forEach { k, v-> + println("${project.name}<<<[$k] = $v>>>") + extra[k as String] = v + } + val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false + + extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion + kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) + + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + project.bootstrapKotlinRepo?.let { + maven(url = it) + } + } + + dependencies { + classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") + } +} + +apply{ + plugin("kotlin") + plugin("kotlin-sam-with-receiver") +} +plugins { + `kotlin-dsl` + //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" +} + +val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true +repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/") + maven("https://kotlin.bintray.com/kotlin-dependencies") + maven("https://cache-redirector.jetbrains.com/dl.kotlin.bintray.com/kotlinx") + gradlePluginPortal() + maven("https://kotlin.bintray.com/kotlin-dev") + extra["bootstrapKotlinRepo"]?.let { + maven(url = it) + } +} + +tasks.validatePlugins.configure { + enabled = false +} + + +sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { + kotlin.srcDir("src/main/kotlin") + //kotlin.srcDir("tools/benchmarks/shared/src/main/kotlin") + kotlin.srcDir("../../build-tools/src/main/kotlin") + //kotlin.srcDir("../../build-tools/src/main/kotlin") + kotlin.srcDir("../../shared/src/library/kotlin") + kotlin.srcDir("../../shared/src/main/kotlin") + kotlin.srcDir("../../tools/benchmarks/shared/src/main/kotlin/report") + kotlin.srcDir("../../../native/utils/src") +} + +tasks.withType<KotlinCompile>().configureEach { + kotlinOptions.freeCompilerArgs += + listOf("-Xopt-in=kotlin.RequiresOptIn", + "-Xskip-runtime-version-check", + "-Xopt-in=kotlin.ExperimentalStdlibApi") +} + + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") + api("org.jetbrains.kotlin:kotlin-native-utils:${project.bootstrapKotlinVersion}") + compileOnly(gradleApi()) + val kotlinVersion = project.bootstrapKotlinVersion + val ktorVersion = "1.2.1" + val slackApiVersion = "1.2.0" + val shadowVersion = "5.1.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") + + // Located in <repo root>/shared and always provided by the composite build. + //api("org.jetbrains.kotlin:kotlin-native-shared:$konanVersion") + implementation("com.github.jengelman.gradle.plugins:shadow:$shadowVersion") + + implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion") +} + +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" + } + } +} \ No newline at end of file
diff --git a/kotlin-native/performance/buildSrc/settings.gradle.kts b/kotlin-native/performance/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..694954d --- /dev/null +++ b/kotlin-native/performance/buildSrc/settings.gradle.kts
@@ -0,0 +1,20 @@ +import java.io.File +pluginManagement { + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + mavenCentral() + gradlePluginPortal() + } +} + +buildscript { + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + } + dependencies { + classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + } +} + +//include("tools")
diff --git a/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt b/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt new file mode 100644 index 0000000..936da67 --- /dev/null +++ b/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt
@@ -0,0 +1,13 @@ +/* + * Copyright 2010-2021 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. + */ +import org.gradle.api.Project + +fun Project.kotlinInit(cacheRedirectorEnabled: Boolean) { + extensions.extraProperties["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion + kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) + + extensions.extraProperties["kotlinVersion"] = findProperty("kotlinVersion") + extensions.extraProperties["konanVersion"] = findProperty("konanVersion") +}
diff --git a/kotlin-native/performance/cinterop/gradle.properties b/kotlin-native/performance/cinterop/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/cinterop/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/framework/build.gradle b/kotlin-native/performance/framework/build.gradle index 1c985d7..5987f1b 100644 --- a/kotlin-native/performance/framework/build.gradle +++ b/kotlin-native/performance/framework/build.gradle
@@ -7,9 +7,6 @@ apply from: "$rootProject.projectDir/../gradle/kotlinGradlePlugin.gradle" repositories { - maven { - url 'https://cache-redirector.jetbrains.com/jcenter' - } jcenter() } } @@ -17,18 +14,10 @@ apply plugin: 'kotlin-multiplatform' repositories { - maven { - url 'https://cache-redirector.jetbrains.com/jcenter' - } jcenter() - maven { - url kotlinCompilerRepo - } - maven { - url buildKotlinCompilerRepo - } } + def toolsPath = '../../tools' def frameworkName = 'benchmarksAnalyzer' @@ -37,9 +26,6 @@ kotlin { sourceSets { macosMain { - dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" - } kotlin.srcDir "$toolsPath/benchmarks/shared/src" kotlin.srcDir "$toolsPath/benchmarksAnalyzer/src/main/kotlin" kotlin.srcDir "$rootProject.projectDir/../endorsedLibraries/kotlinx.cli/src/main/kotlin" @@ -69,7 +55,10 @@ } } -task jvmRun(type: RunJvmTask) { +/** + * TODO: it would be better to make help function generating such nop task in buildSrc. + */ +task jvmRun { doLast { println("JVM run is unsupported") }
diff --git a/kotlin-native/performance/framework/gradle.properties b/kotlin-native/performance/framework/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/framework/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/gradle.properties b/kotlin-native/performance/gradle.properties index ed7cd82..a434446 100644 --- a/kotlin-native/performance/gradle.properties +++ b/kotlin-native/performance/gradle.properties
@@ -1,4 +1,4 @@ -kotlin.native.home=../dist +kotlin.native.home=../../dist org.jetbrains.kotlin.native.jvmArgs=-Xmx6G org.gradle.jvmargs=-Xmx2048m jvmWarmup = 1000
diff --git a/kotlin-native/performance/helloworld/gradle.properties b/kotlin-native/performance/helloworld/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/helloworld/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/numerical/gradle.properties b/kotlin-native/performance/numerical/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/numerical/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/objcinterop/gradle.properties b/kotlin-native/performance/objcinterop/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/objcinterop/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/ring/gradle.properties b/kotlin-native/performance/ring/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/ring/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/settings.gradle b/kotlin-native/performance/settings.gradle index cfe0527..8c1b24a 100644 --- a/kotlin-native/performance/settings.gradle +++ b/kotlin-native/performance/settings.gradle
@@ -19,5 +19,4 @@ } } -includeBuild '../build-tools' - +includeBuild '../tools/benchmarksAnalyzer'
diff --git a/kotlin-native/performance/startup/gradle.properties b/kotlin-native/performance/startup/gradle.properties deleted file mode 100644 index e8944cc..0000000 --- a/kotlin-native/performance/startup/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist
diff --git a/kotlin-native/performance/swiftinterop/gradle.properties b/kotlin-native/performance/swiftinterop/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/swiftinterop/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/performance/videoplayer/gradle.properties b/kotlin-native/performance/videoplayer/gradle.properties deleted file mode 100644 index d7062dc..0000000 --- a/kotlin-native/performance/videoplayer/gradle.properties +++ /dev/null
@@ -1 +0,0 @@ -kotlin.native.home=../../dist \ No newline at end of file
diff --git a/kotlin-native/tools/benchmarksAnalyzer/build.gradle b/kotlin-native/tools/benchmarksAnalyzer/build.gradle index 770fdc3..dce7794 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/build.gradle +++ b/kotlin-native/tools/benchmarksAnalyzer/build.gradle
@@ -1,17 +1,25 @@ buildscript { ext.rootBuildDirectory = file('../..') + ext { + def properties = new java.util.Properties() + properties.load(new java.io.FileReader(project.file("$rootBuildDirectory/../gradle.properties"))) + properties.each { k, v-> + project.logger.info("${project.name} $k: $v") + set(k as String, v) + } + } + ext["withoutEmbedabble"] = true + MiscKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false) + ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(project) + ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(project) + ext["kotlinVersion"] = project.bootstrapKotlinVersion + apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" repositories { - maven { - url 'https://cache-redirector.jetbrains.com/jcenter' - } jcenter() - maven { - url kotlinCompilerRepo - } } dependencies { @@ -23,15 +31,9 @@ repositories { maven { - url 'https://cache-redirector.jetbrains.com/jcenter' + url project.bootstrapKotlinRepo } jcenter() - maven { - url kotlinCompilerRepo - } - maven { - url buildKotlinCompilerRepo - } } def getHostName() {
diff --git a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts new file mode 100644 index 0000000..ad88ee5 --- /dev/null +++ b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts
@@ -0,0 +1,110 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.util.Properties +import java.io.FileReader + +extra["versions.native-platform"] = "0.14" + + + +buildscript { + java.util.Properties().also { + it.load(java.io.FileReader(project.file("../../../../gradle.properties"))) + }.forEach { k, v-> + extra[k as String] = v + } + + val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false + + extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion + kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) + extra["bootstrapKotlinRepo"] = project.bootstrapKotlinRepo + extra["bootstrapKotlinVersion"] = project.bootstrapKotlinVersion + + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + project.bootstrapKotlinRepo?.let { + maven(url = it) + } + } + + dependencies { + classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") + } +} + +apply{ + plugin("kotlin") + plugin("kotlin-sam-with-receiver") +} +plugins { + `kotlin-dsl` + //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" +} + +val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true +repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/") + maven("https://kotlin.bintray.com/kotlin-dependencies") + maven("https://cache-redirector.jetbrains.com/dl.kotlin.bintray.com/kotlinx") + gradlePluginPortal() + maven("https://kotlin.bintray.com/kotlin-dev") + extra["bootstrapKotlinRepo"]?.let { + maven(url = it) + } +} + +tasks.validatePlugins.configure { + enabled = false +} + + +sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { + //kotlin.srcDir("tools/benchmarks/shared/src/main/kotlin") + kotlin.srcDir("../../../build-tools/src/main/kotlin") + kotlin.srcDir("../../../performance/buildSrc/src/main/kotlin") + //kotlin.srcDir("../../build-tools/src/main/kotlin") + kotlin.srcDir("../../../shared/src/library/kotlin") + kotlin.srcDir("../../../shared/src/main/kotlin") + kotlin.srcDir("../../benchmarks/shared/src/main/kotlin/report") + kotlin.srcDir("../../../../native/utils/src") +} + +tasks.withType<KotlinCompile>().configureEach { + kotlinOptions.freeCompilerArgs += + listOf("-Xopt-in=kotlin.RequiresOptIn", + "-Xskip-runtime-version-check", + "-Xopt-in=kotlin.ExperimentalStdlibApi") +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") + api("org.jetbrains.kotlin:kotlin-native-utils:${project.bootstrapKotlinVersion}") + compileOnly(gradleApi()) + val kotlinVersion = project.bootstrapKotlinVersion + val ktorVersion = "1.2.1" + val slackApiVersion = "1.2.0" + val shadowVersion = "5.1.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") + + // Located in <repo root>/shared and always provided by the composite build. + //api("org.jetbrains.kotlin:kotlin-native-shared:$konanVersion") + implementation("com.github.jengelman.gradle.plugins:shadow:$shadowVersion") + + implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion") +}
diff --git a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..a3a3c57 --- /dev/null +++ b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts
@@ -0,0 +1,17 @@ +pluginManagement { + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + jcenter() + mavenCentral() + gradlePluginPortal() + } +} + +buildscript { + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + } + dependencies { + classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.24-minamoto-3") + } +} \ No newline at end of file