Skip to content

Commit

Permalink
Fix duplicatge symbols with gradle instead of manual copy-pasting (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Sep 3, 2024
1 parent 32bcf0e commit 9b7197c
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 324 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ jobs:
- os: ubuntu-latest
EXTRA_GRADLE_ARGS: apiCheck :test:proguard:r8jar
- os: macos-latest
EXTRA_GRADLE_ARGS: :mordant:compileKotlinMetadata
EXTRA_GRADLE_ARGS: >-
:mordant:compileNativeMainKotlinMetadata
:mordant:compilePosixMainKotlinMetadata
:mordant:compileAppleMainKotlinMetadata
:mordant:compileMacosMainKotlinMetadata
:mordant:compileWatchosMainKotlinMetadata
:mordant:compileTvosMainKotlinMetadata
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ kotlin {
tvosX64()
tvosArm64()
tvosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosX64()
watchosSimulatorArm64()

sourceSets {
for (target in listOf(
"tvosX64", "tvosArm64", "tvosSimulatorArm64",
"watchosArm32", "watchosArm64", "watchosX64", "watchosSimulatorArm64",
)) {
sourceSets.getByName(target + "Main").kotlin.srcDirs("src/posixSharedMain/kotlin")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ kotlin {
// Not all targets are supported by the markdown library
// tvosX64()
// tvosArm64()
tvosSimulatorArm64()
// tvosSimulatorArm64()
// watchosArm32()
// watchosArm64()
// watchosDeviceArm64()
// watchosX64()
watchosSimulatorArm64()
// watchosSimulatorArm64()

applyDefaultHierarchyTemplate()

Expand All @@ -33,5 +33,15 @@ kotlin {
for (target in listOf(iosMain, tvosMain, watchosMain)) {
target.get().dependsOn(appleNonDesktopMain)
}
// Kotlin 2.0 changed the way MPP is compiled, so instead of copying shared sources to each
// target, it compiles intermediate sources separately. That means that code that previously
// compiled is broken due to errors like "declaration is using numbers with different bit
// widths". So we copy the shared sources to each target manually.
for (target in listOf(
"linuxX64", "linuxArm64",
"macosX64", "macosArm64",
)) {
sourceSets.getByName(target + "Main").kotlin.srcDirs("src/posixSharedMain/kotlin")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
package com.github.ajalt.mordant.internal

import com.github.ajalt.mordant.terminal.TerminalInterface
import com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeCopyPasted

internal actual fun testsHaveFileSystem(): Boolean = true
internal actual fun getStandardTerminalInterface(): TerminalInterface {
return TerminalInterfaceNativeCopyPasted()
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.ajalt.mordant.internal

import com.github.ajalt.mordant.terminal.TerminalInterface
import com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeCopyPasted
import com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeShared

internal actual fun getStandardTerminalInterface(): TerminalInterface {
return TerminalInterfaceNativeCopyPasted()
return TerminalInterfaceNativeShared()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import platform.posix.*
// they have different bit widths for some fields, so the compileMetadata task fails if we don't use
// separate files. Hopefully some day there will be solution that doesn't require copy-pasting.

internal class TerminalInterfaceNativeCopyPasted : TerminalInterfaceNativePosix() {
internal class TerminalInterfaceNativeShared : TerminalInterfaceNativePosix() {
override val termiosConstants: TermiosConstants = TermiosConstants(
VTIME = VTIME,
VMIN = VMIN,
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9b7197c

Please sign in to comment.