|
5 | 5 | import aws.sdk.kotlin.gradle.dsl.configureLinting |
6 | 6 | import aws.sdk.kotlin.gradle.dsl.configureNexus |
7 | 7 | import aws.sdk.kotlin.gradle.util.typedProp |
8 | | -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension |
9 | | -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget |
10 | | -import org.jetbrains.kotlin.konan.target.Family |
11 | | -import org.jetbrains.kotlin.konan.target.HostManager |
12 | | -import kotlin.apply |
13 | 8 |
|
14 | 9 | buildscript { |
15 | 10 | // NOTE: buildscript classpath for the root project is the parent classloader for the subprojects, we |
@@ -159,69 +154,3 @@ apiValidation { |
159 | 154 | ), |
160 | 155 | ) |
161 | 156 | } |
162 | | - |
163 | | -val disableCrossCompile = typedProp<Boolean>("aws.kotlin.native.disableCrossCompile") == true |
164 | | - |
165 | | -if (disableCrossCompile) { |
166 | | - logger.warn("aws.kotlin.native.disableCrossCompile=true: Cross compilation is disabled.") |
167 | | - disableCrossCompileTargets() |
168 | | -} |
169 | | - |
170 | | -private val KotlinNativeTarget.isLinux: Boolean |
171 | | - get() = konanTarget.family == Family.LINUX |
172 | | - |
173 | | -private val KotlinNativeTarget.isApple: Boolean |
174 | | - get() = konanTarget.family.isAppleFamily |
175 | | - |
176 | | -private val KotlinNativeTarget.isWindows: Boolean |
177 | | - get() = konanTarget.family == Family.MINGW |
178 | | - |
179 | | -/** |
180 | | - * Kotlin/Native Linux and Windows targets are generally enabled on all hosts since |
181 | | - * the Kotlin toolchain and backend compilers support cross compilation. We |
182 | | - * are using cinterop and have to compile CRT for those platforms which sometimes |
183 | | - * requires using docker which isn't always available in CI or setup in users environment. |
184 | | - * |
185 | | - * See [KT-30498](https://youtrack.jetbrains.com/issue/KT-30498) |
186 | | - */ |
187 | | -fun Project.disableCrossCompileTargets() { |
188 | | - allprojects { |
189 | | - plugins.withId("org.jetbrains.kotlin.multiplatform") { |
190 | | - configure<KotlinMultiplatformExtension> { |
191 | | - targets.withType<KotlinNativeTarget> { |
192 | | - val knTarget = this |
193 | | - when { |
194 | | - HostManager.hostIsMac && (knTarget.isLinux || knTarget.isWindows) -> disable(knTarget) |
195 | | - HostManager.hostIsLinux && knTarget.isApple -> disable(knTarget) |
196 | | - HostManager.hostIsMingw && (knTarget.isLinux || knTarget.isApple) -> disable(knTarget) |
197 | | - } |
198 | | - } |
199 | | - } |
200 | | - } |
201 | | - } |
202 | | -} |
203 | | - |
204 | | -internal fun Project.disable(knTarget: KotlinNativeTarget) { |
205 | | - logger.warn("disabling Kotlin/Native target: ${knTarget.name}") |
206 | | - knTarget.apply { |
207 | | - compilations.all { |
208 | | - cinterops.all { |
209 | | - tasks.named(interopProcessingTaskName).configure { enabled = false } |
210 | | - } |
211 | | - compileTaskProvider.configure { enabled = false } |
212 | | - } |
213 | | - |
214 | | - binaries.all { |
215 | | - linkTaskProvider.configure { enabled = false } |
216 | | - } |
217 | | - |
218 | | - mavenPublication { |
219 | | - tasks.withType<AbstractPublishToMaven>().configureEach { |
220 | | - onlyIf { publication != this@mavenPublication } |
221 | | - } |
222 | | - tasks.withType<GenerateModuleMetadata>().configureEach { |
223 | | - onlyIf { publication != this@mavenPublication } |
224 | | - } |
225 | | - } |
226 | | - } |
227 | | -} |
0 commit comments