Skip to content

Commit

Permalink
Ensure iOS publication is referenced in the .module multiplaform even…
Browse files Browse the repository at this point in the history
… when deployed from linux or windows (#1914)
  • Loading branch information
soywiz committed Oct 4, 2023
1 parent 5dc81ed commit 754c36a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/TEST.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ jobs:
- { name: Testing JVM, run: "./gradlew --stacktrace --parallel jvmTest", env: { EGL_LOG_LEVEL: debug, LIBGL_DEBUG: verbose, LIBGL_ALWAYS_SOFTWARE: true, MESA_DEBUG: true } }
- { name: Archive Test Results, if: failure(), uses: actions/upload-artifact@v3, with: { name: screenshot-test-results-linux, retention-days: 21, path: "**/build/reports", if-no-files-found: ignore } }
- { name: Check sandbox compiles, run: "./gradlew :korge-sandbox:jvmJar" }
- { name: Publish to maven local, run: ./gradlew --parallel publishJvmLocal }
- { name: Publish to maven local, run: ./gradlew --parallel publishJvmLocal publishKotlinMultiplatformPublicationToMavenLocal }
- { name: e2e test, working-directory: e2e/e2e-test, run: ./gradlew checkReferencesJvm --stacktrace }
- { name: Archive E2E Test Results, if: failure(), uses: actions/upload-artifact@v3, with: { name: e2e-test-results-linux-jvm, retention-days: 21, path: "**/e2e/e2e-test/build/screenshots", if-no-files-found: ignore } }
- { name: e2e multi test and hotreload, working-directory: e2e/e2e-test-multi, run: "./gradlew --watch-fs --warn --configuration-cache --configuration-cache-problems=warn compileKotlinJvm" }
- { name: Check publication includes iOS, run: ./gradlew checkModulePublication }

test-jvm-macos:
needs: changes
Expand Down
18 changes: 16 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@


plugins {
//id "com.dorongold.task-tree" version "2.1.1"
// ./gradlew :kds:compileKotlinJs taskTree
}

korlibs.root.RootKorlibsPlugin.doInit(rootProject)

// Used to verify we are publishing with iOS references even if we do the publishing from another machine like windows or linux
tasks {
val checkModulePublication by creating {
doLast {
val publishedKorgeModule = File("${System.getProperty("user.home")}/.m2/repository/com/soywiz/korge/korge/999.0.0.999/korge-999.0.0.999.module")
val publishedKorgeModuleText = publishedKorgeModule.readText()
for (ref in listOf("jvmApiElements", "jsApiElements", "android", "iosArm64")) {
check (ref in publishedKorgeModuleText) {
System.err.println(publishedKorgeModuleText)
"Can't find '$ref' on the published '$publishedKorgeModule'"
}
}
}
}
}
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/korlibs/NativeTools.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package korlibs

import korlibs.korge.gradle.targets.*
import korlibs.modules.*
import org.gradle.api.*

object NativeTools {
@JvmStatic
fun configureAllCInterop(project: Project, name: String) {
if (project.doEnableKotlinNative) {
if (supportKotlinNative) {
project.kotlin {
for (target in allNativeTargets(project)) {
target.compilations["main"].cinterops {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ open class KorgeExtension(
*/
fun targetIos() {
target("ios") {
if (isMacos && supportKotlinNative) {
if (supportKotlinNative) {
project.configureNativeIos(projectType)
}
}
Expand Down Expand Up @@ -382,7 +382,7 @@ open class KorgeExtension(
var authorEmail = "unknown@unknown"
var authorHref = "http://localhost"

val nativeEnabled = project.supportKotlinNative
val nativeEnabled = supportKotlinNative

val newDesktopEnabled get() = project.findProperty("korge.enable.desktop") == "true" || System.getenv("KORGE_ENABLE_DESKTOP") == "true"
val newAndroidEnabled get() = project.findProperty("korge.enable.android") == "true" || System.getenv("KORGE_ENABLE_ANDROID") == "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import org.apache.tools.ant.taskdefs.condition.*
import org.gradle.api.*
import org.jetbrains.kotlin.gradle.plugin.*

// Only mac has ios/tvos targets but since CI exports multiplatform on linux
val supportKotlinNative: Boolean get() {
// Linux and Windows ARM hosts doesn't have K/N toolchains
if ((isLinux || isWindows) && isArm) return false
return true
if (isArm && (isLinux || isWindows)) return false
// We can also try to disable it manually
if (System.getenv("DISABLE_KOTLIN_NATIVE") == "true") return false
// On Mac, CI or when FORCE_ENABLE_KOTLIN_NATIVE=true, let's enable it
return isMacos || (System.getenv("CI") == "true") || (System.getenv("FORCE_ENABLE_KOTLIN_NATIVE") == "true")
}

val isWindows get() = Os.isFamily(Os.FAMILY_WINDOWS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
package korlibs.korge.gradle.targets.desktop

import korlibs.korge.gradle.gkotlin
import korlibs.korge.gradle.korge
import korlibs.korge.gradle.kotlin
import korlibs.korge.gradle.targets.isArm
import korlibs.korge.gradle.targets.isLinux
import korlibs.korge.gradle.targets.isMacos
import korlibs.korge.gradle.targets.isWindows
import korlibs.korge.gradle.util.Indenter
import korlibs.korge.gradle.util.createOnce
import org.gradle.api.Project
import org.gradle.api.Task
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinNativeTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTestsPreset
import java.io.File
import korlibs.korge.gradle.*
import korlibs.korge.gradle.util.*
import org.gradle.api.*
import java.io.*

val Project.prepareKotlinNativeBootstrap: Task get() = tasks.createOnce("prepareKotlinNativeBootstrap") {
val output = nativeDesktopBootstrapFile
Expand Down
5 changes: 1 addition & 4 deletions buildSrc/src/main/kotlin/korlibs/modules/Targets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import org.gradle.api.*
import korlibs.korge.gradle.targets.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*

// Only mac has ios/tvos targets
val Project.supportKotlinNative: Boolean get() = isMacos && System.getenv("DISABLE_KOTLIN_NATIVE") != "true"

val Project.doEnableKotlinNative: Boolean get() = supportKotlinNative
val Project.doEnableKotlinAndroid: Boolean get() = rootProject.findProperty("enableKotlinAndroid") == "true" && System.getenv("DISABLE_KOTLIN_ANDROID") != "true"
val Project.doEnableKotlinMobile: Boolean get() = doEnableKotlinNative && rootProject.findProperty("enableKotlinMobile") == "true"
val Project.doEnableKotlinMobile: Boolean get() = supportKotlinNative && rootProject.findProperty("enableKotlinMobile") == "true"
val Project.doEnableKotlinMobileTvos: Boolean get() = doEnableKotlinMobile && rootProject.findProperty("enableKotlinMobileTvos") == "true"

val Project.hasAndroid get() = extensions.findByName("android") != null
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/korlibs/root/RootKorlibsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object RootKorlibsPlugin {
project.configureAndroidDirect(ProjectType.fromExecutable(isSample), isKorge = false)
}

if (isSample && doEnableKotlinNative && isMacos) {
if (isSample && supportKotlinNative && isMacos) {
project.configureNativeIos(projectType = ProjectType.EXECUTABLE)
}

Expand Down Expand Up @@ -427,7 +427,7 @@ object RootKorlibsPlugin {
}
}

if (doEnableKotlinNative) {
if (supportKotlinNative) {
val native by lazy { createPairSourceSet("native", concurrent) }
val posix by lazy { createPairSourceSet("posix", native) }
val darwin by lazy { createPairSourceSet("darwin", posix) }
Expand Down

0 comments on commit 754c36a

Please sign in to comment.