Skip to content

Commit 2112ebc

Browse files
fsladkeyGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "Revert "Revert "Revert "Enable native KMP targets by default."""" into androidx-main
2 parents c3ce958 + 279f2e1 commit 2112ebc

File tree

9 files changed

+30
-64
lines changed

9 files changed

+30
-64
lines changed

buildSrc-tests/src/test/kotlin/androidx/build/KmpPlatformsTest.kt

+11-13
Original file line numberDiff line numberDiff line change
@@ -23,51 +23,49 @@ class KmpPlatformsTest {
2323

2424
@Test
2525
fun withAnEmptyFlag_itReturnsTheDefaultValue() {
26-
assertThat(KmpFlagParser.parse("")).isEqualTo(KmpPlatform.enabledByDefault.toSet()
27-
)
26+
assertThat(KmpFlagParser.parse("")).isEqualTo(setOf(KmpPlatform.JVM))
2827
}
2928

3029
@Test
3130
fun withANullFlag_itReturnsTheDefaultValue() {
32-
assertThat(KmpFlagParser.parse(null)).isEqualTo(KmpPlatform.enabledByDefault.toSet()
33-
)
31+
assertThat(KmpFlagParser.parse(null)).isEqualTo(setOf(KmpPlatform.JVM))
3432
}
3533

3634
@Test
3735
fun withASingleDefaultPlatform_itParsesTheFlagCorrectly() {
38-
assertThat(KmpFlagParser.parse("+jvm")).isEqualTo(KmpPlatform.enabledByDefault.toSet())
36+
assertThat(KmpFlagParser.parse("+jvm")).isEqualTo(setOf(KmpPlatform.JVM))
3937
}
4038

4139
@Test
4240
fun withNoPlatforms_itParsesTheFlagCorrectly() {
43-
assertThat(KmpFlagParser.parse("-jvm,-mac,-linux")).isEqualTo(emptySet<KmpPlatform>())
41+
assertThat(KmpFlagParser.parse("-jvm")).isEqualTo(emptySet<KmpPlatform>())
4442
}
4543

4644
@Test
4745
fun withASingleNonDefaultPlatform_itParsesTheFlagCorrectly() {
4846
assertThat(KmpFlagParser.parse("+js")).isEqualTo(
49-
KmpPlatform.enabledByDefault.toSet() + KmpPlatform.JS
47+
setOf(KmpPlatform.JVM, KmpPlatform.JS)
5048
)
5149
}
5250

5351
@Test
5452
fun withAMultiplePlatforms_itParsesTheFlagCorrectly() {
5553
assertThat(KmpFlagParser.parse("+js,+mac")).isEqualTo(
56-
setOf(KmpPlatform.JVM, KmpPlatform.JS, KmpPlatform.MAC, KmpPlatform.LINUX)
54+
setOf(KmpPlatform.JVM, KmpPlatform.JS, KmpPlatform.MAC)
5755
)
5856
}
5957

6058
@Test
6159
fun withNegativeFlags_itParsesTheFlagCorrectly() {
62-
assertThat(KmpFlagParser.parse("-jvm,-linux,+js")).isEqualTo(
63-
setOf(KmpPlatform.MAC, KmpPlatform.JS)
60+
assertThat(KmpFlagParser.parse("-jvm,+mac")).isEqualTo(
61+
setOf(KmpPlatform.MAC)
6462
)
6563
}
6664

6765
@Test
68-
fun withTheNegativeNativeFlag_itParsesTheFlagCorrectly() {
69-
assertThat(KmpFlagParser.parse("-native")).isEqualTo(
70-
setOf(KmpPlatform.JVM)
66+
fun withTheNativeFlag_itParsesTheFlagCorrectly() {
67+
assertThat(KmpFlagParser.parse("+native")).isEqualTo(
68+
setOf(KmpPlatform.JVM, KmpPlatform.MAC, KmpPlatform.LINUX)
7169
)
7270
}
7371

buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt

+2-23
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,6 @@ class AndroidXImplPlugin @Inject constructor(val componentFactory: SoftwareCompo
280280
extension: AndroidXExtension,
281281
plugin: KotlinBasePluginWrapper
282282
) {
283-
if (plugin is KotlinMultiplatformPluginWrapper) {
284-
project.configureMultiplatformConfigurationCacheIncompatibleTasks()
285-
}
286283
project.afterEvaluate {
287284
project.tasks.withType(KotlinCompile::class.java).configureEach { task ->
288285
if (extension.type.compilationTarget == CompilationTarget.HOST &&
@@ -798,12 +795,11 @@ class AndroidXImplPlugin @Inject constructor(val componentFactory: SoftwareCompo
798795
private fun Project.overrideKotlinNativeDependenciesUrlToLocalDirectory() {
799796
val konanPrebuiltsFolder = getKonanPrebuiltsFolder()
800797
// use relative path so it doesn't affect gradle remote cache.
801-
val workingDir = File(System.getProperty("user.dir"))
802-
val relativeWorkingDirPath = konanPrebuiltsFolder.relativeTo(workingDir).path
798+
val relativeRootPath = konanPrebuiltsFolder.relativeTo(rootProject.projectDir).path
803799
val relativeProjectPath = konanPrebuiltsFolder.relativeTo(projectDir).path
804800
tasks.withType(KotlinNativeCompile::class.java).configureEach {
805801
it.kotlinOptions.freeCompilerArgs += listOf(
806-
"-Xoverride-konan-properties=dependenciesUrl=file:$relativeWorkingDirPath"
802+
"-Xoverride-konan-properties=dependenciesUrl=file:$relativeRootPath"
807803
)
808804
}
809805
tasks.withType(CInteropProcess::class.java).configureEach {
@@ -1019,25 +1015,8 @@ class AndroidXImplPlugin @Inject constructor(val componentFactory: SoftwareCompo
10191015
}
10201016
}
10211017

1022-
private fun Project.configureMultiplatformConfigurationCacheIncompatibleTasks() {
1023-
tasks.matching {
1024-
taskTypesIncompatibleWithConfigurationCache.contains(it::class.qualifiedName)
1025-
}.configureEach {
1026-
it.notCompatibleWithConfigurationCache(
1027-
taskTypesIncompatibleWithConfigurationCache[it::class.qualifiedName]!!
1028-
)
1029-
}
1030-
}
1031-
10321018
private const val PROJECTS_MAP_KEY = "projects"
10331019
private const val ACCESSED_PROJECTS_MAP_KEY = "accessedProjectsMap"
1034-
private val taskTypesIncompatibleWithConfigurationCache = mapOf(
1035-
"org.jetbrains.kotlin.gradle.targets.native.internal." +
1036-
"CInteropMetadataDependencyTransformationTask_Decorated" to
1037-
"https://youtrack.jetbrains.com/issue/KT-55259",
1038-
"org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyTransformationTask_Decorated" to
1039-
"https://youtrack.jetbrains.com/issue/KT-55051"
1040-
)
10411020

10421021
/**
10431022
* Hides a project's Javadoc tasks from the output of `./gradlew tasks` by setting their group to

buildSrc/private/src/main/kotlin/androidx/build/ListTaskOutputsTask.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ val taskNamesKnownToDuplicateOutputs = setOf(
135135

136136
val taskTypesKnownToDuplicateOutputs = setOf(
137137
// b/224564238
138-
"com.android.build.gradle.internal.lint.AndroidLintTask_Decorated",
139-
// https://youtrack.jetbrains.com/issue/KT-55259
140-
"org.jetbrains.kotlin.gradle.targets.native.internal." +
141-
"CInteropMetadataDependencyTransformationTask_Decorated"
138+
"com.android.build.gradle.internal.lint.AndroidLintTask_Decorated"
142139
)
143140

144141
fun shouldValidateTaskOutput(task: Task): Boolean {

buildSrc/private/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt

+8-18
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ val DONT_TRY_RERUNNING_TASK_TYPES = setOf(
166166
"org.gradle.api.publish.maven.tasks.PublishToMavenRepository_Decorated",
167167
// This task is not cacheable by design due to large number of inputs
168168
"androidx.build.license.CheckExternalDependencyLicensesTask_Decorated",
169-
// https://youtrack.jetbrains.com/issue/KT-55259
170-
"org.jetbrains.kotlin.gradle.targets.native.internal." +
171-
"CInteropMetadataDependencyTransformationTask_Decorated",
172-
// https://youtrack.jetbrains.com/issue/KT-55051
173-
"org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyTransformationTask_Decorated"
174169
)
175170

176171
@Suppress("UnstableApiUsage") // usage of BuildService that's incubating
@@ -229,8 +224,7 @@ abstract class TaskUpToDateValidator :
229224
// the actual message looks something like:
230225
// Input property 'rootSpec$1$3' file <some-path>.klib has changed
231226
return result.executionReasons.orEmpty().any {
232-
it.contains(".klib has changed") ||
233-
it.contains(".klib has been removed")
227+
it.contains(".klib has changed")
234228
}
235229
}
236230

@@ -242,7 +236,12 @@ abstract class TaskUpToDateValidator :
242236
if (ALLOW_RERUNNING_TASKS.contains(taskName)) {
243237
return true
244238
}
245-
if (isCompileKotlinMetadataTask(taskName)) {
239+
if (taskName.startsWith("compile") && taskName.endsWith("KotlinMetadata")) {
240+
// these tasks' up-to-date checks might flake.
241+
// https://youtrack.jetbrains.com/issue/KT-52675
242+
// We are not adding the task type to the DONT_TRY_RERUNNING_TASKS list because it
243+
// is a common compilation task that is shared w/ other kotlin native compilations.
244+
// (e.g. similar to the Exec task in Gradle)
246245
return true
247246
}
248247
return false
@@ -252,8 +251,7 @@ abstract class TaskUpToDateValidator :
252251
return !(
253252
DONT_TRY_RERUNNING_TASKS.contains(task.name) ||
254253
DONT_TRY_RERUNNING_TASKS.contains(task.path) ||
255-
DONT_TRY_RERUNNING_TASK_TYPES.contains(task::class.qualifiedName) ||
256-
isCompileKotlinMetadataTask(task.name)
254+
DONT_TRY_RERUNNING_TASK_TYPES.contains(task::class.qualifiedName)
257255
)
258256
}
259257

@@ -282,11 +280,3 @@ abstract class TaskUpToDateValidator :
282280
}
283281
}
284282
}
285-
286-
// these tasks' up-to-date checks might flake.
287-
// https://youtrack.jetbrains.com/issue/KT-52675
288-
// We are not adding the task type to the DONT_TRY_RERUNNING_TASKS list because it
289-
// is a common compilation task that is shared w/ other kotlin native compilations.
290-
// (e.g. similar to the Exec task in Gradle)
291-
private fun isCompileKotlinMetadataTask(taskName: String) =
292-
(taskName.startsWith("compile") && taskName.endsWith("KotlinMetadata"))

buildSrc/public/src/main/kotlin/androidx/build/KmpPlatforms.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum class KmpPlatform {
3434
LINUX;
3535
companion object {
3636
val native = listOf(MAC, LINUX)
37-
val enabledByDefault = listOf(JVM) + native
37+
val enabledByDefault = listOf(JVM)
3838
private const val JVM_PLATFORM = "jvm"
3939
private const val JS_PLATFORM = "js"
4040
private const val MAC_ARM_64 = "macosarm64"

busytown/androidx_host_tests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cd "$(dirname $0)"
88
impl/build.sh test linuxX64Test \
99
-Pandroidx.ignoreTestFailures \
1010
-Pandroidx.displayTestOutput=false \
11+
-Pandroidx.enabled.kmp.target.platforms=+native \
1112
"$@"
1213

1314
echo "Completing $0 at $(date)"

busytown/androidx_host_tests_max_dep_versions.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cd "$(dirname $0)"
77

88
impl/build.sh test linuxX64Test -Pandroidx.useMaxDepVersions \
99
-Pandroidx.displayTestOutput=false \
10+
-Pandroidx.enabled.kmp.target.platforms=+native \
1011
-Pandroidx.ignoreTestFailures "$@"
1112

1213
echo "Completing $0 at $(date)"

development/build_log_simplifier/messages.ignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ Found an unresolved type in androidx\.room\.RoomDatabase\.Builder\$setAutoCloseT
949949
# > Task :compose:ui:ui:compileReleaseKotlin
950950
w: \$SUPPORT/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat\.android\.kt: \([0-9]+, [0-9]+\): Unnecessary non\-null assertion \(!!\) on a non\-null receiver of type LayoutNode
951951
# When konan is downloading a dependency from another file, don't warn about it.
952-
\(KonanProperies\) Downloading dependency: file:(\.\.\/.\.\/)?prebuilts\/androidx\/konan\/.+
952+
\(KonanProperies\) Downloading dependency: file:\.\./\.\./.*
953953
Please wait while Kotlin/Native compiler .* is being installed\.
954954
Unpack Kotlin/Native compiler to .*
955955
Download file:\.\./\.\./.*

settings.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,10 @@ includeProject(":asynclayoutinflater:asynclayoutinflater-appcompat", [BuildType.
390390
includeProject(":autofill:autofill", [BuildType.MAIN])
391391
includeProject(":benchmark:benchmark-benchmark", "benchmark/benchmark", [BuildType.MAIN, BuildType.COMPOSE])
392392
includeProject(":benchmark:benchmark-common")
393-
includeProject(":benchmark:benchmark-darwin", [BuildType.MAIN, BuildType.KMP])
394-
includeProject(":benchmark:benchmark-darwin-core", [BuildType.MAIN, BuildType.KMP])
395-
includeProject(":benchmark:benchmark-darwin-samples", [BuildType.MAIN, BuildType.KMP])
396-
includeProject(":benchmark:benchmark-darwin-gradle-plugin", [BuildType.MAIN, BuildType.KMP])
393+
includeProject(":benchmark:benchmark-darwin", [BuildType.KMP])
394+
includeProject(":benchmark:benchmark-darwin-core", [BuildType.KMP])
395+
includeProject(":benchmark:benchmark-darwin-samples", [BuildType.KMP])
396+
includeProject(":benchmark:benchmark-darwin-gradle-plugin", [BuildType.KMP])
397397
includeProject(":benchmark:benchmark-gradle-plugin", "benchmark/gradle-plugin", [BuildType.MAIN])
398398
includeProject(":benchmark:benchmark-baseline-profile-gradle-plugin", "benchmark/baseline-profile-gradle-plugin",[BuildType.MAIN])
399399
includeProject(":benchmark:benchmark-junit4")

0 commit comments

Comments
 (0)