234 lines
7.8 KiB
Groovy
234 lines
7.8 KiB
Groovy
import org.jetbrains.kotlin.RegressionsReporter
|
|
import org.jetbrains.kotlin.RegressionsSummaryReporter
|
|
import org.jetbrains.kotlin.BuildRegister
|
|
import org.jetbrains.kotlin.MPPTools
|
|
|
|
buildscript {
|
|
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
|
|
repositories {
|
|
maven {
|
|
url 'https://cache-redirector.jetbrains.com/jcenter'
|
|
}
|
|
}
|
|
}
|
|
|
|
def rootBuildDirectory = rootProject.projectDir
|
|
|
|
task konanRun {
|
|
subprojects.each {
|
|
dependsOn it.getTasksByName('konanRun', true)[0]
|
|
}
|
|
}
|
|
|
|
task jvmRun {
|
|
subprojects.each {
|
|
dependsOn it.getTasksByName('jvmRun', true)[0]
|
|
}
|
|
}
|
|
|
|
task clean {
|
|
subprojects.each {
|
|
dependsOn it.getTasksByName('clean', true)[0]
|
|
}
|
|
doLast {
|
|
delete "${buildDir.absolutePath}"
|
|
}
|
|
}
|
|
|
|
defaultTasks 'konanRun'
|
|
|
|
// Produce and send slack report.
|
|
task slackReport(type: RegressionsReporter) {
|
|
def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}",
|
|
"${rootBuildDirectory}/${analyzerToolDirectory}")
|
|
def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")
|
|
if (teamcityConfig && analyzerBinary != null) {
|
|
// Create folder for report (root Kotlin project settings make create report in separate folder).
|
|
def reportDirectory = new File(outputReport).parentFile
|
|
mkdir reportDirectory
|
|
def targetsResults = new File(new File("${rootBuildDirectory}"), "targetsResults").toString()
|
|
mkdir targetsResults
|
|
currentBenchmarksReportFile = "${buildDir.absolutePath}/${nativeJson}"
|
|
analyzer = analyzerBinary
|
|
htmlReport = outputReport
|
|
defaultBranch = project.findProperty('kotlin.native.default.branch') ?: "master"
|
|
def target = System.getProperty("os.name")
|
|
summaryFile = "${targetsResults}/${target}.txt"
|
|
bundleBuild = project.findProperty('kotlin.bundleBuild') == null ? false : true
|
|
}
|
|
}
|
|
|
|
task slackSummary(type: RegressionsSummaryReporter) {
|
|
targetsResultFiles = ['Linux': "${rootBuildDirectory}/targetsResults/Linux.txt".toString(),
|
|
'MacOSX': "${rootBuildDirectory}/targetsResults/Mac OS X.txt".toString(),
|
|
'Windows': "${rootBuildDirectory}/targetsResults/Windows 10.txt".toString()]
|
|
}
|
|
|
|
private def uploadBenchmarkResultToArtifactory(String fileName) {
|
|
def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")
|
|
if (teamcityConfig) {
|
|
def buildProperties = new Properties()
|
|
buildProperties.load(new FileInputStream(teamcityConfig))
|
|
def password = buildProperties.getProperty("artifactory.apikey")
|
|
def buildNumber = buildProperties.getProperty("build.number")
|
|
def target = System.getProperty("os.name").replaceAll("\\s", "")
|
|
MPPTools.uploadFileToArtifactory("${artifactoryUrl}", "${artifactoryRepo}",
|
|
"${target}/${buildNumber}/${fileName}", "${buildDir.absolutePath}/${fileName}", password)
|
|
}
|
|
}
|
|
|
|
// Register external benchmarks reports (e.g. results of libraries benchmarks)
|
|
task registerExternalBenchmarks {
|
|
doLast {
|
|
def reports = externalReports.split(';')
|
|
def jsonReports = []
|
|
reports.each {
|
|
def reportFile = new File(buildDir, it)
|
|
if (!reportFile.exists())
|
|
return
|
|
|
|
def lines = reportFile.readLines()
|
|
if (lines.size < 3) {
|
|
println("Couldn't use report to register benchmarks. Wrong format.")
|
|
return
|
|
}
|
|
def name = lines[0]
|
|
def status = lines[1]
|
|
def compileTime = lines[2]
|
|
def codeSize = null
|
|
if (lines.size > 3) {
|
|
codeSize = lines[3]
|
|
}
|
|
// Create benchmarks report.
|
|
def compileBenchmark = MPPTools.toCompileBenchmark(compileTime, status, name)
|
|
def properties = [
|
|
"cpu": System.getProperty("os.arch"),
|
|
"os": System.getProperty("os.name"),
|
|
"jdkVersion": System.getProperty("java.version"),
|
|
"jdkVendor": System.getProperty("java.vendor"),
|
|
"kotlinVersion": kotlinVersion,
|
|
"type": "native",
|
|
"compilerVersion": konanVersion,
|
|
"flags": ["-g"],
|
|
"benchmarks": "[]",
|
|
"compileTime": [compileBenchmark]]
|
|
if (codeSize != null) {
|
|
properties += ["codeSize": MPPTools.toCodeSizeBenchmark(codeSize, status, name)]
|
|
}
|
|
def output = MPPTools.createJsonReport(properties)
|
|
def jsonFile = new File(buildDir, it.replace(".txt", ".json"))
|
|
jsonFile.write(output)
|
|
jsonReports.add(jsonFile)
|
|
}
|
|
def merged = MPPTools.mergeReports(jsonReports)
|
|
if (!merged.isEmpty()) {
|
|
mkdir buildDir.absolutePath
|
|
new File(buildDir, externalBenchmarksReport).write(merged)
|
|
uploadBenchmarkResultToArtifactory(externalBenchmarksReport)
|
|
}
|
|
}
|
|
}
|
|
|
|
task registerBuild(type: BuildRegister) {
|
|
def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}",
|
|
"${rootBuildDirectory}/${analyzerToolDirectory}")
|
|
if (analyzerBinary != null) {
|
|
onlyBranch = project.findProperty('kotlin.register.branch')
|
|
// Get bundle size.
|
|
bundleSize = null
|
|
if (project.findProperty('kotlin.bundleBuild') != null) {
|
|
def dist = findProperty('org.jetbrains.kotlin.native.home') ?: 'dist'
|
|
dist = (new File(dist)).isAbsolute() ? dist : "${project.getProjectDir()}/$dist"
|
|
bundleSize = (new File(dist)).directorySize()
|
|
}
|
|
currentBenchmarksReportFile = "${buildDir.absolutePath}/${nativeJson}"
|
|
analyzer = analyzerBinary
|
|
}
|
|
}
|
|
|
|
def mergeReports(String fileName) {
|
|
def reports = []
|
|
subprojects.each {
|
|
def reportFile = new File("${it.buildDir.absolutePath}/${fileName}")
|
|
if (reportFile.exists()) {
|
|
reports.add(reportFile)
|
|
}
|
|
}
|
|
def output = MPPTools.mergeReports(reports)
|
|
mkdir buildDir.absolutePath
|
|
new File("${buildDir.absolutePath}/${fileName}").write(output)
|
|
}
|
|
|
|
task mergeNativeReports {
|
|
doLast {
|
|
mergeReports(nativeJson)
|
|
uploadBenchmarkResultToArtifactory(nativeJson)
|
|
}
|
|
}
|
|
|
|
task mergeJvmReports {
|
|
doLast {
|
|
mergeReports(jvmJson)
|
|
uploadBenchmarkResultToArtifactory(jvmJson)
|
|
}
|
|
}
|
|
|
|
subprojects.each {
|
|
it.getTasksByName('jvmJsonReport', true)[0].finalizedBy mergeJvmReports
|
|
it.getTasksByName('konanJsonReport', true)[0].finalizedBy mergeNativeReports
|
|
}
|
|
|
|
task teamCityStat(type:Exec) {
|
|
def extension = MPPTools.getNativeProgramExtension()
|
|
def analyzer = MPPTools.findFile("${analyzerTool}${extension}", "${rootBuildDirectory}/${analyzerToolDirectory}")
|
|
if (analyzer != null) {
|
|
commandLine "${analyzer}", "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}"
|
|
} else {
|
|
println("No analyzer $analyzerTool found in subdirectories of ${rootBuildDirectory}/${analyzerToolDirectory}")
|
|
}
|
|
}
|
|
|
|
task cinterop {
|
|
dependsOn 'clean'
|
|
dependsOn 'cinterop:konanRun'
|
|
}
|
|
|
|
task framework {
|
|
dependsOn 'clean'
|
|
dependsOn 'framework:konanRun'
|
|
}
|
|
|
|
task helloworld {
|
|
dependsOn 'clean'
|
|
dependsOn 'helloworld:konanRun'
|
|
}
|
|
|
|
task objcinterop {
|
|
dependsOn 'clean'
|
|
dependsOn 'objcinterop:konanRun'
|
|
}
|
|
|
|
task ring {
|
|
dependsOn 'clean'
|
|
dependsOn 'ring:konanRun'
|
|
}
|
|
|
|
task numerical {
|
|
dependsOn 'clean'
|
|
dependsOn 'numerical:konanRun'
|
|
}
|
|
|
|
task swiftinterop {
|
|
dependsOn 'clean'
|
|
dependsOn 'swiftinterop:konanRun'
|
|
}
|
|
|
|
task videoplayer {
|
|
dependsOn 'clean'
|
|
dependsOn 'videoplayer:konanRun'
|
|
}
|
|
|
|
task KotlinVsSwift {
|
|
dependsOn 'clean'
|
|
dependsOn 'KotlinVsSwift:konanRun'
|
|
} |