From cf8ec29d96f03378ff34d64a0e43eeeb28535c12 Mon Sep 17 00:00:00 2001 From: jcater Date: Fri, 4 Jun 2021 06:35:30 -0700 Subject: [PATCH] Update AndroidSplitTransition to not fall back to legacy when --incompatible_enable_android_toolchain_resolution is set. PiperOrigin-RevId: 377500282 --- .../rules/android/AndroidSplitTransition.java | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSplitTransition.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSplitTransition.java index 8681b4b0c58159..6016b6cc9fd594 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSplitTransition.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSplitTransition.java @@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.PlatformOptions; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.BuildOptionsView; @@ -53,24 +54,37 @@ public ImmutableMap split( CppOptions cppOptions = buildOptions.get(CppOptions.class); /* * The intended order of checks is: - * - --android_platforms - * - Split using the values of this flag as the target platform - * - If this is unset, fall though. - * - --fat_apk_cpus - * - Split using the values of this flag as --cpu - * - If this is unset, fall though. - * - legacy, will eventually be removed - * - --android_cpu - * - Don't split, just use the value of this flag as --cpu - * - If this is unset, fall though. - * - legacy, will eventually be removed - * - Default - * - Don't split, using the same previously set --cpu and/or --platforms + * - When --incompatible_enable_android_toolchain_resolution is set: + * - --android_platforms + * - Split using the values of this flag as the target platform + * - If this is unset, use the first value from --platforms. + * - If this isn't a valid Android platform, an error will be thrown during the build. + * - Fall back to legacy flag logic: + * - --fat_apk_cpus + * - Split using the values of this flag as --cpu + * - If this is unset, fall though. + * - --android_cpu + * - Don't split, just use the value of this flag as --cpu + * - This will not update the output path to include "-android". + * - If this is unset, fall though. + * - Default + * - This will not update the output path to include "-android". + * - Don't split, using the same previously set --cpu value. */ - if (androidOptions.incompatibleUseToolchainResolution - && !androidOptions.androidPlatforms.isEmpty()) { - return handleAndroidPlatforms(buildOptions, androidOptions, androidOptions.androidPlatforms); - } else if (!androidOptions.fatApkCpus.isEmpty()) { + if (androidOptions.incompatibleUseToolchainResolution) { + // Always use --android_platforms when toolchain resolution is enabled. + List