[K/N][perf] Performance project build
* Add build-tools plugin * Cleanup code * Add missing methods after the move
This commit is contained in:
committed by
Space Team
parent
71eaa43d95
commit
c49128aa99
@@ -1,5 +1,5 @@
|
||||
cacheRedirectorEnabled=true
|
||||
bootstrap.kotlin.default.version=1.8.20-dev-5197
|
||||
bootstrap.kotlin.default.version=1.9.0-dev-877
|
||||
kotlin.build.gradlePlugin.version=0.0.39
|
||||
|
||||
org.gradle.java.installations.fromEnv=\
|
||||
|
||||
@@ -293,26 +293,6 @@ fun Task.dependsOnKonanBuildingTask(artifact: String, target: KonanTarget) {
|
||||
}
|
||||
|
||||
//endregion
|
||||
// Run command line from string.
|
||||
fun Array<String>.runCommand(
|
||||
workingDir: File = File("."),
|
||||
timeoutAmount: Long = 60,
|
||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS
|
||||
): String {
|
||||
return try {
|
||||
ProcessBuilder(*this)
|
||||
.directory(workingDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start().apply {
|
||||
waitFor(timeoutAmount, timeoutUnit)
|
||||
}.inputStream.bufferedReader().readText()
|
||||
} catch (e: Exception) {
|
||||
println("Couldn't run command ${this.joinToString(" ")}")
|
||||
println(e.stackTrace.joinToString("\n"))
|
||||
error(e.message!!)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun compileSwift(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import org.jetbrains.kotlin.BuildRegister
|
||||
import org.jetbrains.kotlin.MPPTools
|
||||
import org.jetbrains.kotlin.UtilsKt
|
||||
import org.jetbrains.kotlin.konan.CompilerVersionKt
|
||||
import org.jetbrains.kotlin.konan.target.DistributionKt
|
||||
import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||
|
||||
@@ -17,7 +16,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
ext["withoutEmbedabble"] = true
|
||||
MiscKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean())
|
||||
UtilsKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean())
|
||||
ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(project)
|
||||
ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(project)
|
||||
|
||||
@@ -30,6 +29,7 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("kotlin.native.build-tools-conventions")
|
||||
id("org.jetbrains.kotlin.multiplatform") apply false
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ subprojects { proj ->
|
||||
proj.logger.info("${proj.name}<<<[$key] = $value>>>")
|
||||
proj.ext.set(key, value)
|
||||
}
|
||||
MiscKt.kotlinInit(proj, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
||||
UtilsKt.kotlinInit(proj, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
||||
proj.ext.platformManager = platformManager
|
||||
proj.ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(proj)
|
||||
proj.ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(proj)
|
||||
|
||||
@@ -38,19 +38,12 @@ tasks.validatePlugins.configure {
|
||||
}
|
||||
|
||||
|
||||
sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
|
||||
kotlin.filter.exclude("**/FileCheckTest.kt")
|
||||
// TODO: Consider moving required stuff from kotlin-native/build-tools/ to buildSrc/ here.
|
||||
kotlin.filter.exclude("**/bitcode/**")
|
||||
kotlin.filter.exclude("**/cpp/**")
|
||||
kotlin.filter.exclude("**/testing/**")
|
||||
|
||||
kotlin.srcDir("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")
|
||||
sourceSets["main"].kotlin {
|
||||
srcDir("src/main/kotlin")
|
||||
srcDir("../../shared/src/library/kotlin")
|
||||
srcDir("../../shared/src/main/kotlin")
|
||||
srcDir("../../tools/benchmarks/shared/src/main/kotlin/report")
|
||||
srcDir("../../../native/utils/src")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
@@ -80,8 +73,6 @@ dependencies {
|
||||
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("gradle.plugin.com.github.johnrengelman:shadow:$shadowVersion")
|
||||
@@ -115,12 +106,6 @@ gradlePlugin {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.4"
|
||||
apiVersion = "1.4"
|
||||
}
|
||||
}
|
||||
tasks.withType<JavaCompile> {
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
kotlin.build.gradlePlugin.version=0.0.39
|
||||
kotlin.build.gradlePlugin.version=0.0.39
|
||||
+4
@@ -15,4 +15,8 @@ object PlatformInfo {
|
||||
|
||||
@JvmStatic
|
||||
fun isLinux() = HostManager.hostIsLinux
|
||||
|
||||
@JvmStatic
|
||||
val hostName: String
|
||||
get() = HostManager.hostName
|
||||
}
|
||||
+31
-1
@@ -2,7 +2,16 @@
|
||||
* 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 java.io.File
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinBuildProperties
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
fun Project.kotlinInit(cacheRedirectorEnabled: Boolean) {
|
||||
extensions.extraProperties["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion
|
||||
@@ -37,4 +46,25 @@ fun sendGetRequest(url: String, username: String? = null, password: String? = nu
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.connect()
|
||||
return connection.inputStream.use { it.reader().use { reader -> reader.readText() } }
|
||||
}
|
||||
}
|
||||
|
||||
val Project.platformManager
|
||||
get() = findProperty("platformManager") as PlatformManager
|
||||
|
||||
val validPropertiesNames = listOf(
|
||||
"konan.home",
|
||||
"org.jetbrains.kotlin.native.home",
|
||||
"kotlin.native.home"
|
||||
)
|
||||
|
||||
val Project.kotlinNativeDist
|
||||
get() = rootProject.currentKotlinNativeDist
|
||||
|
||||
val Project.currentKotlinNativeDist
|
||||
get() = file(validPropertiesNames.firstOrNull { hasProperty(it) }?.let { findProperty(it) } ?: "dist")
|
||||
|
||||
val kotlinNativeHome
|
||||
get() = validPropertiesNames.mapNotNull(System::getProperty).first()
|
||||
|
||||
val Project.useCustomDist
|
||||
get() = validPropertiesNames.any { hasProperty(it) }
|
||||
+53
@@ -9,9 +9,13 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinNativeTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import java.nio.file.Paths
|
||||
import java.net.URL
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.nio.file.Path
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
enum class CodeSizeEntity { FRAMEWORK, EXECUTABLE }
|
||||
@@ -93,6 +97,55 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
fun Array<String>.runCommand(
|
||||
workingDir: File = File("."),
|
||||
timeoutAmount: Long = 60,
|
||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS
|
||||
): String {
|
||||
return try {
|
||||
ProcessBuilder(*this)
|
||||
.directory(workingDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start().apply {
|
||||
waitFor(timeoutAmount, timeoutUnit)
|
||||
}.inputStream.bufferedReader().readText()
|
||||
} catch (e: Exception) {
|
||||
println("Couldn't run command ${this.joinToString(" ")}")
|
||||
println(e.stackTrace.joinToString("\n"))
|
||||
error(e.message!!)
|
||||
}
|
||||
}
|
||||
fun compileSwift(
|
||||
project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
|
||||
output: Path, fullBitcode: Boolean = false
|
||||
) {
|
||||
val platform = project.platformManager.platform(target)
|
||||
assert(platform.configurables is AppleConfigurables)
|
||||
val configs = platform.configurables as AppleConfigurables
|
||||
val compiler = configs.absoluteTargetToolchain + "/usr/bin/swiftc"
|
||||
|
||||
val swiftTarget = configs.targetTriple.withOSVersion(configs.osVersionMin).toString()
|
||||
|
||||
val args = listOf("-sdk", configs.absoluteTargetSysRoot, "-target", swiftTarget) +
|
||||
options + "-o" + output.toString() + sources +
|
||||
if (fullBitcode) listOf("-embed-bitcode", "-Xlinker", "-bitcode_verify") else listOf("-embed-bitcode-marker")
|
||||
|
||||
val out = mutableListOf<String>().apply {
|
||||
add(compiler)
|
||||
addAll(args)
|
||||
}.toTypedArray().runCommand(timeoutAmount = 240)
|
||||
|
||||
println(
|
||||
"""
|
||||
|$compiler finished with:
|
||||
|options: ${args.joinToString(separator = " ")}
|
||||
|output: $out
|
||||
""".trimMargin()
|
||||
)
|
||||
check(output.toFile().exists()) { "Compiler swiftc hasn't produced an output file: $output" }
|
||||
}
|
||||
|
||||
override fun Project.collectCodeSize(applicationName: String) =
|
||||
getCodeSizeBenchmark(applicationName,
|
||||
if (benchmark.useCodeSize == CodeSizeEntity.FRAMEWORK)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -13,6 +13,8 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
includeBuild '../build-tools'
|
||||
|
||||
include ':ring'
|
||||
include ':cinterop'
|
||||
include ':helloworld'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.UtilsKt
|
||||
|
||||
buildscript {
|
||||
ext.rootBuildDirectory = file('../..')
|
||||
@@ -14,7 +15,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
ext["withoutEmbedabble"] = true
|
||||
MiscKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
||||
UtilsKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
||||
ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(project)
|
||||
ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(project)
|
||||
ext["kotlinVersion"] = project.bootstrapKotlinVersion
|
||||
|
||||
@@ -42,19 +42,12 @@ tasks.validatePlugins.configure {
|
||||
}
|
||||
|
||||
|
||||
sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
|
||||
kotlin.filter.exclude("**/FileCheckTest.kt")
|
||||
// TODO: Consider moving required stuff from kotlin-native/build-tools/ to buildSrc/ here.
|
||||
kotlin.filter.exclude("**/bitcode/**")
|
||||
kotlin.filter.exclude("**/cpp/**")
|
||||
kotlin.filter.exclude("**/testing/**")
|
||||
|
||||
kotlin.srcDir("../../../build-tools/src/main/kotlin")
|
||||
kotlin.srcDir("../../../performance/buildSrc/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")
|
||||
sourceSets["main"].kotlin {
|
||||
srcDir("../../../performance/buildSrc/src/main/kotlin")
|
||||
srcDir("../../../shared/src/library/kotlin")
|
||||
srcDir("../../../shared/src/main/kotlin")
|
||||
srcDir("../../benchmarks/shared/src/main/kotlin/report")
|
||||
srcDir("../../../../native/utils/src")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
+1
-1
@@ -74,7 +74,7 @@ open class KonanCacheTask: DefaultTask() {
|
||||
@TaskAction
|
||||
fun compile() {
|
||||
// This code uses bootstrap version of util-klib and fails due to the older default ABI than library being used
|
||||
// A possible solution is to read it manually from manifest file or this check should be done bu the compiler itself
|
||||
// A possible solution is to read it manually from manifest file or this check should be done by the compiler itself
|
||||
// check(klibUniqName == readKlibUniqNameFromManifest()) {
|
||||
// "klibUniqName mismatch: configured '$klibUniqName', resolved '${readKlibUniqNameFromManifest()}'"
|
||||
// }
|
||||
|
||||
@@ -13,7 +13,8 @@ buildscript {
|
||||
}
|
||||
|
||||
extra["withoutEmbedabble"] = true
|
||||
project.kotlinInit(findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
||||
extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion
|
||||
extra["kotlinVersion"] = findProperty("kotlinVersion")
|
||||
val bootstrapKotlinVersion: String by extra(project.bootstrapKotlinVersion)
|
||||
val kotlinVersion: String by extra(bootstrapKotlinVersion)
|
||||
|
||||
|
||||
@@ -34,23 +34,22 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(8))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.validatePlugins.configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
|
||||
kotlin.filter.exclude("**/FileCheckTest.kt")
|
||||
// TODO: Consider moving required stuff from kotlin-native/build-tools/ to buildSrc/ here.
|
||||
kotlin.filter.exclude("**/bitcode/**")
|
||||
kotlin.filter.exclude("**/cpp/**")
|
||||
kotlin.filter.exclude("**/testing/**")
|
||||
|
||||
kotlin.srcDir("../../../build-tools/src/main/kotlin")
|
||||
kotlin.srcDir("../../../performance/buildSrc/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")
|
||||
sourceSets["main"].kotlin {
|
||||
srcDir("../../../performance/buildSrc/src/main/kotlin")
|
||||
srcDir("../../../shared/src/library/kotlin")
|
||||
srcDir("../../../shared/src/main/kotlin")
|
||||
srcDir("../../benchmarks/shared/src/main/kotlin/report")
|
||||
srcDir("../../../../native/utils/src")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
|
||||
@@ -24,4 +24,5 @@ dependencies {
|
||||
implementation project(':kotlin-native:klib')
|
||||
implementation project(":kotlin-native:utilities:basic-utils")
|
||||
implementation project(path: ":kotlin-native:endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
|
||||
implementation project(":kotlin-native-shared")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user