108 lines
3.7 KiB
Groovy
108 lines
3.7 KiB
Groovy
import org.jetbrains.kotlin.konan.target.HostManager
|
|
import org.jetbrains.kotlin.konan.util.PlatformLibsInfo
|
|
import org.jetbrains.kotlin.*
|
|
|
|
buildscript {
|
|
repositories {
|
|
if (UtilsKt.getCacheRedirectorEnabled(project))
|
|
maven { url 'https://cache-redirector.jetbrains.com/jcenter' }
|
|
else
|
|
jcenter()
|
|
maven {
|
|
url project.bootstrapKotlinRepo
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
apply plugin: 'kotlin-multiplatform'
|
|
|
|
repositories {
|
|
if (UtilsKt.getCacheRedirectorEnabled(project))
|
|
maven { url 'https://cache-redirector.jetbrains.com/jcenter' }
|
|
else
|
|
jcenter()
|
|
}
|
|
|
|
kotlin {
|
|
sourceSets {
|
|
commonMain {
|
|
dependencies {
|
|
implementation project(":kotlin-stdlib-common")
|
|
}
|
|
kotlin.srcDir 'src/main/kotlin'
|
|
|
|
}
|
|
commonTest {
|
|
dependencies {
|
|
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 project(":kotlin-stdlib-jdk8")
|
|
}
|
|
kotlin.srcDir 'src/main/kotlin-jvm'
|
|
}
|
|
// JVM-specific tests and their dependencies:
|
|
jvm().compilations.test.defaultSourceSet {
|
|
dependencies {
|
|
implementation project(":kotlin-test:kotlin-test-junit")
|
|
}
|
|
}
|
|
|
|
jvm().compilations.all {
|
|
kotlinOptions {
|
|
freeCompilerArgs = ["-Xopt-in=kotlinx.cli.ExperimentalCli", "-Xopt-in=kotlin.RequiresOptIn"]
|
|
suppressWarnings = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def commonSrc = new File("$projectDir/src/main/kotlin")
|
|
def nativeSrc = new File("$projectDir/src/main/kotlin-native")
|
|
|
|
targetList.each { target ->
|
|
def konanJvmArgs = [*HostManager.regularJvmArgs]
|
|
|
|
def defaultArgs = ['-nopack', '-no-default-libs', '-no-endorsed-libs']
|
|
if (target != "wasm32") defaultArgs += '-g'
|
|
def konanArgs = [*defaultArgs,
|
|
'-target', target,
|
|
"-Xruntime=${project(':kotlin-native:runtime').file('build/bitcode/main/' + target + '/runtime.bc')}",
|
|
*project.globalBuildArgs]
|
|
|
|
task("${target}KotlinxCli", type: JavaExec) {
|
|
def outputFile = project.file("build/${target}KotlinxCli")
|
|
// See :endorsedLibraries.ext for full endorsedLibraries list.
|
|
def moduleName = endorsedLibraries[project].name
|
|
|
|
dependsOn ":kotlin-native:distCompiler"
|
|
dependsOn ":kotlin-native:${target}CrossDistRuntime"
|
|
|
|
def kotlinNativeDist = UtilsKt.getKotlinNativeDist(project)
|
|
systemProperties "konan.home": kotlinNativeDist
|
|
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
|
// This task depends on distCompiler, so the compiler jar is already in the dist directory.
|
|
classpath = fileTree("$kotlinNativeDist/konan/lib") {
|
|
include "*.jar"
|
|
}
|
|
jvmArgs = konanJvmArgs
|
|
args = [*konanArgs,
|
|
'-output', outputFile,
|
|
'-produce', 'library', '-module-name', moduleName, '-XXLanguage:+AllowContractsForCustomFunctions',
|
|
'-Xmulti-platform', '-Xopt-in=kotlinx.cli.ExperimentalCli',
|
|
'-Xopt-in=kotlin.ExperimentalMultiplatform',
|
|
'-Xallow-result-return-type', '-Werror', '-Xopt-in=kotlin.RequiresOptIn',
|
|
commonSrc.absolutePath,
|
|
"-Xcommon-sources=${commonSrc.absolutePath}",
|
|
nativeSrc]
|
|
inputs.dir(nativeSrc)
|
|
inputs.dir(commonSrc)
|
|
outputs.dir(outputFile)
|
|
}
|
|
}
|