@@ -53,7 +53,7 @@ allprojects {
53
53
}
54
54
}
55
55
56
- // true when on CI, and false when local dev. Needed for native build configuration
56
+ // true when on CI, and false when local dev. Needed for build configuration
57
57
val ciRun = System .getenv(" CI" ) == " true"
58
58
59
59
// configure main host, for which jvm and js tests are enabled, true if locally, or linux on CI
@@ -62,7 +62,7 @@ val isMainHost: Boolean = !ciRun || HostManager.hostIsLinux
62
62
// can be: macos, ios, watchos, tvos. If provided, compile and test only those targets
63
63
val macTargetsCompilation: String? by project
64
64
65
- println (" Configuration: CI= ${ System .getenv( " CI " )} , ciRun=$ciRun , isMainHost=$isMainHost , macTargetsCompilation=$macTargetsCompilation " )
65
+ println (" Configuration: ciRun=$ciRun , isMainHost=$isMainHost , macTargetsCompilation=$macTargetsCompilation " )
66
66
67
67
val Project .publicationNames: Array <String >
68
68
get() {
@@ -125,55 +125,55 @@ subprojects {
125
125
}
126
126
127
127
// native targets configuration
128
- if (ciRun) {
129
- fun KotlinNativeTarget.disableCompilation () {
130
- compilations.all { compileKotlinTask.enabled = false }
131
- binaries.all { linkTask.enabled = false }
132
- }
128
+ val hostTargets = listOfNotNull(linuxX64(), macosX64(), if (supportMingw) mingwX64() else null )
133
129
134
- val hostTargets = listOfNotNull(linuxX64(), macosX64(), if (supportMingw) mingwX64() else null )
130
+ val iosTargets = listOf (iosArm32(), iosArm64(), iosX64())
131
+ val tvosTargets = listOf (tvosArm64(), tvosX64())
132
+ val watchosTargets = listOf (watchosArm32(), watchosArm64(), watchosX86())
133
+ val nativeTargets = hostTargets + iosTargets + tvosTargets + watchosTargets
135
134
136
- val iosTargets = listOf (iosArm32(), iosArm64(), iosX64())
137
- val tvosTargets = listOf (tvosArm64(), tvosX64())
138
- val watchosTargets = listOf (watchosArm32(), watchosArm64(), watchosX86())
139
- val nativeTargets = hostTargets + iosTargets + tvosTargets + watchosTargets
135
+ val nativeMain by sourceSets.creating {
136
+ dependsOn(sourceSets[" commonMain" ])
137
+ }
138
+ val nativeTest by sourceSets.creating {
139
+ dependsOn(sourceSets[" commonTest" ])
140
+ }
140
141
141
- val nativeMain by sourceSets.creating {
142
- dependsOn(sourceSets[" commonMain" ])
143
- }
144
- val nativeTest by sourceSets.creating {
145
- dependsOn(sourceSets[" commonTest" ])
146
- }
142
+ nativeTargets.forEach {
143
+ sourceSets[" ${it.name} Main" ].dependsOn(nativeMain)
144
+ sourceSets[" ${it.name} Test" ].dependsOn(nativeTest)
145
+ }
147
146
148
- nativeTargets.forEach {
149
- sourceSets[ " ${it.name} Main " ].dependsOn(nativeMain)
150
- sourceSets[ " ${it.name} Test " ].dependsOn(nativeTest)
151
- }
147
+ fun KotlinNativeTarget. disableCompilation () {
148
+ compilations.all { compileKotlinTask.enabled = false }
149
+ binaries.all { linkTask.enabled = false }
150
+ }
152
151
153
- // disable cross compilation of linux target on non linux hosts
154
- if (! HostManager .hostIsLinux) linuxX64().disableCompilation()
155
-
156
- // disable compilation of part of mac targets
157
- if (HostManager .hostIsMac) when (macTargetsCompilation) {
158
- " macos" -> iosTargets + tvosTargets + watchosTargets
159
- " ios" , " watchos" , " tvos" -> {
160
- // disable test compilation for macos, but leave main to compile examples and playground
161
- macosX64 {
162
- compilations.all { if (name == " test" ) compileKotlinTask.enabled = false }
163
- binaries.all { linkTask.enabled = false }
164
- }
165
- when (macTargetsCompilation) {
166
- " ios" -> tvosTargets + watchosTargets
167
- " watchos" -> iosTargets + tvosTargets
168
- " tvos" -> iosTargets + watchosTargets
169
- else -> emptyList()
170
- }
152
+ // disable cross compilation of linux target on non linux hosts
153
+ if (! HostManager .hostIsLinux) linuxX64().disableCompilation()
154
+
155
+ // disable compilation of part of mac targets
156
+ if (HostManager .hostIsMac) when (macTargetsCompilation) {
157
+ " macos" -> iosTargets + tvosTargets + watchosTargets
158
+ " ios" , " watchos" , " tvos" -> {
159
+ // disable test compilation for macos, but leave main to compile examples and playground
160
+ macosX64 {
161
+ compilations.all { if (name == " test" ) compileKotlinTask.enabled = false }
162
+ binaries.all { linkTask.enabled = false }
163
+ }
164
+ when (macTargetsCompilation) {
165
+ " ios" -> tvosTargets + watchosTargets
166
+ " watchos" -> iosTargets + tvosTargets
167
+ " tvos" -> iosTargets + watchosTargets
168
+ else -> emptyList()
171
169
}
172
- else -> emptyList()
173
- }.forEach(KotlinNativeTarget ::disableCompilation)
170
+ }
171
+ else -> emptyList()
172
+ }.forEach(KotlinNativeTarget ::disableCompilation)
174
173
175
- // run tests on release + mimalloc to reduce tests execution time
176
- // compilation is slower in that mode, but work with buffers is much faster
174
+ // run tests on release + mimalloc to reduce tests execution time
175
+ // compilation is slower in that mode, but work with buffers is much faster
176
+ if (ciRun) {
177
177
targets.all {
178
178
if (this is KotlinNativeTargetWithTests <* >) {
179
179
binaries.test(listOf (RELEASE ))
@@ -183,13 +183,6 @@ subprojects {
183
183
}
184
184
}
185
185
}
186
- } else {
187
- // if not on CI, use only one native target same as host, DON'T PUBLISH IN THAT MODE LOCALLY!!!
188
- when {
189
- HostManager .hostIsLinux -> linuxX64(" native" )
190
- HostManager .hostIsMingw && supportMingw -> mingwX64(" native" )
191
- HostManager .hostIsMac -> macosX64(" native" )
192
- }
193
186
}
194
187
}
195
188
0 commit comments