[build] joint (step 1)

(cherry picked from commit 7d0775f7e69ab900200bcf1fa78b94d68e6bd4f6)
This commit is contained in:
Vasily Levchenko
2020-11-12 10:25:57 +01:00
parent cc9573a9a0
commit c85c3ac123
59 changed files with 822 additions and 637 deletions
+85
View File
@@ -81,12 +81,15 @@ extra["intellijReleaseType"] = when {
else -> "releases"
}
extra["versions.androidDxSources"] = "5.0.0_r2"
extra["customDepsOrg"] = "kotlin.build"
repositories {
jcenter()
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://kotlin.bintray.com/kotlin-dev")
gradlePluginPortal()
extra["bootstrapKotlinRepo"]?.let {
@@ -94,6 +97,21 @@ repositories {
}
}
sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
kotlin.srcDir("src/main/kotlin")
kotlin.srcDir("src/generated/kotlin")
kotlin.srcDir("src/to_bootstrap/kotlin")
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")
}
tasks.validatePlugins.configure {
enabled = false
}
dependencies {
implementation(kotlin("stdlib", embeddedKotlinVersion))
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
@@ -113,6 +131,26 @@ dependencies {
implementation("org.gradle:test-retry-gradle-plugin:1.1.9")
implementation("com.gradle.enterprise:test-distribution-gradle-plugin:1.2.1")
compileOnly(gradleApi())
val kotlinVersion = project.bootstrapKotlinVersion
val ktorVersion = "1.2.1"
val slackApiVersion = "1.2.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")
implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion")
}
samWithReceiver {
@@ -134,6 +172,14 @@ tasks.withType<KotlinCompile>().configureEach {
}
tasks["build"].dependsOn(":prepare-deps:build")
sourceSets["main"].withConvention(org.gradle.api.tasks.GroovySourceSet::class) {
groovy.srcDir("../kotlin-native/build-tools/src/main/groovy")
}
tasks.named("compileGroovy", GroovyCompile::class.java) {
classpath += project.files(tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java))
dependsOn(tasks.named("compileKotlin"))
}
allprojects {
tasks.register("checkBuild")
@@ -142,3 +188,42 @@ allprojects {
apply(from = "$rootDir/../gradle/cacheRedirector.gradle.kts")
}
}
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"
}
create("konan") {
id = "konan"
implementationClass = "org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin"
}
// We bundle a shaded version of kotlinx-serialization plugin
create("kotlinx-serialization-native") {
id = "kotlinx-serialization-native"
implementationClass = "shadow.org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin"
}
create("org.jetbrains.kotlin.konan") {
id = "org.jetbrains.kotlin.konan"
implementationClass = "org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin"
}
}
}
@@ -0,0 +1,14 @@
/*
* 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.kotlin.konan
internal val currentCompilerVersion: CompilerVersion =
CompilerVersionImpl(
MetaVersion.DEV, 1, 4,
30, -1, -1)
val CompilerVersion.Companion.CURRENT: CompilerVersion
get() = currentCompilerVersion
@@ -0,0 +1,84 @@
/*
* 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.kotlin
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.*
import java.io.File
import java.io.FileNotFoundException
import java.io.PrintWriter
import java.util.regex.Pattern
open class VersionGenerator: DefaultTask() {
@OutputDirectory
fun getVersionSourceDirectory(): File {
return getProject().file("build/generated")
}
@OutputFile
open fun getVersionFile(): File? {
return getProject().file(getVersionSourceDirectory().path + "/src/generated/org/jetbrains/kotlin/konan/CompilerVersionGenerated.kt")
}
@Input
open fun getKonanVersion(): String? {
return getProject().getProperties().get("konanVersion").toString()
}
// TeamCity passes all configuration parameters into a build script as project properties.
// Thus we can use them here instead of environment variables.
@Optional
@Input
open fun getBuildNumber(): String? {
val property: Any = getProject().findProperty("build.number") ?: return null
return property.toString()
}
@Input
open fun getMeta(): String {
val konanMetaVersionProperty: Any = getProject().getProperties().get("konanMetaVersion") ?: return "MetaVersion.DEV"
return "MetaVersion." + konanMetaVersionProperty.toString().toUpperCase()
}
private val versionPattern = Pattern.compile(
"^(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:-M(\\p{Digit}))?(?:-(\\p{Alpha}\\p{Alnum}*))?(?:-(\\d+))?$"
)
@TaskAction
open fun generateVersion() {
val matcher = versionPattern.matcher(getKonanVersion())
require(matcher.matches()) { "Cannot parse Kotlin/Native version: \$konanVersion" }
val major = matcher.group(1).toInt()
val minor = matcher.group(2).toInt()
val maintenanceStr = matcher.group(3)
val maintenance = maintenanceStr?.toInt() ?: 0
val milestoneStr = matcher.group(4)
val milestone = milestoneStr?.toInt() ?: -1
val buildNumber = getBuildNumber()
getProject().getLogger().info("BUILD_NUMBER: " + getBuildNumber())
var build = -1
if (buildNumber != null) {
val buildNumberSplit = buildNumber.split("-".toRegex()).toTypedArray()
build = buildNumberSplit[buildNumberSplit.size - 1].toInt() // //7-dev-buildcount
}
try {
PrintWriter(getVersionFile()).use { printWriter ->
printWriter.println(
"""package org.jetbrains.kotlin.konan
internal val currentCompilerVersion: CompilerVersion =
CompilerVersionImpl(${getMeta()}, $major, $minor,
$maintenance, $milestone, $build)
val CompilerVersion.Companion.CURRENT: CompilerVersion
get() = currentCompilerVersion"""
)
}
} catch (e: FileNotFoundException) {
throw IllegalStateException(e)
}
}
}
+5 -11
View File
@@ -20,8 +20,7 @@ buildscript {
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}"
}
}
apply plugin: 'kotlin'
@@ -32,7 +31,7 @@ apply plugin: 'cpp'
import org.jetbrains.kotlin.konan.target.ClangArgs
final Project libclangextProject = project(":libclangext")
final Project libclangextProject = project(":kotlin-native:libclangext")
final String libclangextTask = libclangextProject.path + ":build"
File libclangextDir = new File(libclangextProject.buildDir, "libs/clangext/static")
final boolean libclangextIsEnabled = libclangextProject.isEnabled
@@ -46,7 +45,7 @@ if (isWindows()) {
List<String> cflags = [
"-I$llvmDir/include",
"-I${project(":libclangext").projectDir.absolutePath + "/src/main/include"}"
"-I${project(":kotlin-native:libclangext").projectDir.absolutePath}/src/main/include"
]*.toString()
List<String> ldflags = ["$llvmDir/$libclang", "-L$libclangextDir.absolutePath", "-lclangext"]*.toString()
@@ -111,15 +110,10 @@ sourceSets {
}
}
repositories {
maven {
url buildKotlinCompilerRepo
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile project(':Interop:Runtime')
compile project(":kotlin-stdlib")
compile project(':kotlin-native:Interop:Runtime')
}
task nativelibs(type: Copy) {
+1 -1
View File
@@ -15,6 +15,6 @@
*/
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
}
+6 -13
View File
@@ -23,8 +23,7 @@ buildscript {
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}"
}
}
import org.jetbrains.kotlin.konan.target.ClangArgs
@@ -38,9 +37,9 @@ model {
include '**/*.c'
}
binaries.all {
def host = rootProject.ext.hostName
def host = rootProject.project(":kotlin-native").ext.hostName
def hostLibffiDir = rootProject.ext.get("${host}LibffiDir")
def hostLibffiDir = rootProject.project(":kotlin-native").ext.get("${host}LibffiDir")
cCompiler.args hostPlatform.clang.hostCompilerArgsForJni
cCompiler.args "-I$hostLibffiDir/include"
@@ -59,16 +58,10 @@ model {
}
}
repositories {
maven {
url buildKotlinCompilerRepo
}
}
dependencies {
compile project(":utilities:basic-utils")
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile project(":kotlin-native:utilities:basic-utils")
compile project(":kotlin-stdlib")
compile project(":kotlin-reflect")
}
sourceSets.main.kotlin.srcDirs += "src/jvm/kotlin"
@@ -15,7 +15,7 @@
*/
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
}
apply plugin: 'kotlin'
@@ -23,25 +23,19 @@ apply plugin: 'application'
mainClassName = "org.jetbrains.kotlin.native.interop.gen.jvm.MainKt"
repositories {
maven {
url buildKotlinCompilerRepo
}
}
dependencies {
implementation project(":Interop:Indexer")
implementation project(":utilities:basic-utils")
api project(path: ":endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
implementation project(":kotlin-native:Interop:Indexer")
implementation project(":kotlin-native:utilities:basic-utils")
api project(path: ":kotlin-native:endorsedLibraries:kotlinx.cli", configuration: "jvmRuntimeElements")
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
api "org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion"
api "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
api "org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion"
api project(":kotlin-stdlib")
api project(":kotlin-compiler")
api project(":kotlinx-metadata-klib")
testImplementation "junit:junit:4.12"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
testImplementation project(":kotlin-test:kotlin-test-junit")
}
compileKotlin {
+26 -27
View File
@@ -6,7 +6,7 @@ import org.jetbrains.kotlin.konan.target.HostManager
* that can be found in the LICENSE file.
*/
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
apply from: "../../kotlin-native/gradle/kotlinGradlePlugin.gradle"
apply plugin: 'project-report'
dependencies {
@@ -24,7 +24,7 @@ apply plugin: "maven-publish"
// (gets applied to this project and all its subprojects)
allprojects {
repositories {
maven { url buildKotlinCompilerRepo }
maven { url project.bootstrapKotlinRepo }
}
}
@@ -87,22 +87,23 @@ task renamePackage {
kotlinNativeInterop {
llvm {
dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary"
dependsOn ":llvmCoverageMappingC:coverageMappingStaticLibrary"
dependsOn ":kotlin-native:llvmDebugInfoC:debugInfoStaticLibrary"
dependsOn ":kotlin-native:llvmCoverageMappingC:coverageMappingStaticLibrary"
defFile 'llvm.def'
if (!project.parent.convention.plugins.platformInfo.isWindows())
compilerOpts "-fPIC"
compilerOpts "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include", "-I${project(':llvmCoverageMappingC').projectDir}/src/main/include"
linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static", "-L${project(':llvmCoverageMappingC').buildDir}/libs/coverageMapping/static"
compilerOpts "-I$llvmDir/include", "-I${rootProject.project(':kotlin-native:llvmDebugInfoC').projectDir}/src/main/include", "-I${rootProject.project(':kotlin-native:llvmCoverageMappingC').projectDir}/src/main/include"
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').buildDir}/libs/debugInfo/static", "-L${rootProject.project(':kotlin-native:llvmCoverageMappingC').buildDir}/libs/coverageMapping/static"
}
hash { // TODO: copy-pasted from ':common:compileHash'
if (!project.parent.convention.plugins.platformInfo.isWindows()) {
if (!rootProject.project(":kotlin-native").convention.plugins.platformInfo.isWindows()) {
compilerOpts '-fPIC'
linkerOpts '-fPIC'
}
linker 'clang++'
linkOutputs ":common:${hostName}Hash"
linkOutputs ":kotlin-native:common:${hostName}Hash"
headers fileTree('../common/src/hash/headers') {
include '**/*.h'
@@ -118,7 +119,7 @@ kotlinNativeInterop {
linkerOpts '-fPIC'
}
linker 'clang++'
linkOutputs ":common:${hostName}Files"
linkOutputs ":kotlin-native:common:${hostName}Files"
headers fileTree('../common/src/files/headers') {
include '**/*.h'
@@ -150,27 +151,25 @@ configurations {
dependencies {
trove4j_jar "org.jetbrains.intellij.deps:trove4j:1.0.20181211@jar"
kotlin_compiler_jar "$kotlinCompilerModule@jar"
kotlin_stdlib_jar "$kotlinStdLibModule@jar"
kotlin_reflect_jar "$kotlinReflectModule@jar"
kotlin_script_runtime_jar "$kotlinScriptRuntimeModule@jar"
kotlin_compiler_jar project(":kotlin-compiler")
kotlin_stdlib_jar project(":kotlin-stdlib")
kotlin_reflect_jar project(":kotlin-reflect")
kotlin_script_runtime_jar project(":kotlin-script-runtime")
[kotlinCommonStdlibModule, kotlinTestCommonModule, kotlinTestAnnotationsCommonModule].each {
kotlinCommonSources(it) { transitive = false }
}
compilerCompile project(":utilities:basic-utils")
compilerCompile project(":kotlin-native:utilities:basic-utils")
compilerCompile "com.google.protobuf:protobuf-java:${protobufVersion}"
compilerCompile kotlinCompilerModule
compilerCompile project(":kotlin-compiler")
compilerCompile kotlinNativeInterop['llvm'].configuration
compilerCompile kotlinNativeInterop['hash'].configuration
compilerCompile kotlinNativeInterop['files'].configuration
compilerCompile "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
cli_bcCompile kotlinCompilerModule
cli_bcCompile "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
cli_bcCompile project(":kotlin-compiler")
cli_bcCompile sourceSets.compiler.output
bc_frontendCompile kotlinCompilerModule
@@ -193,10 +192,10 @@ task unzipStdlibSources(type: CopyCommonSources) {
}
final List<File> stdLibSrc = [
project(':Interop:Runtime').file('src/main/kotlin'),
project(':Interop:Runtime').file('src/native/kotlin'),
project(':Interop:JsRuntime').file('src/main/kotlin'),
project(':runtime').file('src/main/kotlin')
project(':kotlin-native:Interop:Runtime').file('src/main/kotlin'),
project(':kotlin-native:Interop:Runtime').file('src/native/kotlin'),
project(':kotlin-native:Interop:JsRuntime').file('src/main/kotlin'),
project(':kotlin-native:runtime').file('src/main/kotlin')
]
// These files are built before the 'dist' is complete,
@@ -211,7 +210,7 @@ targetList.each { target ->
if (target != "wasm32") defaultArgs += '-g'
def konanArgs = [*defaultArgs,
'-target', target,
"-Xruntime=${project(':runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
"-Xruntime=${project(':kotlin-native:runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
*project.globalBuildArgs]
task("${target}Stdlib", type: JavaExec) {
@@ -222,7 +221,7 @@ targetList.each { target ->
}
jvmArgs = konanJvmArgs
args = [*konanArgs,
'-output', project(':runtime').file("build/${target}Stdlib"),
'-output', project(':kotlin-native:runtime').file("build/${target}Stdlib"),
'-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions',
'-Xmulti-platform', '-Xopt-in=kotlin.RequiresOptIn', '-Xinline-classes',
'-Xopt-in=kotlin.contracts.ExperimentalContracts',
@@ -233,11 +232,11 @@ targetList.each { target ->
*stdLibSrc]
stdLibSrc.forEach { inputs.dir(it) }
inputs.dir(commonSrc)
outputs.dir(project(':runtime').file("build/${target}Stdlib"))
outputs.dir(project(':kotlin-native:runtime').file("build/${target}Stdlib"))
dependsOn 'unzipStdlibSources'
dependsOn ":runtime:${target}Runtime"
dependsOn ":distCompiler"
dependsOn ":kotlin-native:runtime:${target}Runtime"
dependsOn ":kotlin-native:distCompiler"
}
}
@@ -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",
@@ -158,7 +158,7 @@ open class CompareDistributionSignatures : DefaultTask() {
val oldKlibSignatures = getKlibSignatures(old).toSet()
return CompareDiff(
newKlibSignatures - oldKlibSignatures,
oldKlibSignatures - newKlibSignatures,
oldKlibSignatures - newKlibSignatures
)
}
@@ -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)
@@ -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),
@@ -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())
@@ -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,
@@ -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)
@@ -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)
}
}
@@ -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
@@ -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,
@@ -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 }
}
}
}
@@ -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()
}
}
}
@@ -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(
@@ -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>(
@@ -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()) {
@@ -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 ->
@@ -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>()
@@ -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)
}
+68 -74
View File
@@ -33,7 +33,6 @@ buildscript {
apply from: "gradle/kotlinGradlePlugin.gradle"
repositories {
maven { url kotlinCompilerRepo }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://cache-redirector.jetbrains.com/maven-central" }
mavenCentral()
@@ -43,9 +42,7 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion"
//classpath project(":kotlin-native-utils")
classpath 'com.github.jengelman.gradle.plugins:shadow:5.1.0'
}
}
@@ -53,10 +50,10 @@ import org.jetbrains.kotlin.konan.*
// Allows generating wrappers for the root build and all the samples during execution of the default 'wrapper' task.
// Run './gradlew wrapper --gradle-version <version>' to update all the wrappers.
apply plugin: org.jetbrains.kotlin.GradleWrappers
wrappers.projects = ['samples', 'samples/calculator', 'samples/androidNativeActivity', 'samples/cocoapods/kotlin-library']
wrapper.distributionType = Wrapper.DistributionType.ALL
//apply plugin: org.jetbrains.kotlin.GradleWrappers
//
//wrappers.projects = ['samples', 'samples/calculator', 'samples/androidNativeActivity', 'samples/cocoapods/kotlin-library']
//wrapper.distributionType = Wrapper.DistributionType.ALL
// FIXME: Remove until IDEA-231214 is fixed.
//defaultTasks 'clean', 'dist'
@@ -85,14 +82,14 @@ ext {
KonanTarget.LINUX_MIPSEL32.INSTANCE
]
kotlinCompilerModule="org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}"
kotlinStdLibModule="org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
kotlinCommonStdlibModule="org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinStdlibVersion}:sources"
kotlinTestCommonModule="org.jetbrains.kotlin:kotlin-test-common:${kotlinStdlibVersion}:sources"
kotlinTestAnnotationsCommonModule="org.jetbrains.kotlin:kotlin-test-annotations-common:${kotlinStdlibVersion}:sources"
kotlinReflectModule="org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
kotlinScriptRuntimeModule="org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}"
kotlinUtilKliMetadatabModule="org.jetbrains.kotlin:kotlin-util-klib-metadata:${kotlinVersion}"
kotlinCompilerModule= project(":kotlin-compiler")
kotlinStdLibModule= project(":kotlin-stdlib")
kotlinCommonStdlibModule= project(":kotlin-stdlib-common")
kotlinTestCommonModule= project(":kotlin-test:kotlin-test-common")
kotlinTestAnnotationsCommonModule= project(":kotlin-test:kotlin-test-annotations-common")
kotlinReflectModule= project(":kotlin-reflect")
kotlinScriptRuntimeModule= project(":kotlin-script-runtime")
kotlinUtilKliMetadatabModule= project(":kotlin-util-klib-metadata")
konanVersionFull = CompilerVersionGeneratedKt.getCurrentCompilerVersion()
gradlePluginVersion = konanVersionFull
@@ -108,8 +105,8 @@ allprojects {
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
}
}
if (path != ":dependencies") {
evaluationDependsOn(":dependencies")
if (path != ":kotlin-native:dependencies") {
evaluationDependsOn(":kotlin-native:dependencies")
}
repositories {
@@ -118,10 +115,7 @@ allprojects {
}
mavenCentral()
maven {
url kotlinStdlibRepo
}
maven {
url kotlinCompilerRepo
url project.bootstrapKotlinRepo
}
maven {
url "https://dl.bintray.com/kotlin/kotlin-dev"
@@ -151,7 +145,7 @@ void setupHostAndTarget() {
void setupClang(Project project) {
project.convention.plugins.platformManager = project.rootProject.ext.platformManager
project.convention.plugins.platformManager = project.project(":kotlin-native").ext.platformManager
project.convention.plugins.execClang = new org.jetbrains.kotlin.ExecClang(project)
project.plugins.withType(NativeComponentPlugin) {
@@ -223,28 +217,28 @@ dependencies {
[kotlinCommonStdlibModule, kotlinTestCommonModule, kotlinTestAnnotationsCommonModule].each {
kotlinCommonSources(it) { transitive = false }
}
distPack project(':Interop:Runtime')
distPack project(':Interop:Indexer')
distPack project(':Interop:StubGenerator')
distPack project(':backend.native')
distPack project(':utilities:cli-runner')
distPack project(':utilities:basic-utils')
distPack project(':klib')
distPack project(path: ':endorsedLibraries:kotlinx.cli', configuration: "jvmRuntimeElements")
distPack "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
distPack project(':kotlin-native:Interop:Runtime')
distPack project(':kotlin-native:Interop:Indexer')
distPack project(':kotlin-native:Interop:StubGenerator')
//distPack project(':kotlin-native:backend.native')
distPack project(':kotlin-native:utilities:cli-runner')
distPack project(':kotlin-native:utilities:basic-utils')
distPack project(':kotlin-native:klib')
distPack project(path: ':kotlin-native:endorsedLibraries:kotlinx.cli', configuration: "jvmRuntimeElements")
//distPack "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
}
task sharedJar {
dependsOn gradle.includedBuild('shared').task(':jar')
}
//task sharedJar {
// dependsOn gradle.includedBuild('shared').task(':jar')
//}
task gradlePluginJar {
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':shadowJar')
}
//task gradlePluginJar {
// dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':shadowJar')
//}
task gradlePluginCheck {
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':check')
}
//task gradlePluginCheck {
// dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':check')
//}
task dist_compiler(dependsOn: "distCompiler")
task dist_runtime(dependsOn: "distRuntime")
@@ -256,7 +250,7 @@ task build {
task distCommonSources(type: CopyCommonSources) {
outputDir "$distDir/sources"
sourcePaths configurations.kotlinCommonSources.files
sourcePaths project(":kotlin-stdlib-common").file("src")
zipSources true
}
@@ -267,16 +261,16 @@ task distNativeSources(type: Zip) {
includeEmptyDirs = false
include('**/*.kt')
from(project(':runtime').file('src/main/kotlin'))
from(project(':Interop:Runtime').file('src/main/kotlin'))
from(project(':Interop:Runtime').file('src/native/kotlin'))
from(project(':Interop:JsRuntime').file('src/main/kotlin')) {
from(project(':kotlin-native:runtime').file('src/main/kotlin'))
from(project(':kotlin-native:Interop:Runtime').file('src/main/kotlin'))
from(project(':kotlin-native:Interop:Runtime').file('src/native/kotlin'))
from(project(':kotlin-native:Interop:JsRuntime').file('src/main/kotlin')) {
into('kotlinx/wasm/jsinterop')
}
}
task distEndorsedSources {
dependsOn(':endorsedLibraries:endorsedLibsSources')
dependsOn(':kotlin-native:endorsedLibraries:endorsedLibsSources')
}
task distSources {
@@ -366,35 +360,35 @@ task distCompiler(type: Copy) {
destinationDir distDir
from(project(':backend.native').file("build/nativelibs/$hostName")) {
from(project(':kotlin-native:backend.native').file("build/nativelibs/$hostName")) {
into('konan/nativelib')
}
from(project(':backend.native').file('build/external_jars/trove4j.jar')) {
from(project(':kotlin-native:backend.native').file('build/external_jars/trove4j.jar')) {
into('konan/lib')
}
from(project(':Interop').file('Indexer/build/nativelibs')) {
from(project(':kotlin-native:Interop').file('Indexer/build/nativelibs')) {
into('konan/nativelib')
}
from(project(':Interop').file('Runtime/build/nativelibs')) {
from(project(':kotlin-native:Interop').file('Runtime/build/nativelibs')) {
into('konan/nativelib')
}
from(project(':llvmCoverageMappingC').file('build/libs/coverageMapping/shared')) {
from(project(':kotlin-native:llvmCoverageMappingC').file('build/libs/coverageMapping/shared')) {
into('konan/nativelib')
}
from(project(':llvmDebugInfoC').file('build/libs/debugInfo/shared')) {
from(project(':kotlin-native:llvmDebugInfoC').file('build/libs/debugInfo/shared')) {
into('konan/nativelib')
}
from(project(':llvmDebugInfoC').file('src/scripts/konan_lldb.py')) {
from(project(':kotlin-native:llvmDebugInfoC').file('src/scripts/konan_lldb.py')) {
into('tools')
}
from(project(':utilities').file('env_blacklist')) {
from(project(':kotlin-native:utilities').file('env_blacklist')) {
into('tools')
}
@@ -428,7 +422,7 @@ task distDef(type: Copy) {
destinationDir distDir
platformManager.targetValues.each { target ->
from(project("platformLibs").file("src/platform/${target.family.name().toLowerCase()}")) {
from(project(":kotlin-native:platformLibs").file("src/platform/${target.family.name().toLowerCase()}")) {
into("konan/platformDef/${target.visibleName}")
include '**/*.def'
if (target in targetsWithoutZlib) {
@@ -489,12 +483,12 @@ task crossDistEndorsedCache {
targetList.each { target ->
task("${target}CrossDistRuntime", type: Copy) {
dependsOn ":runtime:${target}Runtime"
dependsOn ":backend.native:${target}Stdlib"
dependsOn ":kotlin-native:runtime:${target}Runtime"
dependsOn ":kotlin-native:backend.native:${target}Stdlib"
destinationDir distDir
from(project(':runtime').file("build/${target}Stdlib")) {
from(project(':kotlin-native:runtime').file("build/${target}Stdlib")) {
include('**')
into(stdlib)
eachFile {
@@ -507,38 +501,38 @@ targetList.each { target ->
}
}
}
from(project(':runtime').file("build/bitcode/main/$target")) {
from(project(':kotlin-native:runtime').file("build/bitcode/main/$target")) {
include("runtime.bc")
into("$stdlibDefaultComponent/targets/$target/native")
}
from(project(':runtime').file("build/bitcode/main/$target")) {
from(project(':kotlin-native:runtime').file("build/bitcode/main/$target")) {
include("*.bc")
exclude("runtime.bc")
into("konan/targets/$target/native")
}
if (target == 'wasm32') {
into("$stdlibDefaultComponent/targets/wasm32/included") {
from(project(':runtime').file('src/main/js'))
from(project(':runtime').file('src/launcher/js'))
from(project(':Interop:JsRuntime').file('src/main/js'))
from(project(':kotlin-native:runtime').file('src/main/js'))
from(project(':kotlin-native:runtime').file('src/launcher/js'))
from(project(':kotlin-native:Interop:JsRuntime').file('src/main/js'))
}
}
}
task("${target}PlatformLibs") {
dependsOn ":platformLibs:${target}Install"
dependsOn ":kotlin-native:platformLibs:${target}Install"
if (target in cacheableTargetNames) {
dependsOn(":platformLibs:${target}Cache")
dependsOn(":kotlin-native:platformLibs:${target}Cache")
}
}
if (target in cacheableTargetNames) {
task "${target}StdlibCache" {
dependsOn ":platformLibs:${target}StdlibCache"
dependsOn ":kotlin-native:platformLibs:${target}StdlibCache"
}
task "${target}EndorsedCache" {
dependsOn ":endorsedLibraries:${target}Cache"
dependsOn ":kotlin-native:endorsedLibraries:${target}Cache"
}
}
@@ -550,10 +544,10 @@ targetList.each { target ->
}
task("${target}CrossDistEndorsedLibraries", type: Copy) {
dependsOn ":endorsedLibraries:${target}EndorsedLibraries"
dependsOn ":kotlin-native:endorsedLibraries:${target}EndorsedLibraries"
destinationDir distDir
from(project(':endorsedLibraries').file("build")) {
from(project(':kotlin-native:endorsedLibraries').file("build")) {
include('**')
into("$endorsedLibsBase")
}
@@ -561,8 +555,8 @@ targetList.each { target ->
}
task distPlatformLibs {
dependsOn ':platformLibs:hostInstall'
dependsOn ':platformLibs:hostCache'
dependsOn ':kotlin-native:platformLibs:hostInstall'
dependsOn ':kotlin-native:platformLibs:hostCache'
}
task dist {
@@ -777,8 +771,8 @@ task pusher(type: KotlinBuildPusher){
targetList.each { target ->
CompilationDatabaseKt.mergeCompilationDatabases(project, "${target}CompilationDatabase".toString(), [
":common:${target}CompilationDatabase".toString(),
":runtime:${target}CompilationDatabase".toString()
":kotlin-native::common:${target}CompilationDatabase".toString(),
":kotlin-native:runtime:${target}CompilationDatabase".toString()
]).configure {
outputFile = file("$buildDir/${target}/compile_commands.json")
}
+5 -5
View File
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.konan.util.DependencyProcessor
import static org.jetbrains.kotlin.konan.util.VisibleNamedKt.getVisibleName
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
@@ -33,7 +33,7 @@ class NativeDep extends DefaultTask {
KonanPropertiesLoader konanPropertiesLoader = null
final File getBaseOutDir() {
final File res = project.rootProject.ext.dependenciesDir
final File res = rootProject.project(":kotlin-native").ext.dependenciesDir
res.mkdirs()
return res
}
@@ -75,7 +75,7 @@ enum DependencyKind {
String toString() { return name }
}
def platformManager = rootProject.ext.platformManager
def platformManager = rootProject.project(":kotlin-native").ext.platformManager
platformManager.enabled.each { target ->
@@ -87,7 +87,7 @@ platformManager.enabled.each { target ->
// Also resolves all dependencies:
final DependencyProcessor dependencyProcessor = new DependencyProcessor(
project.rootProject.ext.dependenciesDir,
rootProject.project(":kotlin-native").ext.dependenciesDir,
loader.properties,
loader.dependencies,
NativeDep.baseUrl,
@@ -99,7 +99,7 @@ platformManager.enabled.each { target ->
def dir = kind.getDirectory(loader)
if (dir != null) {
String path = dependencyProcessor.resolve(dir).canonicalPath
rootProject.ext.set(kind.getPropertyName(target), path)
rootProject.project(":kotlin-native").ext.set(kind.getPropertyName(target), path)
}
}
}
@@ -7,10 +7,6 @@ buildscript {
maven { url 'https://cache-redirector.jetbrains.com/jcenter' }
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion"
}
}
ext {
@@ -8,13 +8,10 @@ buildscript {
}
jcenter()
maven {
url kotlinCompilerRepo
url project.bootstrapKotlinRepo
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
apply plugin: 'kotlin-multiplatform'
@@ -24,40 +21,34 @@ repositories {
url 'https://cache-redirector.jetbrains.com/jcenter'
}
jcenter()
maven {
url kotlinCompilerRepo
}
maven {
url buildKotlinCompilerRepo
}
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"
implementation project(":kotlin-stdlib-common")
}
kotlin.srcDir 'src/main/kotlin'
}
commonTest {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion"
implementation project(":kotlin-test:kotlin-test-common")
implementation project(":kotlin-test:kotlin-test-annotations-common")
}
kotlin.srcDir 'src/tests'
}
jvm().compilations.main.defaultSourceSet {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation project(":kotlin-stdlib-jdk8")
}
kotlin.srcDir 'src/main/kotlin-jvm'
}
// JVM-specific tests and their dependencies:
jvm().compilations.test.defaultSourceSet {
dependencies {
implementation kotlin('test-junit')
implementation project(":kotlin-test:kotlin-test-junit")
}
}
@@ -80,7 +71,7 @@ targetList.each { target ->
if (target != "wasm32") defaultArgs += '-g'
def konanArgs = [*defaultArgs,
'-target', target,
"-Xruntime=${project(':runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
"-Xruntime=${project(':kotlin-native:runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
*project.globalBuildArgs]
task("${target}KotlinxCli", type: JavaExec) {
@@ -88,8 +79,8 @@ targetList.each { target ->
// See :endorsedLibraries.ext for full endorsedLibraries list.
def moduleName = endorsedLibraries[project].name
dependsOn ":distCompiler"
dependsOn ":${target}CrossDistRuntime"
dependsOn ":kotlin-native:distCompiler"
dependsOn ":kotlin-native:${target}CrossDistRuntime"
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
// This task depends on distCompiler, so the compiler jar is already in the dist directory.
+1 -4
View File
@@ -43,7 +43,4 @@ shadowVersion=5.1.0
metadataVersion=0.0.1-dev-10
# Uncomment to compile Kotlin/Native backend modules with JVM IR backend.
# kotlin.build.useIR=true
# Uncomment to enable composite build
kotlinProjectPath=..
# kotlin.build.useIR=true
+3 -20
View File
@@ -1,17 +1,6 @@
def properties = ['buildKotlinVersion', 'buildKotlinCompilerRepo', 'kotlinVersion', 'kotlinCompilerRepo']
for (prop in properties) {
if (!hasProperty(prop)) {
throw new GradleException("Please ensure the '$prop' property is defined before applying this script.")
}
}
project.buildscript.repositories {
maven {
url buildKotlinCompilerRepo
}
maven {
url kotlinCompilerRepo
url project.bootstrapKotlinRepo
}
maven {
url 'https://cache-redirector.jetbrains.com/maven-central'
@@ -20,18 +9,12 @@ project.buildscript.repositories {
}
project.buildscript.dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}"
}
configurations {
kotlinCompilerClasspath
}
project.repositories {
maven { url buildKotlinCompilerRepo }
maven {
url kotlinCompilerRepo
}
}
project.dependencies {
kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$buildKotlinVersion")
kotlinCompilerClasspath(project(":kotlin-compiler-embeddable"))
}
+5 -9
View File
@@ -3,10 +3,7 @@
* that can be found in the LICENSE file.
*/
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion"
}
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
ext.useCustomDist = project.hasProperty("org.jetbrains.kotlin.native.home") || project.hasProperty("konan.home")
if (!useCustomDist) {
@@ -48,12 +45,11 @@ repositories {
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation project(path: ':backend.native', configuration: 'cli_bc')
implementation project(":utilities:basic-utils")
implementation project(":kotlin-stdlib")
implementation project(path: ':kotlin-native:backend.native', configuration: 'cli_bc')
implementation project(":kotlin-native:utilities:basic-utils")
testImplementation "junit:junit:4.12"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
testImplementation project(":kotlin-test:kotlin-test-junit")
}
test {
+1 -2
View File
@@ -22,8 +22,7 @@ buildscript {
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}"
}
}
import org.jetbrains.kotlin.konan.target.ClangArgs
@@ -23,8 +23,7 @@ buildscript {
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}"
}
}
import org.jetbrains.kotlin.konan.target.ClangArgs
+1 -2
View File
@@ -23,8 +23,7 @@ buildscript {
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies {
classpath "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}"
}
}
import org.jetbrains.kotlin.konan.target.ClangArgs
+2 -10
View File
@@ -12,20 +12,12 @@ buildscript {
}
mavenCentral()
maven {
url buildKotlinCompilerRepo
}
maven {
url kotlinCompilerRepo
url project.bootstrapKotlinRepo
}
maven {
url "https://kotlin.bintray.com/kotlinx"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion"
classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion"
}
}
// These properties are used by the 'konan' plugin, thus we set them before applying it.
ext.konanHome = distDir.absolutePath
@@ -54,7 +46,7 @@ private String defFileToLibName(String target, String name) {
// TODO: I think most for the non-DSL language below can either be incorporated into DSL
// or moved out of .gradle file.
project.rootProject.ext.platformManager.enabled.each { target ->
rootProject.project("kotlin-native").ext.platformManager.enabled.each { target ->
def targetName = target.visibleName
-60
View File
@@ -1,60 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
include ':dependencies'
include ':Interop:Indexer'
include ':Interop:JsRuntime'
include ':Interop:StubGenerator'
include ':Interop:Runtime'
include ':llvmCoverageMappingC'
include ':llvmDebugInfoC'
include ':libclangext'
include ':klib'
include ':backend.native'
include ':runtime'
include ':common'
include ':backend.native:tests'
include ':backend.native:debugger-tests'
include ':utilities:basic-utils'
include ':utilities:cli-runner'
include ':dependencyPacker'
include ':platformLibs'
include ':endorsedLibraries'
include ':endorsedLibraries:kotlinx.cli'
if (hasProperty("kotlinProjectPath")) {
include ':runtime:generator'
includeBuild(kotlinProjectPath) {
dependencySubstitution {
substitute module("org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion") with project(':include:kotlin-compiler')
substitute module("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinStdlibVersion") with project(':include:kotlin-stdlib-common-sources')
substitute module("org.jetbrains.kotlin:kotlin-stdlib-gen:$kotlinStdlibVersion") with project(':tools:kotlin-stdlib-gen')
substitute module("org.jetbrains.kotlin:kotlin-util-io:$kotlinVersion") with project(':kotlin-util-io')
substitute module("org.jetbrains.kotlin:kotlin-util-klib:$kotlinVersion") with project(':kotlin-util-klib')
substitute module("org.jetbrains.kotlin:kotlin-util-klib-metadata:$kotlinVersion") with project(':kotlin-util-klib-metadata')
substitute module("org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion") with project(':native:kotlin-native-utils')
substitute module("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") with project(':kotlin-reflect')
substitute module("org.jetbrains.kotlinx:kotlinx-metadata-klib") with project(':kotlinx-metadata-klib')
}
}
}
includeBuild 'shared'
includeBuild 'build-tools'
includeBuild 'tools/kotlin-native-gradle-plugin'
@@ -285,7 +285,7 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables)
else -> error(target)
},
"@loader_path/Frameworks".takeIf { dynamic },
compilerRtDir.takeIf { sanitizer != null },
compilerRtDir.takeIf { sanitizer != null }
).flatMap { listOf("-rpath", it) }
fun dsymUtilCommand(executable: ExecutableFile, outputDsymBundle: String) =
@@ -36,7 +36,7 @@ open class KonanArtifactContainer(val project: ProjectInternal)
var targets: Iterable<String> = emptyList()
override fun create(name: String?): T =
override fun create(name: String): T =
instantiator.newInstance(configClass.java, name, project, targets)
}
@@ -117,20 +117,20 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
private fun createTask(target: KonanTarget): TaskProvider<T> =
project.tasks.register(generateTaskName(target), type) {
val outputDescription = determineOutputPlacement(target)
it.init(this, outputDescription.destinationDir, outputDescription.artifactName, target)
it.group = BasePlugin.BUILD_GROUP
it.description = generateTaskDescription(it)
init(this@KonanBuildingConfig, outputDescription.destinationDir, outputDescription.artifactName, target)
group = BasePlugin.BUILD_GROUP
description = generateTaskDescription(this)
} ?: throw Exception("Cannot create task for target: ${target.visibleName}")
private fun createAggregateTask(): TaskProvider<Task> =
project.tasks.register(generateAggregateTaskName()) { task ->
task.group = BasePlugin.BUILD_GROUP
task.description = generateAggregateTaskDescription(task)
project.tasks.register(generateAggregateTaskName()) {
group = BasePlugin.BUILD_GROUP
description = generateAggregateTaskDescription(this)
targetToTask.filter {
project.targetIsRequested(it.key)
}.forEach {
task.dependsOn(it.value)
dependsOn(it.value)
}
}.also {
project.compileAllTask.dependsOn(it)
@@ -141,9 +141,9 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
return this[canonicalTarget]?.let { canonicalBuild ->
project.tasks.register(generateTargetAliasTaskName(targetName)) {
it.group = BasePlugin.BUILD_GROUP
it.description = generateTargetAliasTaskDescription(it, targetName)
it.dependsOn(canonicalBuild)
group = BasePlugin.BUILD_GROUP
description = generateTargetAliasTaskDescription(this, targetName)
dependsOn(canonicalBuild)
}
}
}
@@ -160,43 +160,43 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
// Common building DSL.
override fun artifactName(name: String) = tasks().forEach { it.configure { t -> t.artifactName(name) } }
override fun artifactName(name: String) = tasks().forEach { it.configure { artifactName(name) } }
fun baseDir(dir: Any) =
tasks().forEach {
it.configure { t ->
t.destinationDir(
project.file(dir).targetSubdir(t.konanTarget)
it.configure {
destinationDir(
project.file(dir).targetSubdir(konanTarget)
)
}
}
override fun libraries(closure: Closure<Unit>) =
tasks().forEach { it.configure { t -> t.libraries(closure) } }
tasks().forEach { it.configure { libraries(closure) } }
override fun libraries(action: Action<KonanLibrariesSpec>) =
tasks().forEach { it.configure { t -> t.libraries(action) } }
tasks().forEach { it.configure { libraries(action) } }
override fun libraries(configure: KonanLibrariesSpec.() -> Unit) =
tasks().forEach { it.configure { t -> t.libraries(configure) } }
tasks().forEach { it.configure { libraries(configure) } }
override fun noDefaultLibs(flag: Boolean) =
tasks().forEach { it.configure { t -> t.noDefaultLibs(flag) } }
tasks().forEach { it.configure { noDefaultLibs(flag) } }
override fun noEndorsedLibs(flag: Boolean) =
tasks().forEach { it.configure { t -> t.noEndorsedLibs(flag) } }
tasks().forEach { it.configure { noEndorsedLibs(flag) } }
override fun dumpParameters(flag: Boolean) =
tasks().forEach { it.configure { t -> t.dumpParameters(flag) } }
tasks().forEach { it.configure { dumpParameters(flag) } }
override fun extraOpts(vararg values: Any) =
tasks().forEach { it.configure { t -> t.extraOpts(*values) } }
tasks().forEach { it.configure { extraOpts(*values) } }
override fun extraOpts(values: List<Any>) =
tasks().forEach { it.configure { t -> t.extraOpts(values) } }
tasks().forEach { it.configure { extraOpts(values) } }
fun dependsOn(vararg dependencies: Any?) =
tasks().forEach { it.configure { t -> t.dependsOn(*dependencies) } }
tasks().forEach { it.configure { dependsOn(*dependencies) } }
fun target(targetString: String, configureAction: T.() -> Unit) {
val target = project.hostManager.targetByName(targetString)
@@ -43,33 +43,33 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
override fun generateTargetAliasTaskDescription(task: Task, targetName: String) =
"Build the Kotlin/Native $typeForDescription '${task.name}' for target '$targetName'"
override fun srcDir(dir: Any) = tasks().forEach { it.configure { t -> t.srcDir(dir) } }
override fun srcFiles(vararg files: Any) = tasks().forEach { it.configure { t -> t.srcFiles(*files) } }
override fun srcFiles(files: Collection<Any>) = tasks().forEach { it.configure { t -> t.srcFiles(files) } }
override fun srcDir(dir: Any) = tasks().forEach { it.configure { srcDir(dir) } }
override fun srcFiles(vararg files: Any) = tasks().forEach { it.configure { srcFiles(*files) } }
override fun srcFiles(files: Collection<Any>) = tasks().forEach { it.configure { srcFiles(files) } }
override fun nativeLibrary(lib: Any) = tasks().forEach { it.configure { t -> t.nativeLibrary(lib) } }
override fun nativeLibraries(vararg libs: Any) = tasks().forEach { it.configure { t -> t.nativeLibraries(*libs) } }
override fun nativeLibraries(libs: FileCollection) = tasks().forEach { it.configure { t -> t.nativeLibraries(libs) } }
override fun nativeLibrary(lib: Any) = tasks().forEach { it.configure { nativeLibrary(lib) } }
override fun nativeLibraries(vararg libs: Any) = tasks().forEach { it.configure { nativeLibraries(*libs) } }
override fun nativeLibraries(libs: FileCollection) = tasks().forEach { it.configure { nativeLibraries(libs) } }
@Deprecated("Use commonSourceSets instead", ReplaceWith("commonSourceSets(sourceSetName)"))
override fun commonSourceSet(sourceSetName: String) = tasks().forEach { it.configure { t -> t.commonSourceSets(sourceSetName) } }
override fun commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { t -> t.commonSourceSets(*sourceSetNames) } }
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableMultiplatform(flag) } }
override fun commonSourceSet(sourceSetName: String) = tasks().forEach { it.configure { commonSourceSets(sourceSetName) } }
override fun commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { commonSourceSets(*sourceSetNames) } }
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { enableMultiplatform(flag) } }
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { t -> t.linkerOpts(values) } }
override fun linkerOpts(vararg values: String) = tasks().forEach { it.configure { t -> t.linkerOpts(*values) } }
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
override fun linkerOpts(vararg values: String) = tasks().forEach { it.configure { linkerOpts(*values) } }
override fun enableDebug(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableDebug(flag) } }
override fun noStdLib(flag: Boolean) = tasks().forEach { it.configure { t -> t.noStdLib(flag) } }
override fun noMain(flag: Boolean) = tasks().forEach { it.configure { t -> t.noMain(flag) } }
override fun enableOptimizations(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableOptimizations(flag) } }
override fun enableAssertions(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableAssertions(flag) } }
override fun enableDebug(flag: Boolean) = tasks().forEach { it.configure { enableDebug(flag) } }
override fun noStdLib(flag: Boolean) = tasks().forEach { it.configure { noStdLib(flag) } }
override fun noMain(flag: Boolean) = tasks().forEach { it.configure { noMain(flag) } }
override fun enableOptimizations(flag: Boolean) = tasks().forEach { it.configure { enableOptimizations(flag) } }
override fun enableAssertions(flag: Boolean) = tasks().forEach { it.configure { enableAssertions(flag) } }
override fun entryPoint(entryPoint: String) = tasks().forEach { it.configure { t -> t.entryPoint(entryPoint) } }
override fun entryPoint(entryPoint: String) = tasks().forEach { it.configure { entryPoint(entryPoint) } }
override fun measureTime(flag: Boolean) = tasks().forEach { it.configure { t -> t.measureTime(flag) } }
override fun measureTime(flag: Boolean) = tasks().forEach { it.configure { measureTime(flag) } }
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { t -> t.dependencies(closure) } }
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { dependencies(closure) } }
}
open class KonanProgram(name: String,
@@ -50,36 +50,36 @@ open class KonanInteropLibrary(name: String,
inner class IncludeDirectoriesSpecImpl: IncludeDirectoriesSpec {
override fun allHeaders(vararg includeDirs: Any) = allHeaders(includeDirs.toList())
override fun allHeaders(includeDirs: Collection<Any>) = tasks().forEach {
it.configure { t -> t.includeDirs.allHeaders(includeDirs) }
it.configure { this@configure.includeDirs.allHeaders(includeDirs) }
}
override fun headerFilterOnly(vararg includeDirs: Any) = headerFilterOnly(includeDirs.toList())
override fun headerFilterOnly(includeDirs: Collection<Any>) = tasks().forEach {
it.configure { t -> t.includeDirs.headerFilterOnly(includeDirs) }
it.configure { this@configure.includeDirs.headerFilterOnly(includeDirs) }
}
}
val includeDirs = IncludeDirectoriesSpecImpl()
override fun defFile(file: Any) = tasks().forEach { it.configure { t -> t.defFile(file) } }
override fun defFile(file: Any) = tasks().forEach { it.configure { defFile(file) } }
override fun packageName(value: String) = tasks().forEach { it.configure { t -> t.packageName(value) } }
override fun packageName(value: String) = tasks().forEach { it.configure { packageName(value) } }
override fun compilerOpts(vararg values: String) = tasks().forEach { it.configure { t -> t.compilerOpts(*values) } }
override fun compilerOpts(vararg values: String) = tasks().forEach { it.configure { compilerOpts(*values) } }
override fun headers(vararg files: Any) = tasks().forEach { it.configure { t -> t.headers(*files) } }
override fun headers(vararg files: Any) = tasks().forEach { it.configure { headers(*files) } }
override fun headers(files: FileCollection) = tasks().forEach { it.configure { t -> t.headers(files) } }
override fun headers(files: FileCollection) = tasks().forEach { it.configure { headers(files) } }
override fun includeDirs(vararg values: Any) = tasks().forEach { it.configure { t -> t.includeDirs(*values) } }
override fun includeDirs(vararg values: Any) = tasks().forEach { it.configure { includeDirs(*values) } }
override fun includeDirs(closure: Closure<Unit>) = includeDirs(ConfigureUtil.configureUsing(closure))
override fun includeDirs(action: Action<IncludeDirectoriesSpec>) = includeDirs { action.execute(this) }
override fun includeDirs(configure: IncludeDirectoriesSpec.() -> Unit) = includeDirs.configure()
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { t -> t.linkerOpts(values) } }
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
override fun linkerOpts(vararg values: String) = linkerOpts(values.toList())
override fun link(vararg files: Any) = tasks().forEach { it.configure { t -> t.link(*files) } }
override fun link(files: FileCollection) = tasks().forEach { it.configure { t -> t.link(files) } }
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { t -> t.dependencies(closure) }}
override fun link(vararg files: Any) = tasks().forEach { it.configure { link(*files) } }
override fun link(files: FileCollection) = tasks().forEach { it.configure { link(files) } }
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { dependencies(closure) }}
}
@@ -327,7 +327,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
}
override fun apply(project: ProjectInternal?) {
override fun apply(project: ProjectInternal) {
if (project == null) {
return
}
@@ -370,16 +370,16 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
val isCrossCompile = (task.target != HostManager.host.visibleName)
if (!isCrossCompile && !project.hasProperty("konanNoRun"))
task.runTask = project.tasks.register("run${task.artifactName.capitalize()}", Exec::class.java) {
it.group= "run"
it.dependsOn(task)
group= "run"
dependsOn(task)
val artifactPathClosure = object : Closure<String>(this) {
override fun call() = task.artifactPath
}
// Use GString to evaluate a path to the artifact lazily thus allow changing it at configuration phase.
val lazyArtifactPath = GStringImpl(arrayOf(artifactPathClosure), arrayOf(""))
it.executable(lazyArtifactPath)
executable(lazyArtifactPath)
// Add values passed in the runArgs project property as arguments.
it.argumentProviders.add(task.RunArgumentProvider())
argumentProviders.add(task.RunArgumentProvider())
}
}
}
@@ -390,7 +390,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
.filterIsInstance(KonanProgram::class.java)
.forEach { program ->
program.tasks().forEach { compile ->
compile.configure { it.runTask?.let { runTask.dependsOn(it) } }
compile.configure { runTask?.let { runTask.dependsOn(it) } }
}
}
}
@@ -403,7 +403,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
val konanSoftwareComponent = buildingConfig.mainVariant
project.extensions.configure(PublishingExtension::class.java) {
val builtArtifact = buildingConfig.name
val mavenPublication = it.publications.maybeCreate(builtArtifact, MavenPublication::class.java)
val mavenPublication = publications.maybeCreate(builtArtifact, MavenPublication::class.java)
mavenPublication.apply {
artifactId = builtArtifact
groupId = project.group.toString()
@@ -416,22 +416,22 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
}
project.extensions.configure(PublishingExtension::class.java) {
val publishing = it
for (v in konanSoftwareComponent.variants) {
publishing.publications.create(v.name, MavenPublication::class.java) { mavenPublication ->
this@configure.publications.create(v.name, MavenPublication::class.java) {
val coordinates = (v as NativeVariantIdentity).coordinates
project.logger.info("variant with coordinates($coordinates) and module: ${coordinates.module}")
mavenPublication.artifactId = coordinates.module.name
mavenPublication.groupId = coordinates.group
mavenPublication.version = coordinates.version
mavenPublication.from(v)
(mavenPublication as MavenPublicationInternal).publishWithOriginalFileName()
artifactId = coordinates.module.name
groupId = coordinates.group
version = coordinates.version
from(v)
(this as MavenPublicationInternal).publishWithOriginalFileName()
buildingConfig.pomActions.forEach {
mavenPublication.pom(it)
pom(it)
}
}
}
}
true
}
}
}
@@ -91,20 +91,20 @@ internal abstract class KonanCliRunner(
"Please change it to the compiler root directory and rerun the build.")
}
project.javaexec { spec ->
spec.main = mainClass
spec.classpath = classpath
spec.jvmArgs(jvmArgs)
spec.systemProperties(
project.javaexec {
main = this@KonanCliRunner.mainClass
classpath = classpath
jvmArgs(jvmArgs)
systemProperties(
System.getProperties().asSequence()
.map { (k, v) -> k.toString() to v.toString() }
.filter { (k, _) -> k !in blacklistProperties }
.escapeQuotesForWindows()
.toMap()
)
spec.args(listOf(toolName) + transformArgs(args))
blacklistEnvironment.forEach { spec.environment.remove(it) }
spec.environment(environment)
args(listOf(toolName) + transformArgs(args))
blacklistEnvironment.forEach { environment.remove(it) }
environment(environment)
}
}
}
@@ -97,11 +97,11 @@ abstract class KonanArtifactTask: KonanTargetableTask(), KonanArtifactSpec {
platformConfiguration = project.configurations.create("artifact${artifactName}_${target.name}")
platformConfiguration.extendsFrom(configuration)
platformConfiguration.attributes{
it.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.NATIVE_LINK))
it.attribute(CppBinary.LINKAGE_ATTRIBUTE, Linkage.STATIC)
it.attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false)
it.attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, false)
it.attribute(Attribute.of("org.gradle.native.kotlin.platform", String::class.java), target.name)
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.NATIVE_LINK))
attribute(CppBinary.LINKAGE_ATTRIBUTE, Linkage.STATIC)
attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false)
attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, false)
attribute(Attribute.of("org.gradle.native.kotlin.platform", String::class.java), target.name)
}
val artifactNameWithoutSuffix = artifact.name.removeSuffix("$artifactSuffix")
@@ -190,8 +190,8 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
val workQueue = workerExecutor.noIsolation()
interchangeBox[this.path] = toolRunner
workQueue.submit(RunTool::class.java) {
it.taskName = this.path
it.args = args
taskName = path
this.args = args
}
} else {
toolRunner.run(args)
@@ -6,7 +6,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
apply(from = "$rootDir/gradle/kotlinGradlePlugin.gradle")
apply(from = "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle")
}
plugins {
@@ -19,11 +19,7 @@ tasks.named<KotlinCompile>("compileKotlin") {
}
}
// Convert to normal strings since originally these properties contain GStrings.
val kotlinCompilerModule = rootProject.ext["kotlinCompilerModule"].toString()
val kotlinStdLibModule = rootProject.ext["kotlinStdLibModule"].toString()
dependencies {
api(kotlinStdLibModule)
implementation(kotlinCompilerModule)
api(project(":kotlin-stdlib"))
implementation(project(":kotlin-compiler"))
}
@@ -3,17 +3,11 @@
* that can be found in the LICENSE file.
*/
buildscript {
apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
}
apply plugin: 'kotlin'
repositories {
maven {
url buildKotlinCompilerRepo
}
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xskip-metadata-version-check']
@@ -22,9 +16,10 @@ compileKotlin {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation project(':backend.native')
implementation project(':Interop:StubGenerator')
implementation project(':klib')
implementation project(":utilities:basic-utils")
implementation project(":kotlin-stdlib")
implementation project(":kotlin-stdlib-common")
implementation project(':kotlin-native:backend.native')
implementation project(':kotlin-native:Interop:StubGenerator')
implementation project(':kotlin-native:klib')
implementation project(":kotlin-native:utilities:basic-utils")
}
+18
View File
@@ -581,3 +581,21 @@ project(':kotlin-serialization-unshaded').projectDir = file("$rootDir/libraries/
// Uncomment to use locally built protobuf-relocated
// includeBuild("dependencies/protobuf")
include ':kotlin-native:dependencies'
include ':kotlin-native:endorsedLibraries:kotlinx.cli'
include ':kotlin-native:endorsedLibraries'
include ':kotlin-native:Interop:StubGenerator'
include ':kotlin-native:backend.native'
include ':kotlin-native:Interop:Runtime'
include ':kotlin-native:Interop:Indexer'
include ':kotlin-native:Interop:JsRuntime'
include ':kotlin-native:utilities:basic-utils'
include ':kotlin-native:utilities:cli-runner'
include ':kotlin-native:klib'
include ':kotlin-native:common'
include ':kotlin-native:runtime'
include ':kotlin-native:llvmCoverageMappingC'
include ':kotlin-native:llvmDebugInfoC'
include ':kotlin-native:utilities'
include ':kotlin-native:platformLibs'
include ':kotlin-native:libclangext'