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

Make directory structure follow Amper conventions #2044

Merged
merged 2 commits into from
Nov 26, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
92 changes: 46 additions & 46 deletions .github/workflows/TEST.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,62 +50,62 @@ jobs:
- '**/settings.gradle.kts'
- '**/buildSrc/**'
- '**/gradle/**'
- '**/src/common*/**'
- '**/test/common*/**'
- '**/src/**'
- '**/test/**'
jvm:
- '**/src/jvm*/**'
- '**/src/concurrent*/**'
- '**/test/jvm*/**'
- '**/test/concurrent*/**'
- '**/src@jvm*/**'
- '**/src@concurrent*/**'
- '**/test@jvm*/**'
- '**/test@concurrent*/**'
android:
- '**/AndroidManifest.xml'
- '**/src/android*/**'
- '**/src/jvmAndroid*/**'
- '**/src/concurrent*/**'
- '**/src/main/**'
- '**/test/android*/**'
- '**/test/jvmAndroid*/**'
- '**/test/concurrent*/**'
- '**/test/main/**'
- '**/src@android*/**'
- '**/src@jvmAndroid*/**'
- '**/src@concurrent*/**'
- '**/src@main/**'
- '**/test@android*/**'
- '**/test@jvmAndroid*/**'
- '**/test@concurrent*/**'
- '**/test@main/**'
js:
- '**/src/js*/**'
- '**/test/js*/**'
- '**/src@js*/**'
- '**/test@js*/**'
wasm:
- '**/src/wasm*/**'
- '**/test/wasm*/**'
- '**/src@wasm*/**'
- '**/test@wasm*/**'
native:
- '**/src/native*/**'
- '**/src/concurrent*/**'
- '**/test/native*/**'
- '**/test/concurrent*/**'
- '**/src@native*/**'
- '**/src@concurrent*/**'
- '**/test@native*/**'
- '**/test@concurrent*/**'
windows:
- '**/src/mingw*/**'
- '**/test/mingw*/**'
- '**/src@mingw*/**'
- '**/test@mingw*/**'
linux:
- '**/src/linux*/**'
- '**/src/posix*/**'
- '**/test/linux*/**'
- '**/test/posix*/**'
- '**/src@linux*/**'
- '**/src@posix*/**'
- '**/test@linux*/**'
- '**/test@posix*/**'
macos:
- '**/src/apple*/**'
- '**/src/macos*/**'
- '**/src/darwin*/**'
- '**/src/posix*/**'
- '**/test/apple*/**'
- '**/test/macos*/**'
- '**/test/darwin*/**'
- '**/test/posix*/**'
- '**/src@apple*/**'
- '**/src@macos*/**'
- '**/src@darwin*/**'
- '**/src@posix*/**'
- '**/test@apple*/**'
- '**/test@macos*/**'
- '**/test@darwin*/**'
- '**/test@posix*/**'
ios:
- '**/src/apple*/**'
- '**/src/ios*/**'
- '**/src/tvos*/**'
- '**/src/darwin*/**'
- '**/src/posix*/**'
- '**/test/apple*/**'
- '**/test/ios*/**'
- '**/test/tvos*/**'
- '**/test/darwin*/**'
- '**/test/posix*/**'
- '**/src@apple*/**'
- '**/src@ios*/**'
- '**/src@tvos*/**'
- '**/src@darwin*/**'
- '**/src@posix*/**'
- '**/test@apple*/**'
- '**/test@ios*/**'
- '**/test@tvos*/**'
- '**/test@darwin*/**'
- '**/test@posix*/**'
test-docs:
needs: changes
if: ${{ needs.changes.outputs.testDocs == 'true' }}
Expand Down
24 changes: 12 additions & 12 deletions buildSrc/src/main/kotlin/korlibs/korge/gradle/targets/SourceSets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ open class ExKotlinSourceSetContainer(val project: Project) {
val kotlin = project.kotlin
val sourceSets = kotlin.sourceSets

val common by lazy { sourceSets.createPairSourceSet("common") }
val nonJs by lazy { sourceSets.createPairSourceSet("nonJs", common) }
val concurrent by lazy { sourceSets.createPairSourceSet("concurrent", common) }
val common by lazy { sourceSets.createPairSourceSet("common", project = project) }
val nonJs by lazy { sourceSets.createPairSourceSet("nonJs", common, project = project) }
val concurrent by lazy { sourceSets.createPairSourceSet("concurrent", common, project = project) }

// JS
val js by lazy { sourceSets.createPairSourceSet("js", common) }
val js by lazy { sourceSets.createPairSourceSet("js", common, project = project) }

// JVM
val jvm by lazy { sourceSets.createPairSourceSet("jvm", concurrent, nonJs) }
val jvm by lazy { sourceSets.createPairSourceSet("jvm", concurrent, nonJs, project = project) }

// Native
val native by lazy { sourceSets.createPairSourceSet("native", concurrent, nonJs) }
val posix by lazy { sourceSets.createPairSourceSet("posix", native) }
val darwin by lazy { sourceSets.createPairSourceSet("darwin", posix) }
val darwinMobile by lazy { sourceSets.createPairSourceSet("darwinMobile", darwin) }
val iosTvos by lazy { sourceSets.createPairSourceSet("iosTvos", darwinMobile/*, iosTvosMacos*/) }
val tvos by lazy { sourceSets.createPairSourceSet("tvos", iosTvos) }
val ios by lazy { sourceSets.createPairSourceSet("ios", iosTvos/*, iosMacos*/) }
val native by lazy { sourceSets.createPairSourceSet("native", concurrent, nonJs, project = project) }
val posix by lazy { sourceSets.createPairSourceSet("posix", native, project = project) }
val darwin by lazy { sourceSets.createPairSourceSet("darwin", posix, project = project) }
val darwinMobile by lazy { sourceSets.createPairSourceSet("darwinMobile", darwin, project = project) }
val iosTvos by lazy { sourceSets.createPairSourceSet("iosTvos", darwinMobile/*, iosTvosMacos*/, project = project) }
val tvos by lazy { sourceSets.createPairSourceSet("tvos", iosTvos, project = project) }
val ios by lazy { sourceSets.createPairSourceSet("ios", iosTvos/*, iosMacos*/, project = project) }
}

31 changes: 25 additions & 6 deletions buildSrc/src/main/kotlin/korlibs/korge/gradle/targets/Targets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package korlibs.korge.gradle.targets
import org.apache.tools.ant.taskdefs.condition.*
import org.gradle.api.*
import org.jetbrains.kotlin.gradle.plugin.*
import java.io.*

// Only mac has ios/tvos targets but since CI exports multiplatform on linux
val supportKotlinNative: Boolean get() {
Expand All @@ -23,15 +24,33 @@ val inCI: Boolean get() = !System.getenv("CI").isNullOrBlank() || !System.getPro
val KotlinTarget.isIos get() = name.startsWith("ios")
val KotlinTarget.isTvos get() = name.startsWith("tvos")

fun NamedDomainObjectContainer<KotlinSourceSet>.createPairSourceSet(name: String, vararg dependencies: PairSourceSet, doTest: Boolean = true, block: KotlinSourceSet.(test: Boolean) -> Unit = { }): PairSourceSet {
fun NamedDomainObjectContainer<KotlinSourceSet>.createPairSourceSet(
name: String,
vararg dependencies: PairSourceSet, doTest: Boolean = true,
project: Project? = null,
block: KotlinSourceSet.(test: Boolean) -> Unit = { }
): PairSourceSet {
val main = maybeCreate("${name}Main").apply { block(false) }
val test = if (doTest) maybeCreate("${name}Test").apply { block(true) } else null

main.kotlin.srcDirs(listOf("src/$name"))
if (name == "common") main.resources.srcDirs(listOf("srcresources"))
if (test != null) {
test.kotlin.srcDirs(listOf("test/$name"))
if (name == "common") test.resources.srcDirs(listOf("testresources"))
val newVariant = if (project?.projectDir != null) !File(project.projectDir, "src/commonMain").isDirectory else false

if (newVariant) {
if (name == "common") {
main.kotlin.srcDirs(listOf("src"))
main.resources.srcDirs(listOf("resources"))
} else {
main.kotlin.srcDirs(listOf("src@$name"))
}
if (test != null) {
//test.kotlin.srcDirs(listOf("test/$name"))
if (name == "common") {
test.kotlin.srcDirs(listOf("test"))
test.resources.srcDirs(listOf("testresources"))
} else {
test.kotlin.srcDirs(listOf("test@$name"))
}
}
}

return PairSourceSet(main, test).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fun Project.configureNativeIos(projectType: ProjectType) {
this.project.kotlin.apply {
sourceSets.apply {
for (target in listOf(iosArm64(), iosX64(), iosSimulatorArm64(), tvosArm64(), tvosX64(), tvosSimulatorArm64())) {
val native = createPairSourceSet(target.name)
val native = createPairSourceSet(target.name, project = project)
when {
target.isIos -> native.dependsOn(exKotlinSourceSetContainer.ios)
target.isTvos -> native.dependsOn(exKotlinSourceSetContainer.tvos)
Expand Down
30 changes: 15 additions & 15 deletions buildSrc/src/main/kotlin/korlibs/root/RootKorlibsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ object RootKorlibsPlugin {
// nonNative: [js, jvmAndroid]
sourceSets.apply {

val common = createPairSourceSet("common") { test ->
val common = createPairSourceSet("common", project = project) { test ->
dependencies {
if (test) {
implementation(kotlin("test-common"))
Expand All @@ -383,12 +383,12 @@ object RootKorlibsPlugin {
}
}

val concurrent = createPairSourceSet("concurrent", common)
val jvmAndroid = createPairSourceSet("jvmAndroid", concurrent)
val concurrent = createPairSourceSet("concurrent", common, project = project)
val jvmAndroid = createPairSourceSet("jvmAndroid", concurrent, project = project)

// Default source set for JVM-specific sources and dependencies:
// JVM-specific tests and their dependencies:
val jvm = createPairSourceSet("jvm", jvmAndroid) { test ->
val jvm = createPairSourceSet("jvm", jvmAndroid, project = project) { test ->
dependencies {
if (test) {
implementation(kotlin("test-junit"))
Expand All @@ -399,7 +399,7 @@ object RootKorlibsPlugin {
}

if (hasAndroid) {
val android = createPairSourceSet("android", jvmAndroid, doTest = false) { test ->
val android = createPairSourceSet("android", jvmAndroid, doTest = false, project = project) { test ->
dependencies {
if (test) {
//implementation(kotlin("test"))
Expand All @@ -413,7 +413,7 @@ object RootKorlibsPlugin {
}
}

val js = createPairSourceSet("js", common) { test ->
val js = createPairSourceSet("js", common, project = project) { test ->
dependencies {
if (test) {
implementation(kotlin("test-js"))
Expand All @@ -424,7 +424,7 @@ object RootKorlibsPlugin {
}

if (isWasmEnabled(project)) {
val wasm = createPairSourceSet("wasmJs", common) { test ->
val wasm = createPairSourceSet("wasmJs", common, project = project) { test ->
dependencies {
if (test) {
implementation(kotlin("test-wasm-js"))
Expand All @@ -443,16 +443,16 @@ object RootKorlibsPlugin {
//val macos by lazy { createPairSourceSet("macos", iosMacos) }
//val mingw by lazy { createPairSourceSet("mingw", native) }

val native by lazy { createPairSourceSet("native", concurrent) }
val posix by lazy { createPairSourceSet("posix", native) }
val darwin by lazy { createPairSourceSet("darwin", posix) }
val darwinMobile by lazy { createPairSourceSet("darwinMobile", darwin) }
val iosTvos by lazy { createPairSourceSet("iosTvos", darwinMobile/*, iosTvosMacos*/) }
val tvos by lazy { createPairSourceSet("tvos", iosTvos) }
val ios by lazy { createPairSourceSet("ios", iosTvos/*, iosMacos*/) }
val native by lazy { createPairSourceSet("native", concurrent, project = project) }
val posix by lazy { createPairSourceSet("posix", native, project = project) }
val darwin by lazy { createPairSourceSet("darwin", posix, project = project) }
val darwinMobile by lazy { createPairSourceSet("darwinMobile", darwin, project = project) }
val iosTvos by lazy { createPairSourceSet("iosTvos", darwinMobile/*, iosTvosMacos*/, project = project) }
val tvos by lazy { createPairSourceSet("tvos", iosTvos, project = project) }
val ios by lazy { createPairSourceSet("ios", iosTvos/*, iosMacos*/, project = project) }

for (target in mobileTargets(project)) {
val native = createPairSourceSet(target.name)
val native = createPairSourceSet(target.name, project = project)
when {
target.isIos -> native.dependsOn(ios)
target.isTvos -> native.dependsOn(tvos)
Expand Down
Loading
Loading