mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-02 13:20:14 +08:00
[build] Disable KotlinNativeLink by default. Can be enabled by -Dmirai.native.link=true
This commit is contained in:
parent
9540bc95c5
commit
9f7face6eb
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -134,7 +134,7 @@ jobs:
|
|||||||
# FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
|
# FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
|
||||||
# > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
|
# > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
|
||||||
enableLocalPublishingTest: 'false'
|
enableLocalPublishingTest: 'false'
|
||||||
gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8"
|
gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};~other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m" "-Dfile.encoding=UTF-8"
|
||||||
isMac: ${{ startsWith(matrix.os, 'macos') }}
|
isMac: ${{ startsWith(matrix.os, 'macos') }}
|
||||||
isWindows: ${{ startsWith(matrix.os, 'windows') }}
|
isWindows: ${{ startsWith(matrix.os, 'windows') }}
|
||||||
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
|
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
|
||||||
|
@ -19,10 +19,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPI
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
val MIRAI_PLATFORM_ATTRIBUTE = Attribute.of(
|
val MIRAI_PLATFORM_ATTRIBUTE = Attribute.of(
|
||||||
@ -374,6 +372,14 @@ fun KotlinMultiplatformExtension.configureNativeTargetsHierarchical(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinMultiplatformExtension.configureNativeTargetBinaries(project: Project) {
|
fun KotlinMultiplatformExtension.configureNativeTargetBinaries(project: Project) {
|
||||||
|
if (!System.getProperty("mirai.native.link", "false").toBoolean()) {
|
||||||
|
// Must enable KotlinNativeLink by argument "mirai.native.link".
|
||||||
|
|
||||||
|
// :mirai-core:linkReleaseSharedMacosX64
|
||||||
|
return
|
||||||
|
// disableNativeLinkTasks(project)
|
||||||
|
}
|
||||||
|
|
||||||
NATIVE_TARGETS.forEach { targetName ->
|
NATIVE_TARGETS.forEach { targetName ->
|
||||||
val target = targets.getByName(targetName) as KotlinNativeTarget
|
val target = targets.getByName(targetName) as KotlinNativeTarget
|
||||||
target.binaries {
|
target.binaries {
|
||||||
@ -387,6 +393,15 @@ fun KotlinMultiplatformExtension.configureNativeTargetBinaries(project: Project)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disableNativeLinkTasks(project: Project) {
|
||||||
|
project.tasks.withType<KotlinNativeLink>()
|
||||||
|
.filter { it.binary.outputKind != NativeOutputKind.TEST }
|
||||||
|
.forEach {
|
||||||
|
it.enabled = false
|
||||||
|
project.logger.warn("Disabling KotlinNativeLink: ${it.path}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun KotlinNativeTarget.findOrCreateTest(buildType: NativeBuildType, configure: TestExecutable.() -> Unit) =
|
private fun KotlinNativeTarget.findOrCreateTest(buildType: NativeBuildType, configure: TestExecutable.() -> Unit) =
|
||||||
binaries.findTest(buildType)?.apply(configure) ?: binaries.test(listOf(buildType), configure)
|
binaries.findTest(buildType)?.apply(configure) ?: binaries.test(listOf(buildType), configure)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user