Skip to content

Commit

Permalink
Kotlin version 1.3.70-eap-42, fixed HMPP support in IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Jan 17, 2020
1 parent 10979a3 commit 4a79ce7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 56 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# Kotlin
version=1.3.3-native-mt-SNAPSHOT
group=org.jetbrains.kotlinx
kotlin_version=1.3.61
kotlin_version=1.3.70-eap-42

# Dependencies
junit_version=4.12
atomicfu_version=0.14.1
atomicfu_version=0.14.1-1.3.70-eap-42-2
html_version=0.6.8
lincheck_version=2.0
dokka_version=0.9.16-rdev-2-mpp-hacks
Expand Down
28 changes: 11 additions & 17 deletions gradle/compile-native-multiplatform.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ kotlin {
}

targets {
if (project.ext.ideaActive) {
// todo: This is IDEA kludge, without "fromPresent" the code does not resolve properly
//fromPreset(project.ext.ideaPreset, 'native')
addTarget(project.ext.ideaPreset)
} else {
addTarget(presets.linuxX64)
addTarget(presets.iosArm64)
addTarget(presets.iosArm32)
addTarget(presets.iosX64)
addTarget(presets.macosX64)
addTarget(presets.mingwX64)
addTarget(presets.tvosArm64)
addTarget(presets.tvosX64)
addTarget(presets.watchosArm32)
addTarget(presets.watchosArm64)
addTarget(presets.watchosX86)
}
addTarget(presets.linuxX64)
addTarget(presets.iosArm64)
addTarget(presets.iosArm32)
addTarget(presets.iosX64)
addTarget(presets.macosX64)
addTarget(presets.mingwX64)
addTarget(presets.tvosArm64)
addTarget(presets.tvosX64)
addTarget(presets.watchosArm32)
addTarget(presets.watchosArm64)
addTarget(presets.watchosX86)
}

sourceSets {
Expand Down
28 changes: 0 additions & 28 deletions gradle/targets.gradle

This file was deleted.

43 changes: 34 additions & 9 deletions kotlinx-coroutines-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
*/

apply plugin: 'kotlin-multiplatform'
apply from: rootProject.file("gradle/targets.gradle")
apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
apply from: rootProject.file("gradle/compile-common.gradle")
apply from: rootProject.file("gradle/compile-js-multiplatform.gradle")
apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
apply from: rootProject.file('gradle/publish-npm-js.gradle')

project.ext.ideaActive = System.getProperty('idea.active') == 'true'
project.ext.sourceSetSuffixes = ["Main", "Test"]

void defineSourceSet(newName, dependsOn, includedInPred) {
for (suffix in ["Main", "Test"]) {
for (suffix in project.ext.sourceSetSuffixes) {
def newSS = kotlin.sourceSets.maybeCreate(newName + suffix)
for (dep in dependsOn) {
newSS.dependsOn(kotlin.sourceSets[dep + suffix])
Expand Down Expand Up @@ -48,13 +50,6 @@ defineSourceSet("concurrent", ["common"]) { it in ["jvm", "native"] }
defineSourceSet("nativeDarwin", ["native"]) { isNativeDarwin(it) }
defineSourceSet("nativeOther", ["native"]) { isNativeOther(it) }

// todo: This is IDEA kludge, without "fromPresent" the code does not resolve properly
if (project.ext.ideaActive && isNativeDarwin(project.ext.ideaPreset.name)) {
kotlin.targets {
fromPreset(project.ext.ideaPreset, 'nativeDarwin')
}
}

/*
* All platform plugins and configuration magic happens here instead of build.gradle
* because JMV-only projects depend on core, thus core should always be initialized before configuration.
Expand Down Expand Up @@ -118,6 +113,36 @@ configurations {
configureKotlinJvmPlatform(kotlinCompilerPluginClasspath)
}

def configureNativeSourceSetPreset(name, preset) {
def hostMainCompilation = project.kotlin.targetFromPreset(preset).compilations.main
def compileConfiguration = configurations[hostMainCompilation.compileDependencyConfigurationName]
def hostNativePlatformLibs = files(provider {
compileConfiguration.findAll {
it.path.endsWith(".klib") || it.absolutePath.contains("klib${File.separator}platform")
}
})
for (suffix in project.ext.sourceSetSuffixes) {
configure(kotlin.sourceSets[name + suffix]) {
dependencies.add(implementationMetadataConfigurationName, hostNativePlatformLibs)
}
}
}

// Configure platform libraries for native source sets when working in IDEA
if (project.ext.ideaActive) {
def manager = project.ext.hostManager
def linuxPreset = kotlin.presets.linuxX64
def macosPreset = kotlin.presets.macosX64
// linux should be always available (cross-compilation capable) -- use it as default
assert manager.isEnabled(linuxPreset.konanTarget)
// use macOS libs for nativeDarwin if available
def macosAvailable = manager.isEnabled(macosPreset.konanTarget)
// configure source sets
configureNativeSourceSetPreset("native", linuxPreset)
configureNativeSourceSetPreset("nativeOther", linuxPreset)
configureNativeSourceSetPreset("nativeDarwin", macosAvailable ? macosPreset : linuxPreset)
}

kotlin.sourceSets {
jvmTest.dependencies {
api "com.devexperts.lincheck:lincheck:$lincheck_version"
Expand Down

0 comments on commit 4a79ce7

Please sign in to comment.