Skip to content

Commit 4a79ce7

Browse files
committed
Kotlin version 1.3.70-eap-42, fixed HMPP support in IDE
1 parent 10979a3 commit 4a79ce7

File tree

4 files changed

+47
-56
lines changed

4 files changed

+47
-56
lines changed

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# Kotlin
66
version=1.3.3-native-mt-SNAPSHOT
77
group=org.jetbrains.kotlinx
8-
kotlin_version=1.3.61
8+
kotlin_version=1.3.70-eap-42
99

1010
# Dependencies
1111
junit_version=4.12
12-
atomicfu_version=0.14.1
12+
atomicfu_version=0.14.1-1.3.70-eap-42-2
1313
html_version=0.6.8
1414
lincheck_version=2.0
1515
dokka_version=0.9.16-rdev-2-mpp-hacks

gradle/compile-native-multiplatform.gradle

+11-17
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@ kotlin {
99
}
1010

1111
targets {
12-
if (project.ext.ideaActive) {
13-
// todo: This is IDEA kludge, without "fromPresent" the code does not resolve properly
14-
//fromPreset(project.ext.ideaPreset, 'native')
15-
addTarget(project.ext.ideaPreset)
16-
} else {
17-
addTarget(presets.linuxX64)
18-
addTarget(presets.iosArm64)
19-
addTarget(presets.iosArm32)
20-
addTarget(presets.iosX64)
21-
addTarget(presets.macosX64)
22-
addTarget(presets.mingwX64)
23-
addTarget(presets.tvosArm64)
24-
addTarget(presets.tvosX64)
25-
addTarget(presets.watchosArm32)
26-
addTarget(presets.watchosArm64)
27-
addTarget(presets.watchosX86)
28-
}
12+
addTarget(presets.linuxX64)
13+
addTarget(presets.iosArm64)
14+
addTarget(presets.iosArm32)
15+
addTarget(presets.iosX64)
16+
addTarget(presets.macosX64)
17+
addTarget(presets.mingwX64)
18+
addTarget(presets.tvosArm64)
19+
addTarget(presets.tvosX64)
20+
addTarget(presets.watchosArm32)
21+
addTarget(presets.watchosArm64)
22+
addTarget(presets.watchosX86)
2923
}
3024

3125
sourceSets {

gradle/targets.gradle

-28
This file was deleted.

kotlinx-coroutines-core/build.gradle

+34-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
*/
44

55
apply plugin: 'kotlin-multiplatform'
6-
apply from: rootProject.file("gradle/targets.gradle")
76
apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
87
apply from: rootProject.file("gradle/compile-common.gradle")
98
apply from: rootProject.file("gradle/compile-js-multiplatform.gradle")
109
apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
1110
apply from: rootProject.file('gradle/publish-npm-js.gradle')
1211

12+
project.ext.ideaActive = System.getProperty('idea.active') == 'true'
13+
project.ext.sourceSetSuffixes = ["Main", "Test"]
14+
1315
void defineSourceSet(newName, dependsOn, includedInPred) {
14-
for (suffix in ["Main", "Test"]) {
16+
for (suffix in project.ext.sourceSetSuffixes) {
1517
def newSS = kotlin.sourceSets.maybeCreate(newName + suffix)
1618
for (dep in dependsOn) {
1719
newSS.dependsOn(kotlin.sourceSets[dep + suffix])
@@ -48,13 +50,6 @@ defineSourceSet("concurrent", ["common"]) { it in ["jvm", "native"] }
4850
defineSourceSet("nativeDarwin", ["native"]) { isNativeDarwin(it) }
4951
defineSourceSet("nativeOther", ["native"]) { isNativeOther(it) }
5052

51-
// todo: This is IDEA kludge, without "fromPresent" the code does not resolve properly
52-
if (project.ext.ideaActive && isNativeDarwin(project.ext.ideaPreset.name)) {
53-
kotlin.targets {
54-
fromPreset(project.ext.ideaPreset, 'nativeDarwin')
55-
}
56-
}
57-
5853
/*
5954
* All platform plugins and configuration magic happens here instead of build.gradle
6055
* because JMV-only projects depend on core, thus core should always be initialized before configuration.
@@ -118,6 +113,36 @@ configurations {
118113
configureKotlinJvmPlatform(kotlinCompilerPluginClasspath)
119114
}
120115

116+
def configureNativeSourceSetPreset(name, preset) {
117+
def hostMainCompilation = project.kotlin.targetFromPreset(preset).compilations.main
118+
def compileConfiguration = configurations[hostMainCompilation.compileDependencyConfigurationName]
119+
def hostNativePlatformLibs = files(provider {
120+
compileConfiguration.findAll {
121+
it.path.endsWith(".klib") || it.absolutePath.contains("klib${File.separator}platform")
122+
}
123+
})
124+
for (suffix in project.ext.sourceSetSuffixes) {
125+
configure(kotlin.sourceSets[name + suffix]) {
126+
dependencies.add(implementationMetadataConfigurationName, hostNativePlatformLibs)
127+
}
128+
}
129+
}
130+
131+
// Configure platform libraries for native source sets when working in IDEA
132+
if (project.ext.ideaActive) {
133+
def manager = project.ext.hostManager
134+
def linuxPreset = kotlin.presets.linuxX64
135+
def macosPreset = kotlin.presets.macosX64
136+
// linux should be always available (cross-compilation capable) -- use it as default
137+
assert manager.isEnabled(linuxPreset.konanTarget)
138+
// use macOS libs for nativeDarwin if available
139+
def macosAvailable = manager.isEnabled(macosPreset.konanTarget)
140+
// configure source sets
141+
configureNativeSourceSetPreset("native", linuxPreset)
142+
configureNativeSourceSetPreset("nativeOther", linuxPreset)
143+
configureNativeSourceSetPreset("nativeDarwin", macosAvailable ? macosPreset : linuxPreset)
144+
}
145+
121146
kotlin.sourceSets {
122147
jvmTest.dependencies {
123148
api "com.devexperts.lincheck:lincheck:$lincheck_version"

0 commit comments

Comments
 (0)