Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-5753: Enable linuxArm64 builds #3587

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/IdeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.jetbrains.kotlin.konan.target.*

fun KotlinMultiplatformExtension.ideaTarget(): KotlinNativeTarget = when (HostManager.host) {
is KonanTarget.LINUX_X64 -> linuxX64()
is KonanTarget.LINUX_ARM64 -> linuxArm64()
is KonanTarget.MACOS_X64 -> macosX64()
is KonanTarget.MACOS_ARM64 -> macosArm64()
is KonanTarget.MINGW_X64 -> mingwX64()
Expand Down
12 changes: 11 additions & 1 deletion buildSrc/src/main/kotlin/NativeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ fun Project.posixTargets(): List<String> = fastOr {
}

fun Project.nixTargets(): List<String> = fastOr {
darwinTargets() + kotlin.linuxX64().name
darwinTargets() + linuxTargets()
}

fun Project.linuxTargets(): List<String> = fastOr {
with(kotlin) {
listOf (
linuxX64(),
linuxArm64(),
)
}.map { it.name }
}

fun Project.darwinTargets(): List<String> = fastOr {
Expand Down Expand Up @@ -71,6 +80,7 @@ fun Project.desktopTargets(): List<String> = fastOr {
macosX64(),
macosArm64(),
linuxX64(),
linuxArm64(),
mingwX64()
).map { it.name }
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Publication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun isAvailableForPublication(publication: Publication): Boolean {
"kotlinMultiplatform"
)
result = result || name in jvmAndCommon
result = result || (HOST_NAME == "linux" && name == "linuxX64")
result = result || (HOST_NAME == "linux" && (name == "linuxX64" || name == "linuxArm64"))
result = result || (HOST_NAME == "windows" && name == "mingwX64")
val macPublications = setOf(
"iosX64",
Expand Down
30 changes: 28 additions & 2 deletions buildSrc/src/main/kotlin/TargetsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ val Project.hasJvmAndNix: Boolean get() = hasCommon || files.any { it.name == "j
val Project.hasPosix: Boolean get() = hasCommon || files.any { it.name == "posix" }
val Project.hasDesktop: Boolean get() = hasPosix || files.any { it.name == "desktop" }
val Project.hasNix: Boolean get() = hasPosix || hasJvmAndNix || files.any { it.name == "nix" }
val Project.hasLinux: Boolean get() = hasNix || files.any { it.name == "linux" }
val Project.hasDarwin: Boolean get() = hasNix || files.any { it.name == "darwin" }
val Project.hasWindows: Boolean get() = hasPosix || files.any { it.name == "windows" }
val Project.hasJs: Boolean get() = hasCommon || files.any { it.name == "js" }
val Project.hasJvm: Boolean get() = hasCommon || hasJvmAndNix || files.any { it.name == "jvm" }
val Project.hasNative: Boolean get() = hasCommon || hasNix || hasPosix || hasDarwin || hasDesktop || hasWindows
val Project.hasNative: Boolean get() = hasCommon || hasNix || hasPosix || hasLinux || hasDarwin || hasDesktop || hasWindows

fun Project.configureTargets() {
configureCommon()
Expand All @@ -37,7 +38,7 @@ fun Project.configureTargets() {
configureJs()
}

if (hasPosix || hasDarwin || hasWindows) extra.set("hasNative", true)
if (hasPosix || hasLinux || hasDarwin || hasWindows) extra.set("hasNative", true)

sourceSets {
if (hasPosix) {
Expand Down Expand Up @@ -80,6 +81,11 @@ fun Project.configureTargets() {
}
}

if (hasLinux) {
val linuxMain by creating
val linuxTest by creating
}

if (hasWindows) {
val windowsMain by creating
val windowsTest by creating
Expand Down Expand Up @@ -186,6 +192,25 @@ fun Project.configureTargets() {
}
}

if (hasLinux) {
val linuxMain by getting {
findByName("nixMain")?.let { dependsOn(it) }
}

val linuxTest by getting {
findByName("nixTest")?.let { dependsOn(it) }

dependencies {
implementation(kotlin("test"))
}
}

linuxTargets().forEach {
getByName("${it}Main").dependsOn(linuxMain)
getByName("${it}Test").dependsOn(linuxTest)
}
}

if (hasDesktop) {
val desktopMain by getting {
findByName("posixMain")?.let { dependsOn(it) }
Expand Down Expand Up @@ -218,6 +243,7 @@ fun Project.configureTargets() {

if (hasNative) {
tasks.findByName("linkDebugTestLinuxX64")?.onlyIf { HOST_NAME == "linux" }
tasks.findByName("linkDebugTestLinuxArm64")?.onlyIf { HOST_NAME == "linux" }
tasks.findByName("linkDebugTestMingwX64")?.onlyIf { HOST_NAME == "windows" }
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kotlin.native.binary.memoryModel=experimental

kotlin_version=1.8.22
coroutines_version=1.7.1
atomicfu_version=0.20.0
atomicfu_version=0.20.2
slf4j_version=1.7.36
junit_version=4.13.2
logback_version=1.2.11
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]
kotlin-version = "1.8.22"
kotlinx-html-version = "0.8.1"
kotlinx-html-version = "0.9.1"
coroutines-version = "1.7.2"
atomicfu-version = "0.18.5"
atomicfu-version = "0.20.2"
serialization-version = "1.5.1"
validator-version = "0.8.0"
ktlint-version = "3.15.0"
Expand Down
2 changes: 1 addition & 1 deletion ktor-client/ktor-client-curl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ kotlin {
includeDirs.headerFilterOnly(paths)
}

createCInterop("libcurl", listOf("macosArm64")) {
createCInterop("libcurl", listOf("macosArm64", "linuxArm64")) {
defFile = File(projectDir, "desktop/interop/libcurl_arm64.def")
includeDirs.headerFilterOnly(paths)
}
Expand Down