[build] joint (step 1)
(cherry picked from commit 7d0775f7e69ab900200bcf1fa78b94d68e6bd4f6)
This commit is contained in:
+7
-7
@@ -164,7 +164,7 @@ class NamedNativeInteropConfig implements Named {
|
||||
this.project = project
|
||||
this.flavor = flavor
|
||||
|
||||
def platformManager = project.rootProject.ext.platformManager
|
||||
def platformManager = project.project(":kotlin-native").ext.platformManager
|
||||
def targetManager = platformManager.targetManager(target)
|
||||
this.target = targetManager.targetName
|
||||
|
||||
@@ -189,7 +189,7 @@ class NamedNativeInteropConfig implements Named {
|
||||
interopStubs.kotlin.srcDirs generatedSrcDir
|
||||
|
||||
project.dependencies {
|
||||
add interopStubs.getCompileConfigurationName(), project(path: ':Interop:Runtime')
|
||||
add interopStubs.getCompileConfigurationName(), project(path: ':kotlin-native:Interop:Runtime')
|
||||
}
|
||||
|
||||
this.configuration.extendsFrom project.configurations[interopStubs.runtimeConfigurationName]
|
||||
@@ -202,8 +202,8 @@ class NamedNativeInteropConfig implements Named {
|
||||
jvmArgs '-ea'
|
||||
|
||||
systemProperties "java.library.path" : project.files(
|
||||
new File(project.findProject(":Interop:Indexer").buildDir, "nativelibs"),
|
||||
new File(project.findProject(":Interop:Runtime").buildDir, "nativelibs")
|
||||
new File(project.findProject(":kotlin-native:Interop:Indexer").buildDir, "nativelibs"),
|
||||
new File(project.findProject(":kotlin-native:Interop:Runtime").buildDir, "nativelibs")
|
||||
).asPath
|
||||
// Set the konan.home property because we run the cinterop tool not from a distribution jar
|
||||
// so it will not be able to determine this path by itself.
|
||||
@@ -298,7 +298,7 @@ class NativeInteropPlugin implements Plugin<Project> {
|
||||
void apply(Project prj) {
|
||||
prj.extensions.add("kotlinNativeInterop", new NativeInteropExtension(prj))
|
||||
|
||||
def runtimeNativeLibsDir = new File(prj.findProject(':Interop:Runtime').buildDir, 'nativelibs')
|
||||
def runtimeNativeLibsDir = new File(prj.findProject(':kotlin-native:Interop:Runtime').buildDir, 'nativelibs')
|
||||
|
||||
def nativeLibsDir = new File(prj.buildDir, "nativelibs")
|
||||
|
||||
@@ -307,8 +307,8 @@ class NativeInteropPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
prj.dependencies {
|
||||
interopStubGenerator project(path: ":Interop:StubGenerator")
|
||||
interopStubGenerator project(path: ":endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
|
||||
interopStubGenerator project(path: ":kotlin-native:Interop:StubGenerator")
|
||||
interopStubGenerator project(path: ":kotlin-native:endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ fun configureCacheTesting(project: Project): CacheTesting? {
|
||||
val compilerArgs = listOf("-Xcached-library=$stdlib,$cacheFile")
|
||||
|
||||
val buildCacheTask = project.tasks.create("buildStdlibCache", Exec::class.java) {
|
||||
it.doFirst {
|
||||
doFirst {
|
||||
cacheDir.mkdirs()
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ fun configureCacheTesting(project: Project): CacheTesting? {
|
||||
"distCompiler"
|
||||
).map { task -> project.rootProject.tasks.getByName(task) }
|
||||
|
||||
it.dependsOn(tasks)
|
||||
dependsOn(tasks)
|
||||
}
|
||||
|
||||
it.commandLine(
|
||||
commandLine(
|
||||
"$dist/bin/konanc",
|
||||
"-p", cacheKind.visibleName,
|
||||
"-o", "$cacheDir/stdlib-cache",
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ open class CompareDistributionSignatures : DefaultTask() {
|
||||
val oldKlibSignatures = getKlibSignatures(old).toSet()
|
||||
return CompareDiff(
|
||||
newKlibSignatures - oldKlibSignatures,
|
||||
oldKlibSignatures - newKlibSignatures,
|
||||
oldKlibSignatures - newKlibSignatures
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -96,9 +96,9 @@ fun mergeCompilationDatabases(project: Project, name: String, paths: List<String
|
||||
}
|
||||
task
|
||||
}
|
||||
return project.tasks.create(name, MergeCompilationDatabases::class.java) { task ->
|
||||
task.dependsOn(subtasks)
|
||||
task.inputFiles.addAll(subtasks.map { it.outputFile })
|
||||
return project.tasks.create(name, MergeCompilationDatabases::class.java) {
|
||||
dependsOn(subtasks)
|
||||
inputFiles.addAll(subtasks.map { it.outputFile })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +120,10 @@ fun createCompilationDatabasesFromCompileToBitcodeTasks(project: Project, name:
|
||||
task.objDir)
|
||||
}
|
||||
for ((target, tasks) in compdbTasks) {
|
||||
project.tasks.create("${target}${name}", MergeCompilationDatabases::class.java) { task ->
|
||||
task.dependsOn(tasks)
|
||||
task.inputFiles.addAll(tasks.map { it.outputFile })
|
||||
task.outputFile = File(File(project.buildDir, target), "compile_commands.json")
|
||||
project.tasks.create("${target}${name}", MergeCompilationDatabases::class.java) {
|
||||
dependsOn(tasks)
|
||||
inputFiles.addAll(tasks.map { it.outputFile })
|
||||
outputFile = File(File(project.buildDir, target), "compile_commands.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +67,12 @@ open class CopyCommonSources : DefaultTask() {
|
||||
val fileTree = if (isFile) project.zipTree(this) else project.fileTree(this)
|
||||
|
||||
project.copy {
|
||||
it.from(fileTree)
|
||||
it.includeEmptyDirs = false
|
||||
it.include("generated/**/*.kt")
|
||||
it.include("kotlin/**/*.kt")
|
||||
it.include("kotlin.test/*.kt")
|
||||
it.into(destinationDir)
|
||||
from(fileTree)
|
||||
includeEmptyDirs = false
|
||||
include("generated/**/*.kt")
|
||||
include("kotlin/**/*.kt")
|
||||
include("kotlin.test/*.kt")
|
||||
into(destinationDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ open class CopySamples : Copy() {
|
||||
|
||||
private fun configureReplacements() {
|
||||
from(samplesDir) {
|
||||
it.exclude("**/*.gradle.kts")
|
||||
it.exclude("**/*.gradle")
|
||||
it.exclude("**/gradle.properties")
|
||||
exclude("**/*.gradle.kts")
|
||||
exclude("**/*.gradle")
|
||||
exclude("**/gradle.properties")
|
||||
}
|
||||
from(samplesDir) {
|
||||
it.include("**/*.gradle")
|
||||
it.include("**/*.gradle.kts")
|
||||
it.filter { line ->
|
||||
include("**/*.gradle")
|
||||
include("**/*.gradle.kts")
|
||||
filter { line ->
|
||||
replacements.forEach { (repo, replacement) ->
|
||||
if (line.contains(repo)) {
|
||||
return@filter line.replace(repo, replacement)
|
||||
@@ -33,14 +33,14 @@ open class CopySamples : Copy() {
|
||||
}
|
||||
}
|
||||
from(samplesDir) {
|
||||
it.include("**/gradle.properties")
|
||||
include("**/gradle.properties")
|
||||
|
||||
val kotlinVersion = project.property("kotlinVersion") as? String
|
||||
?: throw IllegalArgumentException("Property kotlinVersion should be specified in the root project")
|
||||
val kotlinCompilerRepo = project.property("kotlinCompilerRepo") as? String
|
||||
?: throw IllegalArgumentException("Property kotlinCompilerRepo should be specified in the root project")
|
||||
|
||||
it.filter { line ->
|
||||
filter { line ->
|
||||
when {
|
||||
line.startsWith("kotlin_version") -> "kotlin_version=$kotlinVersion"
|
||||
line.startsWith("#kotlinCompilerRepo") || line.startsWith("kotlinCompilerRepo") ->
|
||||
@@ -63,6 +63,6 @@ open class CopySamples : Copy() {
|
||||
"https://dl.bintray.com/kotlin/ktor" to "https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/ktor",
|
||||
"https://plugins.gradle.org/m2" to "https://cache-redirector.jetbrains.com/plugins.gradle.org/m2",
|
||||
"mavenCentral()" to "maven { setUrl(\"https://cache-redirector.jetbrains.com/maven-central\") }",
|
||||
"jcenter()" to "maven { setUrl(\"https://cache-redirector.jetbrains.com/jcenter\") }",
|
||||
"jcenter()" to "maven { setUrl(\"https://cache-redirector.jetbrains.com/jcenter\") }"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.konan.file.*
|
||||
|
||||
class ExecClang(private val project: Project) {
|
||||
|
||||
private val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager
|
||||
private val platformManager = project.project(":kotlin-native").findProperty("platformManager") as PlatformManager
|
||||
|
||||
private fun konanArgs(target: KonanTarget): List<String> {
|
||||
return platformManager.platform(target).clang.clangArgsForKonanSources.asList()
|
||||
@@ -108,11 +108,9 @@ class ExecClang(private val project: Project) {
|
||||
}
|
||||
|
||||
fun execToolchainClang(target: KonanTarget, action: Action<in ExecSpec>): ExecResult {
|
||||
val extendedAction = Action<ExecSpec> { execSpec ->
|
||||
action.execute(execSpec)
|
||||
execSpec.apply {
|
||||
executable = resolveToolchainExecutable(target, executable)
|
||||
}
|
||||
val extendedAction = Action<ExecSpec> {
|
||||
action.execute(this)
|
||||
executable = resolveToolchainExecutable(target, executable)
|
||||
}
|
||||
return project.exec(extendedAction)
|
||||
}
|
||||
@@ -128,16 +126,14 @@ class ExecClang(private val project: Project) {
|
||||
}
|
||||
|
||||
private fun execClang(defaultArgs: List<String>, action: Action<in ExecSpec>): ExecResult {
|
||||
val extendedAction = Action<ExecSpec> { execSpec ->
|
||||
action.execute(execSpec)
|
||||
execSpec.apply {
|
||||
executable = resolveExecutable(executable)
|
||||
val extendedAction = Action<ExecSpec> {
|
||||
action.execute(this)
|
||||
executable = resolveExecutable(executable)
|
||||
|
||||
val hostPlatform = project.findProperty("hostPlatform") as Platform
|
||||
environment["PATH"] = project.files(hostPlatform.clang.clangPaths).asPath +
|
||||
java.io.File.pathSeparator + environment["PATH"]
|
||||
args = args + defaultArgs
|
||||
}
|
||||
val hostPlatform = project.findProperty("hostPlatform") as Platform
|
||||
environment["PATH"] = project.files(hostPlatform.clang.clangPaths).asPath +
|
||||
java.io.File.pathSeparator + environment["PATH"]
|
||||
args = args + defaultArgs
|
||||
}
|
||||
return project.exec(extendedAction)
|
||||
}
|
||||
|
||||
@@ -58,15 +58,13 @@ fun create(project: Project): ExecutorService {
|
||||
sshExecutor(project)
|
||||
} else when (testTarget) {
|
||||
KonanTarget.WASM32 -> object : ExecutorService {
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec { execSpec ->
|
||||
action.execute(execSpec)
|
||||
with(execSpec) {
|
||||
val exe = executable
|
||||
val d8 = "$absoluteTargetToolchain/bin/d8"
|
||||
val launcherJs = "$executable.js"
|
||||
executable = d8
|
||||
args = listOf("--expose-wasm", launcherJs, "--", exe) + args
|
||||
}
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
val exe = executable
|
||||
val d8 = "$absoluteTargetToolchain/bin/d8"
|
||||
val launcherJs = "$executable.js"
|
||||
this.executable = d8
|
||||
this.args = listOf("--expose-wasm", launcherJs, "--", exe) + args
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +100,11 @@ fun runProcess(executor: (Action<in ExecSpec>) -> ExecResult?,
|
||||
val errStream = ByteArrayOutputStream()
|
||||
|
||||
val execResult = executor(Action {
|
||||
it.executable = executable
|
||||
it.args = args.toList()
|
||||
it.standardOutput = outStream
|
||||
it.errorOutput = errStream
|
||||
it.isIgnoreExitValue = true
|
||||
this.executable = executable
|
||||
this.args = args.toList()
|
||||
this.standardOutput = outStream
|
||||
this.errorOutput = errStream
|
||||
this.isIgnoreExitValue = true
|
||||
})
|
||||
|
||||
checkNotNull(execResult)
|
||||
@@ -135,12 +133,12 @@ fun runProcessWithInput(executor: (Action<in ExecSpec>) -> ExecResult?,
|
||||
val inStream = ByteArrayInputStream(input.toByteArray())
|
||||
|
||||
val execResult = executor(Action {
|
||||
it.executable = executable
|
||||
it.args = args.toList()
|
||||
it.standardOutput = outStream
|
||||
it.errorOutput = errStream
|
||||
it.isIgnoreExitValue = true
|
||||
it.standardInput = inStream
|
||||
this.executable = executable
|
||||
this.args = args.toList()
|
||||
this.standardOutput = outStream
|
||||
this.errorOutput = errStream
|
||||
this.isIgnoreExitValue = true
|
||||
this.standardInput = inStream
|
||||
})
|
||||
|
||||
checkNotNull(execResult)
|
||||
@@ -166,10 +164,10 @@ val Project.executor: ExecutorService
|
||||
*/
|
||||
fun ExecutorService.add(actionParameter: Action<in ExecSpec>) = object : ExecutorService {
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? =
|
||||
this@add.execute {
|
||||
action.execute(it)
|
||||
actionParameter.execute(it)
|
||||
}
|
||||
this@add.execute(Action {
|
||||
action.execute(this)
|
||||
actionParameter.execute(this)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,25 +204,24 @@ private fun emulatorExecutor(project: Project, target: KonanTarget) = object : E
|
||||
?: error("$target does not support emulation!")
|
||||
val absoluteTargetSysRoot = configurables.absoluteTargetSysRoot
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec { execSpec ->
|
||||
action.execute(execSpec)
|
||||
with(execSpec) {
|
||||
val exe = executable
|
||||
// TODO: Move these to konan.properties when when it will be possible
|
||||
// to represent absolute path there.
|
||||
val qemuSpecificArguments = listOf("-L", absoluteTargetSysRoot)
|
||||
val targetSpecificArguments = when (target) {
|
||||
KonanTarget.LINUX_MIPS32,
|
||||
KonanTarget.LINUX_MIPSEL32 -> {
|
||||
// This is to workaround an endianess issue.
|
||||
// See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=731082 for details.
|
||||
listOf("$absoluteTargetSysRoot/lib/ld.so.1", "--inhibit-cache")
|
||||
}
|
||||
else -> emptyList()
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
|
||||
val exe = executable
|
||||
// TODO: Move these to konan.properties when when it will be possible
|
||||
// to represent absolute path there.
|
||||
val qemuSpecificArguments = listOf("-L", absoluteTargetSysRoot)
|
||||
val targetSpecificArguments = when (target) {
|
||||
KonanTarget.LINUX_MIPS32,
|
||||
KonanTarget.LINUX_MIPSEL32 -> {
|
||||
// This is to workaround an endianess issue.
|
||||
// See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=731082 for details.
|
||||
listOf("$absoluteTargetSysRoot/lib/ld.so.1", "--inhibit-cache")
|
||||
}
|
||||
executable = configurables.absoluteEmulatorExecutable
|
||||
args = qemuSpecificArguments + targetSpecificArguments + exe + args
|
||||
else -> emptyList()
|
||||
}
|
||||
executable = configurables.absoluteEmulatorExecutable
|
||||
args = qemuSpecificArguments + targetSpecificArguments + exe + args
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +248,8 @@ private fun simulator(project: Project): ExecutorService = object : ExecutorServ
|
||||
}
|
||||
val out = ByteArrayOutputStream()
|
||||
val result = project.exec {
|
||||
it.commandLine("/usr/bin/xcrun", "--find", "simctl", "--sdk", sdk)
|
||||
it.standardOutput = out
|
||||
commandLine("/usr/bin/xcrun", "--find", "simctl", "--sdk", sdk)
|
||||
standardOutput = out
|
||||
}
|
||||
result.assertNormalExitValue()
|
||||
out.toString("UTF-8").trim()
|
||||
@@ -272,10 +269,10 @@ private fun simulator(project: Project): ExecutorService = object : ExecutorServ
|
||||
else -> error("${target.architecture} can't be used in simulator.")
|
||||
}.toTypedArray()
|
||||
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec { execSpec ->
|
||||
action.execute(execSpec)
|
||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec {
|
||||
action.execute(this)
|
||||
// Starting Xcode 11 `simctl spawn` requires explicit `--standalone` flag.
|
||||
with(execSpec) { commandLine = listOf(simctl, "spawn", "--standalone", *archSpecification, device, executable) + args }
|
||||
commandLine = listOf(simctl, "spawn", "--standalone", *archSpecification, device, executable) + args
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,14 +300,12 @@ private fun sshExecutor(project: Project): ExecutorService = object : ExecutorSe
|
||||
var execFile: String? = null
|
||||
|
||||
createRemoteDir()
|
||||
val execResult = project.exec { execSpec ->
|
||||
action.execute(execSpec)
|
||||
with(execSpec) {
|
||||
upload(executable)
|
||||
executable = "$remoteDir/${File(executable).name}"
|
||||
execFile = executable
|
||||
commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + commandLine
|
||||
}
|
||||
val execResult = project.exec {
|
||||
action.execute(this)
|
||||
upload(executable)
|
||||
this.executable = "$remoteDir/${File(executable).name}"
|
||||
execFile = executable
|
||||
commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + commandLine
|
||||
}
|
||||
cleanup(execFile!!)
|
||||
return execResult
|
||||
@@ -318,19 +313,19 @@ private fun sshExecutor(project: Project): ExecutorService = object : ExecutorSe
|
||||
|
||||
private fun createRemoteDir() {
|
||||
project.exec {
|
||||
it.commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "mkdir" + "-p" + remoteDir
|
||||
commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "mkdir" + "-p" + remoteDir
|
||||
}
|
||||
}
|
||||
|
||||
private fun upload(fileName: String) {
|
||||
project.exec {
|
||||
it.commandLine = arrayListOf("$sshHome/scp") + sshArgs + fileName + "$remote:$remoteDir"
|
||||
commandLine = arrayListOf("$sshHome/scp") + sshArgs + fileName + "$remote:$remoteDir"
|
||||
}
|
||||
}
|
||||
|
||||
private fun cleanup(fileName: String) {
|
||||
project.exec {
|
||||
it.commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "rm" + fileName
|
||||
commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "rm" + fileName
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,12 +359,12 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
|
||||
var savedOut: OutputStream? = null
|
||||
val out = ByteArrayOutputStream()
|
||||
result = project.exec { execSpec: ExecSpec ->
|
||||
action.execute(execSpec)
|
||||
execSpec.executable = "lldb"
|
||||
execSpec.args = commands + "-b" + "-o" + "command script import ${pythonScript()}" +
|
||||
result = project.exec {
|
||||
action.execute(this)
|
||||
executable = "lldb"
|
||||
args = commands + "-b" + "-o" + "command script import ${pythonScript()}" +
|
||||
"-o" + ("process launch" +
|
||||
(execSpec.args.takeUnless { it.isEmpty() }
|
||||
(args.takeUnless { it.isEmpty() }
|
||||
?.let { " -- ${it.joinToString(" ")}" }
|
||||
?: "")) +
|
||||
"-o" + "get_exit_code" +
|
||||
@@ -378,8 +373,8 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
// A test task that uses project.exec { } sets the stdOut to parse the result,
|
||||
// but the test executable is being run under debugger that has its own output mixed with the
|
||||
// output from the test. Save the stdOut from the test to write the parsed output to it.
|
||||
savedOut = execSpec.standardOutput
|
||||
execSpec.standardOutput = out
|
||||
savedOut = this.standardOutput
|
||||
standardOutput = out
|
||||
}
|
||||
out.toString()
|
||||
.also { if (project.verboseTest) println(it) }
|
||||
@@ -430,7 +425,7 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
absolutePath
|
||||
}
|
||||
|
||||
private fun kill() = project.exec { it.commandLine(idb, "kill") }
|
||||
private fun kill() = project.exec { commandLine(idb, "kill") }
|
||||
|
||||
private inline fun tryUntilTrue(times: Int = 3, f: () -> Boolean) {
|
||||
for (i in 1..times) {
|
||||
@@ -445,8 +440,8 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
// So relaunch `list-targets` again.
|
||||
tryUntilTrue {
|
||||
project.exec {
|
||||
it.commandLine(idb, "list-targets", "--json")
|
||||
it.standardOutput = out
|
||||
commandLine(idb, "list-targets", "--json")
|
||||
standardOutput = out
|
||||
}.assertNormalExitValue()
|
||||
out.toString().trim().isNotEmpty()
|
||||
}
|
||||
@@ -469,11 +464,11 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
lateinit var result: ExecResult
|
||||
tryUntilTrue {
|
||||
result = project.exec {
|
||||
it.workingDir = xcProject.toFile()
|
||||
it.commandLine = listOf(idb, "install", "--udid", udid, bundlePath)
|
||||
it.standardOutput = out
|
||||
it.errorOutput = out
|
||||
it.isIgnoreExitValue = true
|
||||
workingDir = xcProject.toFile()
|
||||
commandLine = listOf(idb, "install", "--udid", udid, bundlePath)
|
||||
standardOutput = out
|
||||
errorOutput = out
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
println(out.toString())
|
||||
result.exitValue == 0
|
||||
@@ -485,11 +480,11 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
val out = ByteArrayOutputStream()
|
||||
|
||||
project.exec {
|
||||
it.workingDir = xcProject.toFile()
|
||||
it.commandLine = listOf(idb, "uninstall", "--udid", udid, bundleID)
|
||||
it.standardOutput = out
|
||||
it.errorOutput = out
|
||||
it.isIgnoreExitValue = true
|
||||
workingDir = xcProject.toFile()
|
||||
commandLine = listOf(idb, "uninstall", "--udid", udid, bundleID)
|
||||
standardOutput = out
|
||||
errorOutput = out
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
println(out.toString())
|
||||
}
|
||||
@@ -498,11 +493,11 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
val out = ByteArrayOutputStream()
|
||||
|
||||
val result = project.exec {
|
||||
it.workingDir = xcProject.toFile()
|
||||
it.commandLine = listOf(idb, "debugserver", "start", "--udid", udid, bundleID)
|
||||
it.standardOutput = out
|
||||
it.errorOutput = out
|
||||
it.isIgnoreExitValue = true
|
||||
workingDir = xcProject.toFile()
|
||||
commandLine = listOf(idb, "debugserver", "start", "--udid", udid, bundleID)
|
||||
standardOutput = out
|
||||
errorOutput = out
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
check(result.exitValue == 0) { "Failed to start debug server: $out" }
|
||||
return out.toString()
|
||||
@@ -570,9 +565,9 @@ fun KonanTestExecutable.configureXcodeBuild() {
|
||||
val xcode = listOf("/usr/bin/xcrun", "-sdk", sdk, "xcodebuild")
|
||||
val out = ByteArrayOutputStream()
|
||||
val result = project.exec {
|
||||
it.workingDir = xcProject.toFile()
|
||||
it.commandLine = xcode + elements.toList()
|
||||
it.standardOutput = out
|
||||
workingDir = xcProject.toFile()
|
||||
commandLine = xcode + elements.toList()
|
||||
standardOutput = out
|
||||
}
|
||||
println(out.toString("UTF-8"))
|
||||
result.assertNormalExitValue()
|
||||
|
||||
@@ -90,7 +90,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
|
||||
fun Language.filesFrom(dir: String): FileTree = project.fileTree(dir) {
|
||||
// include only files with the language extension
|
||||
it.include("*${this.extension}")
|
||||
include("*${this@filesFrom.extension}")
|
||||
}
|
||||
|
||||
fun List<String>.toFiles(language: Language): List<File> =
|
||||
@@ -222,8 +222,8 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
private fun runTest(executorService: ExecutorService, testExecutable: Path, args: List<String> = emptyList()) {
|
||||
val (stdOut, stdErr, exitCode) = runProcess(
|
||||
executor = { executorService.add(Action {
|
||||
it.environment = buildEnvironment()
|
||||
it.workingDir = Paths.get(testOutput).toFile()
|
||||
environment = buildEnvironment()
|
||||
workingDir = Paths.get(testOutput).toFile()
|
||||
}).execute(it) },
|
||||
executable = testExecutable.toString(),
|
||||
args = args)
|
||||
|
||||
+10
-10
@@ -464,18 +464,18 @@ open class KonanDynamicTest : KonanStandaloneTest() {
|
||||
val isOpt = flagsContain("-opt")
|
||||
val isDebug = flagsContain("-g")
|
||||
|
||||
val execResult = plugin.execKonanClang(project.testTarget) {
|
||||
it.workingDir = File(outputDirectory)
|
||||
it.executable = clangTool
|
||||
it.args = listOf(processCSource(),
|
||||
val execResult = plugin.execKonanClang(project.testTarget, Action<ExecSpec> {
|
||||
workingDir = File(outputDirectory)
|
||||
executable = clangTool
|
||||
args = listOf(processCSource(),
|
||||
"-c",
|
||||
"-o", "$executable.o",
|
||||
"-o", "${this@KonanDynamicTest.executable}.o",
|
||||
"-I", artifactsDir
|
||||
) + clangFlags
|
||||
it.standardOutput = log
|
||||
it.errorOutput = log
|
||||
it.isIgnoreExitValue = true
|
||||
}
|
||||
standardOutput = log
|
||||
errorOutput = log
|
||||
isIgnoreExitValue = true
|
||||
})
|
||||
log.toString("UTF-8").also {
|
||||
project.file("$executable.compilation.log").writeText(it)
|
||||
println(it)
|
||||
@@ -484,7 +484,7 @@ open class KonanDynamicTest : KonanStandaloneTest() {
|
||||
|
||||
val linker = project.platformManager.platform(project.testTarget).linker
|
||||
val commands = linker.finalLinkCommands(
|
||||
objectFiles = listOf("$executable.o"),
|
||||
objectFiles = listOf("${this@KonanDynamicTest.executable}.o"),
|
||||
executable = executable,
|
||||
libraries = listOf("-l$name"),
|
||||
linkerArgs = listOf("-L", artifactsDir, "-rpath", artifactsDir),
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ open class MetadataComparisonTest : DefaultTask() {
|
||||
val sourcecodeLibrary = cinterop(project.file(defFile), Mode.SOURCECODE)
|
||||
compareKlibMetadata(CInteropComparisonConfig(), sourcecodeLibrary.absolutePath, metadataLibrary.absolutePath).let { result ->
|
||||
if (result is MetadataCompareResult.Fail) {
|
||||
val message = StringBuilder().also {
|
||||
expandFail(result, it::appendln)
|
||||
}.toString()
|
||||
val message = buildString {
|
||||
expandFail(result, {x:String -> appendln(x)})
|
||||
}
|
||||
throw TestFailedException(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ open class RunJvmTask: JavaExec() {
|
||||
).removePrefix("[").removeSuffix("]")
|
||||
).jsonObject
|
||||
val modifiedBenchmarkReport = JsonObject(HashMap(benchmarkReport.content).apply {
|
||||
put("repeat", JsonLiteral(i))
|
||||
put("repeat", JsonLiteral(i) as JsonElement)
|
||||
put("warmup", JsonLiteral(warmupCount))
|
||||
})
|
||||
result.add(modifiedBenchmarkReport.toString())
|
||||
|
||||
+12
-12
@@ -59,22 +59,22 @@ open class RunKotlinNativeTask @Inject constructor(private val linkTask: Task,
|
||||
val useCset = project.findProperty("useCset")?.toString()?.toBoolean() ?: false
|
||||
project.exec {
|
||||
if (useCset) {
|
||||
it.executable = "cset"
|
||||
it.args("shield", "--exec", "--", executable)
|
||||
executable = "cset"
|
||||
args("shield", "--exec", "--", executable)
|
||||
} else {
|
||||
it.executable = executable
|
||||
this.executable = executable
|
||||
}
|
||||
|
||||
it.args(argumentsList)
|
||||
it.args("-f", benchmark)
|
||||
args(argumentsList)
|
||||
args("-f", benchmark)
|
||||
// Logging with application should be done only in case it controls running benchmarks itself.
|
||||
// Although it's a responsibility of gradle task.
|
||||
if (verbose && repeatingType == BenchmarkRepeatingType.INTERNAL) {
|
||||
it.args("-v")
|
||||
args("-v")
|
||||
}
|
||||
it.args("-w", warmupCount.toString())
|
||||
it.args("-r", repeatCount.toString())
|
||||
it.standardOutput = output
|
||||
args("-w", warmupCount.toString())
|
||||
args("-r", repeatCount.toString())
|
||||
standardOutput = output
|
||||
}
|
||||
return output.toString().substringAfter("[").removeSuffix("]")
|
||||
}
|
||||
@@ -104,9 +104,9 @@ open class RunKotlinNativeTask @Inject constructor(private val linkTask: Task,
|
||||
fun run() {
|
||||
val output = ByteArrayOutputStream()
|
||||
project.exec {
|
||||
it.executable = executable
|
||||
it.args("list")
|
||||
it.standardOutput = output
|
||||
executable = executable
|
||||
args("list")
|
||||
standardOutput = output
|
||||
}
|
||||
val benchmarks = output.toString().lines()
|
||||
val filterArgs = filter.splitCommaSeparatedOption("-f")
|
||||
|
||||
@@ -333,16 +333,16 @@ fun Project.buildStaticLibrary(cSources: Collection<File>, output: File, objDir:
|
||||
|
||||
objDir.mkdirs()
|
||||
exec {
|
||||
it.commandLine(platform.clang.clangC(
|
||||
commandLine(platform.clang.clangC(
|
||||
"-c",
|
||||
*cSources.map { it.absolutePath }.toTypedArray()
|
||||
))
|
||||
it.workingDir(objDir)
|
||||
workingDir(objDir)
|
||||
}
|
||||
|
||||
output.parentFile.mkdirs()
|
||||
exec {
|
||||
it.commandLine(
|
||||
commandLine(
|
||||
"${platform.configurables.absoluteLlvmHome}/bin/llvm-ar",
|
||||
"-rc",
|
||||
output,
|
||||
|
||||
+5
-5
@@ -125,7 +125,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
|
||||
protected open fun Project.configureSourceSets(kotlinVersion: String) {
|
||||
with(kotlin.sourceSets) {
|
||||
commonMain.dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinStdlibVersion")
|
||||
implementation(project(":kotlin-stdlib-common"))
|
||||
}
|
||||
|
||||
project.configurations.getByName(nativeMain.implementationConfigurationName).apply {
|
||||
@@ -134,7 +134,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
|
||||
}
|
||||
|
||||
repositories.maven {
|
||||
it.setUrl(kotlinStdlibRepo)
|
||||
setUrl(kotlinStdlibRepo)
|
||||
}
|
||||
|
||||
additionalConfigurations(this@configureSourceSets)
|
||||
@@ -215,10 +215,10 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
|
||||
|
||||
protected open fun Project.configureKonanJsonTask(nativeTarget: KotlinNativeTarget): Task {
|
||||
return tasks.create("konanJsonReport") {
|
||||
it.group = BENCHMARKING_GROUP
|
||||
it.description = "Builds the benchmarking report for Kotlin/Native."
|
||||
group = BENCHMARKING_GROUP
|
||||
description = "Builds the benchmarking report for Kotlin/Native."
|
||||
|
||||
it.doLast {
|
||||
doLast {
|
||||
val applicationName = benchmark.applicationName
|
||||
val benchContents = buildDir.resolve(nativeBenchResults).readText()
|
||||
val nativeCompileTime = if (benchmark.compileTasks.isEmpty()) getNativeCompileTime(project, applicationName)
|
||||
|
||||
+13
-13
@@ -41,11 +41,11 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
|
||||
|
||||
private fun Project.configureUtilityTasks() {
|
||||
tasks.create("configureBuild") {
|
||||
it.doLast { mkdir(buildDir) }
|
||||
doLast { mkdir(buildDir) }
|
||||
}
|
||||
|
||||
tasks.create("clean", Delete::class.java) {
|
||||
it.delete(buildDir)
|
||||
delete(buildDir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
|
||||
benchmarkExtension: CompileBenchmarkExtension
|
||||
): Unit = with(benchmarkExtension) {
|
||||
// Aggregate task.
|
||||
val konanRun = tasks.create("konanRun") { task ->
|
||||
task.dependsOn("configureBuild")
|
||||
val konanRun = tasks.create("konanRun") {
|
||||
dependsOn("configureBuild")
|
||||
|
||||
task.group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
task.description = "Runs the compile only benchmark for Kotlin/Native."
|
||||
group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
description = "Runs the compile only benchmark for Kotlin/Native."
|
||||
}
|
||||
|
||||
// Compile tasks.
|
||||
@@ -112,16 +112,16 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
|
||||
|
||||
private fun Project.configureJvmRun() {
|
||||
val jvmRun = tasks.create("jvmRun") {
|
||||
it.group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
it.description = "Runs the compile only benchmark for Kotlin/JVM."
|
||||
it.doLast { println("JVM run isn't supported") }
|
||||
group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
description = "Runs the compile only benchmark for Kotlin/JVM."
|
||||
doLast { println("JVM run isn't supported") }
|
||||
}
|
||||
|
||||
tasks.create("jvmJsonReport") {
|
||||
it.group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
it.description = "Builds the benchmarking report for Kotlin/Native."
|
||||
it.doLast { println("JVM run isn't supported") }
|
||||
jvmRun.finalizedBy(it)
|
||||
group = BenchmarkingPlugin.BENCHMARKING_GROUP
|
||||
description = "Builds the benchmarking report for Kotlin/Native."
|
||||
doLast { println("JVM run isn't supported") }
|
||||
jvmRun.finalizedBy(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -37,10 +37,10 @@ open class KotlinNativeBenchmarkExtension @Inject constructor(project: Project)
|
||||
open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
|
||||
override fun Project.configureJvmJsonTask(jvmRun: Task): Task {
|
||||
return tasks.create("jvmJsonReport") {
|
||||
it.group = BENCHMARKING_GROUP
|
||||
it.description = "Builds the benchmarking report for Kotlin/JVM."
|
||||
group = BENCHMARKING_GROUP
|
||||
description = "Builds the benchmarking report for Kotlin/JVM."
|
||||
|
||||
it.doLast {
|
||||
doLast {
|
||||
val applicationName = benchmark.applicationName
|
||||
val jarPath = (tasks.getByName("jvmJar") as Jar).archiveFile.get().asFile
|
||||
val jvmCompileTime = getJvmCompileTime(project, applicationName)
|
||||
@@ -58,28 +58,28 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
|
||||
buildDir.resolve(jvmJson).writeText(output)
|
||||
}
|
||||
|
||||
jvmRun.finalizedBy(it)
|
||||
jvmRun.finalizedBy(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun Project.configureJvmTask(): Task {
|
||||
return tasks.create("jvmRun", RunJvmTask::class.java) { task ->
|
||||
task.dependsOn("jvmJar")
|
||||
return tasks.create("jvmRun", RunJvmTask::class.java) {
|
||||
dependsOn("jvmJar")
|
||||
val mainCompilation = kotlin.jvm().compilations.getByName("main")
|
||||
val runtimeDependencies = configurations.getByName(mainCompilation.runtimeDependencyConfigurationName)
|
||||
task.classpath(files(mainCompilation.output.allOutputs, runtimeDependencies))
|
||||
task.main = "MainKt"
|
||||
classpath(files(mainCompilation.output.allOutputs, runtimeDependencies))
|
||||
main = "MainKt"
|
||||
|
||||
task.group = BENCHMARKING_GROUP
|
||||
task.description = "Runs the benchmark for Kotlin/JVM."
|
||||
group = BENCHMARKING_GROUP
|
||||
description = "Runs the benchmark for Kotlin/JVM."
|
||||
|
||||
// Specify settings configured by a user in the benchmark extension.
|
||||
afterEvaluate {
|
||||
task.args("-p", "${benchmark.applicationName}::")
|
||||
task.warmupCount = jvmWarmup
|
||||
task.repeatCount = attempts
|
||||
task.outputFileName = buildDir.resolve(jvmBenchResults).absolutePath
|
||||
task.repeatingType = benchmark.repeatingType
|
||||
args("-p", "${benchmark.applicationName}::")
|
||||
warmupCount = jvmWarmup
|
||||
repeatCount = attempts
|
||||
outputFileName = buildDir.resolve(jvmBenchResults).absolutePath
|
||||
repeatingType = benchmark.repeatingType
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
|
||||
private fun Project.configureJVMTarget() {
|
||||
kotlin.jvm {
|
||||
compilations.all {
|
||||
it.compileKotlinTask.kotlinOptions {
|
||||
compileKotlinTask.kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
suppressWarnings = true
|
||||
freeCompilerArgs = project.benchmark.compilerOpts + project.compilerArgs
|
||||
|
||||
+6
-6
@@ -28,13 +28,13 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
|
||||
override fun Project.configureJvmJsonTask(jvmRun: Task): Task {
|
||||
return tasks.create("jvmJsonReport") {
|
||||
logger.info("JVM run is unsupported")
|
||||
jvmRun.finalizedBy(it)
|
||||
jvmRun.finalizedBy(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun Project.configureJvmTask(): Task {
|
||||
return tasks.create("jvmRun") { task ->
|
||||
task.doLast {
|
||||
return tasks.create("jvmRun") {
|
||||
doLast {
|
||||
logger.info("JVM run is unsupported")
|
||||
}
|
||||
}
|
||||
@@ -79,9 +79,9 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
|
||||
val nativeTarget = kotlin.targets.getByName(NATIVE_TARGET_NAME) as KotlinNativeTarget
|
||||
// Build executable from swift code.
|
||||
framework = nativeTarget.binaries.getFramework(nativeFrameworkName, benchmark.buildType)
|
||||
tasks.create("buildSwift") { task ->
|
||||
task.dependsOn(framework.linkTaskName)
|
||||
task.doLast {
|
||||
tasks.create("buildSwift") {
|
||||
dependsOn(framework.linkTaskName)
|
||||
doLast {
|
||||
val frameworkParentDirPath = framework.outputDirectory.absolutePath
|
||||
val options = listOf("-O", "-wmo", "-Xlinker", "-rpath", "-Xlinker", frameworkParentDirPath, "-F", frameworkParentDirPath)
|
||||
compileSwift(project, nativeTarget.konanTarget, benchmark.swiftSources, options,
|
||||
|
||||
+13
-13
@@ -20,7 +20,7 @@ open class CompileToBitcode @Inject constructor(
|
||||
val srcRoot: File,
|
||||
val folderName: String,
|
||||
val target: String,
|
||||
val outputGroup: String,
|
||||
val outputGroup: String
|
||||
) : DefaultTask() {
|
||||
|
||||
enum class Language {
|
||||
@@ -35,7 +35,7 @@ open class CompileToBitcode @Inject constructor(
|
||||
"**/*Test.cpp",
|
||||
"**/*TestSupport.cpp",
|
||||
"**/*Test.mm",
|
||||
"**/*TestSupport.mm",
|
||||
"**/*TestSupport.mm"
|
||||
)
|
||||
var includeFiles: List<String> = listOf(
|
||||
"**/*.cpp",
|
||||
@@ -103,8 +103,8 @@ open class CompileToBitcode @Inject constructor(
|
||||
get() {
|
||||
return srcDirs.flatMap { srcDir ->
|
||||
project.fileTree(srcDir) {
|
||||
it.include(includeFiles)
|
||||
it.exclude(excludeFiles)
|
||||
include(includeFiles)
|
||||
exclude(excludeFiles)
|
||||
}.files
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ open class CompileToBitcode @Inject constructor(
|
||||
Language.C -> arrayOf("**/.h")
|
||||
Language.CPP -> arrayOf("**/*.h", "**/*.hpp")
|
||||
}
|
||||
it.include(*includePatterns)
|
||||
include(*includePatterns)
|
||||
}.files
|
||||
}
|
||||
}
|
||||
@@ -158,18 +158,18 @@ open class CompileToBitcode @Inject constructor(
|
||||
val plugin = project.convention.getPlugin(ExecClang::class.java)
|
||||
|
||||
plugin.execKonanClang(target) {
|
||||
it.workingDir = objDir
|
||||
it.executable = executable
|
||||
it.args = compilerFlags + inputFiles.map { it.absolutePath }
|
||||
workingDir = objDir
|
||||
executable = executable
|
||||
args = compilerFlags + inputFiles.map { it.absolutePath }
|
||||
}
|
||||
|
||||
project.exec {
|
||||
val llvmDir = project.findProperty("llvmDir")
|
||||
it.executable = "$llvmDir/bin/llvm-link"
|
||||
it.args = listOf("-o", outFile.absolutePath) + linkerArgs +
|
||||
inputFiles.map {
|
||||
bitcodeFileForInputFile(it).absolutePath
|
||||
}
|
||||
executable = "$llvmDir/bin/llvm-link"
|
||||
args = listOf("-o", outFile.absolutePath) + linkerArgs +
|
||||
project.fileTree(objDir) {
|
||||
include("**/*.bc")
|
||||
}.files.map { it.absolutePath }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -38,7 +38,7 @@ open class CompileToBitcodePlugin: Plugin<Project> {
|
||||
open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
|
||||
private val targetList = with(project) {
|
||||
provider { (rootProject.property("targetList") as? List<*>)?.filterIsInstance<String>() ?: emptyList() } // TODO: Can we make it better?
|
||||
provider { (rootProject.project(":kotlin-native").property("targetList") as? List<*>)?.filterIsInstance<String>() ?: emptyList() } // TODO: Can we make it better?
|
||||
}
|
||||
|
||||
fun create(
|
||||
@@ -48,7 +48,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
configurationBlock: CompileToBitcode.() -> Unit = {}
|
||||
) {
|
||||
targetList.get().forEach { targetName ->
|
||||
val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager
|
||||
val platformManager = project.rootProject.project(":kotlin-native").findProperty("platformManager") as PlatformManager
|
||||
val target = platformManager.targetByName(targetName)
|
||||
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
||||
sanitizers.forEach { sanitizer ->
|
||||
@@ -57,15 +57,15 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
CompileToBitcode::class.java,
|
||||
srcDir, name, targetName, outputGroup
|
||||
).configure {
|
||||
it.sanitizer = sanitizer
|
||||
it.group = BasePlugin.BUILD_GROUP
|
||||
this.sanitizer = sanitizer
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
val sanitizerDescription = when (sanitizer) {
|
||||
null -> ""
|
||||
SanitizerKind.ADDRESS -> " with ASAN"
|
||||
SanitizerKind.THREAD -> " with TSAN"
|
||||
}
|
||||
it.description = "Compiles '$name' to bitcode for $targetName$sanitizerDescription"
|
||||
it.configurationBlock()
|
||||
description = "Compiles '$name' to bitcode for $targetName$sanitizerDescription"
|
||||
configurationBlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ internal class KmComparator(private val configuration: ComparisonConfig) {
|
||||
::compareClassFlags to "Different flags for ${kmClass1.name}",
|
||||
compare(KmClass::constructors, compareLists(::compare)) to "Constructors mismatch for ${kmClass1.name}",
|
||||
compare(KmClass::properties, compareLists(::compare, KmProperty::mangle)) to "Properties mismatch for ${kmClass1.name}",
|
||||
compare(KmClass::functions, compareLists(::compare, KmFunction::mangle)) to "Functions mismatch for ${kmClass1.name}",
|
||||
compare(KmClass::functions, compareLists(::compare, KmFunction::mangle)) to "Functions mismatch for ${kmClass1.name}"
|
||||
)(kmClass1, kmClass2)
|
||||
|
||||
fun compare(typealias1: KmTypeAlias, typealias2: KmTypeAlias): MetadataCompareResult = serialComparator(
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ private class JoinedFragments(
|
||||
val classes: JoinResult<KmClass>,
|
||||
val functions: JoinResult<KmFunction>,
|
||||
val properties: JoinResult<KmProperty>,
|
||||
val typeAliases: JoinResult<KmTypeAlias>,
|
||||
val typeAliases: JoinResult<KmTypeAlias>
|
||||
)
|
||||
|
||||
private fun processMissing(comparisonConfig: ComparisonConfig, joinResult: JoinResult<*>): MetadataCompareResult {
|
||||
@@ -55,7 +55,7 @@ private fun processMissing(
|
||||
processMissing(comparisonConfig, joinedFragments.typeAliases)
|
||||
.messageIfFail("Missing type aliases"),
|
||||
processMissing(comparisonConfig, joinedFragments.properties)
|
||||
.messageIfFail("Missing properties"),
|
||||
.messageIfFail("Missing properties")
|
||||
).wrap()
|
||||
|
||||
private data class JoinResult<T>(
|
||||
|
||||
+5
-5
@@ -56,10 +56,10 @@ open class GitDownloadTask @Inject constructor(
|
||||
execConfiguration: ExecSpec.() -> Unit = {}
|
||||
): ExecResult =
|
||||
project.exec {
|
||||
it.executable = "git"
|
||||
it.args(*args)
|
||||
it.isIgnoreExitValue = ignoreExitValue
|
||||
it.execConfiguration()
|
||||
executable = "git"
|
||||
args(*args)
|
||||
isIgnoreExitValue = ignoreExitValue
|
||||
execConfiguration()
|
||||
}
|
||||
|
||||
private fun tryCloneBranch(): Boolean {
|
||||
@@ -93,7 +93,7 @@ open class GitDownloadTask @Inject constructor(
|
||||
}
|
||||
|
||||
project.delete {
|
||||
it.delete(outputDirectory)
|
||||
delete(outputDirectory)
|
||||
}
|
||||
|
||||
if (!tryCloneBranch()) {
|
||||
|
||||
+19
-19
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
open class CompileNativeTest @Inject constructor(
|
||||
@InputFile val inputFile: File,
|
||||
@Input val target: KonanTarget,
|
||||
@Input val target: KonanTarget
|
||||
) : DefaultTask() {
|
||||
@OutputFile
|
||||
var outputFile = project.buildDir.resolve("bin/test/${target.name}/${inputFile.nameWithoutExtension}.o")
|
||||
@@ -42,13 +42,13 @@ open class CompileNativeTest @Inject constructor(
|
||||
val args = clangArgs + sanitizerFlags + listOf(inputFile.absolutePath, "-o", outputFile.absolutePath)
|
||||
if (target.family.isAppleFamily) {
|
||||
plugin.execToolchainClang(target) {
|
||||
it.executable = "clang++"
|
||||
it.args = args
|
||||
executable = "clang++"
|
||||
this.args = args
|
||||
}
|
||||
} else {
|
||||
plugin.execBareClang {
|
||||
it.executable = "clang++"
|
||||
it.args = args
|
||||
executable = "clang++"
|
||||
this.args = args
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,13 +82,13 @@ open class LlvmLinkNativeTest @Inject constructor(
|
||||
// except the one containing the entry point to a single *.bc without internalization. The second
|
||||
// run internalizes this big module and links it with a module containing the entry point.
|
||||
project.exec {
|
||||
it.executable = "$llvmDir/bin/llvm-link"
|
||||
it.args = listOf("-o", tmpOutput.absolutePath) + inputFiles.map { it.absolutePath }
|
||||
executable = "$llvmDir/bin/llvm-link"
|
||||
args = listOf("-o", tmpOutput.absolutePath) + inputFiles.map { it.absolutePath }
|
||||
}
|
||||
|
||||
project.exec {
|
||||
it.executable = "$llvmDir/bin/llvm-link"
|
||||
it.args = listOf(
|
||||
executable = "$llvmDir/bin/llvm-link"
|
||||
args = listOf(
|
||||
"-o", outputFile.absolutePath,
|
||||
mainFile.absolutePath,
|
||||
tmpOutput.absolutePath,
|
||||
@@ -104,7 +104,7 @@ open class LinkNativeTest @Inject constructor(
|
||||
@Internal val target: String,
|
||||
@Internal val linkerArgs: List<String>,
|
||||
private val platformManager: PlatformManager,
|
||||
private val mimallocEnabled: Boolean,
|
||||
private val mimallocEnabled: Boolean
|
||||
) : DefaultTask () {
|
||||
companion object {
|
||||
fun create(
|
||||
@@ -115,7 +115,7 @@ open class LinkNativeTest @Inject constructor(
|
||||
target: String,
|
||||
outputFile: File,
|
||||
linkerArgs: List<String>,
|
||||
mimallocEnabled: Boolean,
|
||||
mimallocEnabled: Boolean
|
||||
): LinkNativeTest = project.tasks.create(
|
||||
taskName,
|
||||
LinkNativeTest::class.java,
|
||||
@@ -165,7 +165,7 @@ open class LinkNativeTest @Inject constructor(
|
||||
outputDsymBundle = "",
|
||||
needsProfileLibrary = false,
|
||||
mimallocEnabled = mimallocEnabled,
|
||||
sanitizer = sanitizer,
|
||||
sanitizer = sanitizer
|
||||
).map { it.argsWithExecutable }
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ open class LinkNativeTest @Inject constructor(
|
||||
fun link() {
|
||||
for (command in commands) {
|
||||
project.exec {
|
||||
it.commandLine(command)
|
||||
commandLine(command)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,9 +184,9 @@ private fun createTestTask(
|
||||
testName: String,
|
||||
testedTaskNames: List<String>,
|
||||
sanitizer: SanitizerKind?,
|
||||
configureCompileToBitcode: CompileToBitcode.() -> Unit = {},
|
||||
configureCompileToBitcode: CompileToBitcode.() -> Unit = {}
|
||||
): Task {
|
||||
val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager
|
||||
val platformManager = project.project(":kotlin-native").findProperty("platformManager") as PlatformManager
|
||||
val googleTestExtension = project.extensions.getByName(RuntimeTestingPlugin.GOOGLE_TEST_EXTENSION_NAME) as GoogleTestExtension
|
||||
val testedTasks = testedTaskNames.map {
|
||||
project.tasks.getByName(it) as CompileToBitcode
|
||||
@@ -243,7 +243,7 @@ private fun createTestTask(
|
||||
"${testName}Compile",
|
||||
CompileNativeTest::class.java,
|
||||
llvmLinkTask.outputFile,
|
||||
konanTarget,
|
||||
konanTarget
|
||||
).apply {
|
||||
this.sanitizer = sanitizer
|
||||
dependsOn(llvmLinkTask)
|
||||
@@ -259,7 +259,7 @@ private fun createTestTask(
|
||||
listOf(compileTask.outputFile),
|
||||
target,
|
||||
testName,
|
||||
mimallocEnabled,
|
||||
mimallocEnabled
|
||||
).apply {
|
||||
this.sanitizer = sanitizer
|
||||
dependsOn(compileTask)
|
||||
@@ -302,9 +302,9 @@ fun createTestTasks(
|
||||
targetName: String,
|
||||
testTaskName: String,
|
||||
testedTaskNames: List<String>,
|
||||
configureCompileToBitcode: CompileToBitcode.() -> Unit = {},
|
||||
configureCompileToBitcode: CompileToBitcode.() -> Unit = {}
|
||||
): List<Task> {
|
||||
val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager
|
||||
val platformManager = project.rootProject.project(":kotlin-native").findProperty("platformManager") as PlatformManager
|
||||
val target = platformManager.targetByName(targetName)
|
||||
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
||||
return sanitizers.map { sanitizer ->
|
||||
|
||||
+4
-4
@@ -38,10 +38,10 @@ open class RuntimeTestingPlugin : Plugin<Project> {
|
||||
provider { extension.fetchDirectory }
|
||||
)
|
||||
task.configure {
|
||||
it.refresh.set(provider { extension.refresh })
|
||||
it.onlyIf { extension.localSourceRoot == null }
|
||||
it.description = "Retrieves GoogleTest from the given repository"
|
||||
it.group = "Google Test"
|
||||
refresh.set(provider { extension.refresh })
|
||||
onlyIf { extension.localSourceRoot == null }
|
||||
description = "Retrieves GoogleTest from the given repository"
|
||||
group = "Google Test"
|
||||
}
|
||||
return task
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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>()
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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)
|
||||
}
|
||||
Reference in New Issue
Block a user