Skip to content

Commit 55e4136

Browse files
committed
Add build parameters to enable JVM IR and disable native targets
Build with -Penable_jvm_ir enables JVM IR compiler Build with -Pdisable_native_targets disables native targets
1 parent 4ea4078 commit 55e4136

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ buildscript {
3333
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
3434
}
3535
}
36+
ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
37+
ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
3638

3739
// Determine if any project dependency is using a snapshot version
3840
ext.using_snapshot_version = build_snapshot_train

gradle/compile-jvm-multiplatform.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ sourceCompatibility = 1.6
66
targetCompatibility = 1.6
77

88
kotlin {
9-
targets {
10-
fromPreset(presets.jvm, 'jvm')
9+
jvm {
10+
if (rootProject.ext.jvm_ir_enabled) {
11+
compilations.all {
12+
kotlinOptions.useIR = true
13+
}
14+
}
1115
}
1216
sourceSets {
1317
jvmTest.dependencies {

gradle/compile-jvm.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ apply plugin: 'org.jetbrains.kotlin.jvm'
99
sourceCompatibility = 1.6
1010
targetCompatibility = 1.6
1111

12+
if (rootProject.ext.jvm_ir_enabled) {
13+
kotlin.target.compilations.all {
14+
kotlinOptions.useIR = true
15+
}
16+
}
17+
1218
dependencies {
1319
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
1420
// Workaround to make addSuppressed work in tests

kotlinx-coroutines-core/build.gradle

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
apply plugin: 'org.jetbrains.kotlin.multiplatform'
66
apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
77
apply from: rootProject.file("gradle/compile-common.gradle")
8+
9+
if (rootProject.ext.native_targets_enabled) {
10+
apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
11+
}
12+
813
apply from: rootProject.file("gradle/compile-js-multiplatform.gradle")
9-
apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
1014
apply from: rootProject.file('gradle/publish-npm-js.gradle')
1115

1216
/* ==========================================================================
@@ -52,8 +56,11 @@ static boolean isNativeDarwin(String name) { return ["ios", "macos", "tvos", "wa
5256
static boolean isNativeOther(String name) { return ["linux", "mingw"].any { name.startsWith(it) } }
5357

5458
defineSourceSet("concurrent", ["common"]) { it in ["jvm", "native"] }
55-
defineSourceSet("nativeDarwin", ["native"]) { isNativeDarwin(it) }
56-
defineSourceSet("nativeOther", ["native"]) { isNativeOther(it) }
59+
60+
if (rootProject.ext.native_targets_enabled) {
61+
defineSourceSet("nativeDarwin", ["native"]) { isNativeDarwin(it) }
62+
defineSourceSet("nativeOther", ["native"]) { isNativeOther(it) }
63+
}
5764

5865
/* ========================================================================== */
5966

@@ -129,7 +136,7 @@ def configureNativeSourceSetPreset(name, preset) {
129136
}
130137

131138
// :KLUDGE: Idea.active: Configure platform libraries for native source sets when working in IDEA
132-
if (Idea.active) {
139+
if (Idea.active && rootProject.ext.native_targets_enabled) {
133140
def manager = project.ext.hostManager
134141
def linuxPreset = kotlin.presets.linuxX64
135142
def macosPreset = kotlin.presets.macosX64

0 commit comments

Comments
 (0)