Skip to content

Add linuxMain source set #2007

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

Open
wants to merge 1 commit into
base: jb-main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions annotation/annotation-compatibility-stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ androidXComposeMultiplatform {
js()
wasm()
darwin()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
4 changes: 1 addition & 3 deletions annotation/annotation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ androidXComposeMultiplatform {
js()
wasm()
darwin()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
iosArm64("uikitArm64")
iosSimulatorArm64("uikitSimArm64")

val commonMain = sourceSets.getByName("commonMain")
val nativeMain = sourceSets.create("nativeMain")
val nativeMain = getOrCreateNativeMain()
val darwinMain = sourceSets.create("darwinMain")
val macosMain = sourceSets.create("macosMain")
val macosX64Main = sourceSets.getByName("macosX64Main")
Expand All @@ -200,7 +199,6 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
val uikitX64Main = sourceSets.getByName("uikitX64Main")
val uikitArm64Main = sourceSets.getByName("uikitArm64Main")
val uikitSimArm64Main = sourceSets.getByName("uikitSimArm64Main")
nativeMain.dependsOn(commonMain)
darwinMain.dependsOn(nativeMain)
macosMain.dependsOn(darwinMain)
macosX64Main.dependsOn(macosMain)
Expand All @@ -210,8 +208,7 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
uikitArm64Main.dependsOn(uikitMain)
uikitSimArm64Main.dependsOn(uikitMain)

val commonTest = sourceSets.getByName("commonTest")
val nativeTest = sourceSets.create("nativeTest")
val nativeTest = getOrCreateNativeTest()
val darwinTest = sourceSets.create("darwinTest")
val macosTest = sourceSets.create("macosTest")
val macosX64Test = sourceSets.getByName("macosX64Test")
Expand All @@ -220,7 +217,6 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
val uikitX64Test = sourceSets.getByName("uikitX64Test")
val uikitArm64Test = sourceSets.getByName("uikitArm64Test")
val uikitSimArm64Test = sourceSets.getByName("uikitSimArm64Test")
nativeTest.dependsOn(commonTest)
darwinTest.dependsOn(nativeTest)
macosTest.dependsOn(darwinTest)
macosX64Test.dependsOn(macosTest)
Expand All @@ -231,12 +227,25 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
uikitSimArm64Test.dependsOn(uikitTest)
}

override fun linuxX64(): Unit = multiplatformExtension.run {
override fun linux(): Unit = multiplatformExtension.run {
linuxX64()
}

override fun linuxArm64(): Unit = multiplatformExtension.run {
linuxArm64()

val nativeMain = getOrCreateNativeMain()
val linuxMain = sourceSets.create("linuxMain")
val linuxX64Main = sourceSets.getByName("linuxX64Main")
val linuxArm64Main = sourceSets.getByName("linuxArm64Main")
linuxMain.dependsOn(nativeMain)
linuxX64Main.dependsOn(linuxMain)
linuxArm64Main.dependsOn(linuxMain)

val nativeTest = getOrCreateNativeTest()
val linuxTest = sourceSets.create("linuxTest")
val linuxX64Test = sourceSets.getByName("linuxX64Test")
val linuxArm64Test = sourceSets.getByName("linuxArm64Test")
linuxTest.dependsOn(nativeTest)
linuxX64Test.dependsOn(linuxTest)
linuxArm64Test.dependsOn(linuxTest)
}

private fun getOrCreateJvmMain(): KotlinSourceSet =
Expand All @@ -245,6 +254,12 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
private fun getOrCreateJvmTest(): KotlinSourceSet =
getOrCreateSourceSet("jvmTest", "commonTest")

private fun getOrCreateNativeMain(): KotlinSourceSet =
getOrCreateSourceSet("nativeMain", "commonMain")

private fun getOrCreateNativeTest(): KotlinSourceSet =
getOrCreateSourceSet("nativeTest", "commonTest")

private fun getOrCreateSourceSet(
name: String,
dependsOnSourceSetName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,9 @@ abstract class AndroidXComposeMultiplatformExtension {

/**
* Provides the default target configuration and source set dependencies
* for all linuxX64 native targets.
* for all linux native targets.
*/
abstract fun linuxX64(): Unit

/**
* Provides the default target configuration and source set dependencies
* for all linuxArm64 native targets.
*/
abstract fun linuxArm64(): Unit
abstract fun linux(): Unit

/**
* Configures native compilation tasks with flags to link required frameworks
Expand Down
4 changes: 1 addition & 3 deletions collection/collection-compatibility-stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ androidXComposeMultiplatform {
js()
wasm()
darwin()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
4 changes: 1 addition & 3 deletions collection/collection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ androidXComposeMultiplatform {
js()
wasm()
darwin()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
4 changes: 1 addition & 3 deletions compose/runtime/runtime-saveable/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
darwin()
js()
wasm()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
3 changes: 1 addition & 2 deletions compose/runtime/runtime-test-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ androidXComposeMultiplatform {
darwin()
js()
wasm()
linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
4 changes: 1 addition & 3 deletions compose/runtime/runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
js()
wasm()
darwin()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down
4 changes: 1 addition & 3 deletions lifecycle/lifecycle-runtime-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ androidXComposeMultiplatform {
darwin()
js()
wasm()

linuxX64()
linuxArm64()
linux()
}

kotlin {
Expand Down