a14d0d148b
Move all the code to apply Kotlin bootstrap into settings script plugin which does following: - configures based either on the repo root 'local.properties' or on the root project gradle properties or on the repo root 'gradle.properties' current type of bootstrap - automatically adds Kotlin bootstrap repository with exclusive content, so bootstrap dependencies will not be by mistake downloaded from other repository - automatically forces all Kotlin plugins applied in the build to use bootstrap version This script should be applied only in project settings.gradle and then it does all the configuration by itself.
213 lines
7.0 KiB
Groovy
213 lines
7.0 KiB
Groovy
import org.jetbrains.kotlin.konan.target.HostManager
|
|
|
|
buildscript {
|
|
ext.rootBuildDirectory = file('../..')
|
|
|
|
ext {
|
|
def properties = new java.util.Properties()
|
|
properties.load(new java.io.FileReader(project.file("$rootBuildDirectory/../gradle.properties")))
|
|
properties.each { k, v ->
|
|
def key = k as String
|
|
def value = project.findProperty(key) ?: v
|
|
project.logger.info("${project.name} $key: $value")
|
|
set(key, value)
|
|
}
|
|
}
|
|
ext["withoutEmbedabble"] = true
|
|
MiscKt.kotlinInit(project, findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false)
|
|
ext["bootstrapKotlinRepo"] = BootstrapKt.getBootstrapKotlinRepo(project)
|
|
ext["bootstrapKotlinVersion"] = BootstrapKt.getBootstrapKotlinVersion(project)
|
|
ext["kotlinVersion"] = project.bootstrapKotlinVersion
|
|
|
|
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
|
|
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
|
|
}
|
|
|
|
plugins {
|
|
id("org.jetbrains.kotlin.multiplatform")
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
def getHostName() {
|
|
def target = System.getProperty("os.name")
|
|
if (target == 'Linux') return 'linux'
|
|
if (target.startsWith('Windows')) return 'windows'
|
|
if (target.startsWith('Mac'))
|
|
if (System.getProperty("os.arch") == "aarch64")
|
|
return 'macosArm64'
|
|
else
|
|
return 'macosX64'
|
|
return 'unknown'
|
|
}
|
|
|
|
kotlin {
|
|
sourceSets {
|
|
commonMain {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"
|
|
}
|
|
kotlin.srcDir '../benchmarks/shared/src'
|
|
kotlin.srcDir 'src/main/kotlin'
|
|
kotlin.srcDir '../../endorsedLibraries/kotlinx.cli/src/main/kotlin'
|
|
}
|
|
commonTest {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion"
|
|
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion"
|
|
}
|
|
kotlin.srcDir 'src/tests'
|
|
}
|
|
jvmTest {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
|
|
implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
|
|
}
|
|
}
|
|
jsTest {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion"
|
|
}
|
|
}
|
|
nativeMain {
|
|
dependsOn commonMain
|
|
kotlin.srcDir 'src/main/kotlin-native'
|
|
kotlin.srcDir '../../endorsedLibraries/kotlinx.cli/src/main/kotlin-native'
|
|
}
|
|
jvmMain {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
|
|
}
|
|
kotlin.srcDir 'src/main/kotlin-jvm'
|
|
kotlin.srcDir '../../endorsedLibraries/kotlinx.cli/src/main/kotlin-jvm'
|
|
}
|
|
jsMain {
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion"
|
|
}
|
|
kotlin.srcDir 'src/main/kotlin-js'
|
|
kotlin.srcDir '../../endorsedLibraries/kotlinx.cli/src/main/kotlin-js'
|
|
}
|
|
linuxMain { dependsOn nativeMain }
|
|
windowsMain { dependsOn nativeMain }
|
|
macosX64Main { dependsOn nativeMain }
|
|
macosArm64Main { dependsOn nativeMain }
|
|
}
|
|
|
|
targets {
|
|
fromPreset(presets.jvm, 'jvm') {
|
|
compilations.all {
|
|
tasks[compileKotlinTaskName].kotlinOptions {
|
|
jvmTarget = '1.8'
|
|
}
|
|
tasks[compileKotlinTaskName].kotlinOptions.suppressWarnings = true
|
|
}
|
|
}
|
|
|
|
if (HostManager.hostIsMingw) {
|
|
fromPreset(presets.mingwX64, 'windows') {
|
|
binaries.all {
|
|
linkerOpts = ["-L${getMingwPath()}/lib".toString()]
|
|
}
|
|
compilations.main.cinterops {
|
|
libcurl {
|
|
includeDirs.headerFilterOnly "${getMingwPath()}/include"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (HostManager.hostIsLinux) {
|
|
fromPreset(presets.linuxX64, 'linux') {
|
|
compilations.main.cinterops {
|
|
libcurl {
|
|
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (HostManager.hostIsMac) {
|
|
fromPreset(presets.macosX64, 'macosX64') {
|
|
compilations.main.cinterops {
|
|
libcurl {
|
|
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
|
}
|
|
}
|
|
}
|
|
fromPreset(presets.macosArm64, 'macosArm64') {
|
|
compilations.main.cinterops {
|
|
libcurl {
|
|
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fromPreset(presets.js, 'js') {
|
|
compilations.main.kotlinOptions {
|
|
main = "noCall"
|
|
}
|
|
}
|
|
|
|
configure([findByName('windows'), findByName('linux'), findByName('macosX64'), findByName('macosArm64')].findAll { it != null }) {
|
|
def isCurrentHost = (name == getHostName())
|
|
compilations.all {
|
|
cinterops.all {
|
|
project.tasks[interopProcessingTaskName].enabled = isCurrentHost
|
|
}
|
|
compileKotlinTask.enabled = isCurrentHost
|
|
}
|
|
binaries.all {
|
|
linkTask.enabled = isCurrentHost
|
|
}
|
|
|
|
binaries {
|
|
executable('benchmarksAnalyzer', [RELEASE]) {
|
|
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
|
|
linkerOpts("-L${getMingwPath()}/lib")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
js {
|
|
browser {
|
|
distribution {
|
|
directory = new File("$projectDir/web/")
|
|
}
|
|
dceTask {
|
|
keep 'benchmarksAnalyzer.main_kand9s$'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def getMingwPath() {
|
|
def directory = System.getenv("MINGW64_DIR")
|
|
if (directory == null)
|
|
directory = "c:/msys64/mingw64"
|
|
return directory
|
|
}
|
|
|
|
task assembleWeb(type: Sync) {
|
|
def runtimeDependencies = kotlin.targets.js.compilations.main.runtimeDependencyFiles
|
|
from(files {
|
|
runtimeDependencies.collect { File file ->
|
|
zipTree(file.absolutePath)
|
|
}
|
|
}.builtBy(runtimeDependencies)) {
|
|
includeEmptyDirs = false
|
|
include { fileTreeElement ->
|
|
def path = fileTreeElement.path
|
|
path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
|
|
!path.startsWith("META-INF/"))
|
|
}
|
|
}
|
|
|
|
from compileKotlinJs.destinationDirectory
|
|
into "${projectDir}/web"
|
|
}
|