Native build: make distCompiler no-op when using custom dist

Custom dist is already in place and has the compiler, so we don't have
to build and copy the compiler to dist.

Moreover, if we do copy it, it might overwrite the compiler files
already loaded by this Gradle process (including the jar loaded to the
custom classloader), causing hard-to-debug errors.

To workaround this, we disable the distCompiler task and don't add any
dependencies to it when custom dist is used.
This commit is contained in:
Svyatoslav Scherbina
2022-03-05 15:17:43 +03:00
committed by Space
parent 7470aaf06c
commit 5a1513ad59
+13 -3
View File
@@ -246,9 +246,19 @@ task shadowJar(type: ShadowJar) {
}
task distCompiler(type: Copy) {
dependsOn ":kotlin-native:dependencies:update"
dependsOn ':kotlin-native:shadowJar'
dependsOn ":kotlin-native-compiler-embeddable:kotlin-native-compiler-embeddable"
// Workaround: make distCompiler no-op if we are using custom dist:
// the dist is already in place and has the compiler, so we don't have to
// build and copy the compiler to dist.
// Moreover, if we do copy it, it might overwrite the compiler files already loaded
// by this Gradle process (including the jar loaded to the custom classloader),
// causing hard-to-debug errors.
if (!UtilsKt.isDefaultNativeHome(project)) {
enabled = false
} else {
dependsOn ":kotlin-native:dependencies:update"
dependsOn ':kotlin-native:shadowJar'
dependsOn ":kotlin-native-compiler-embeddable:kotlin-native-compiler-embeddable"
}
destinationDir distDir