diff options
author | 2016-05-18 12:00:23 +0000 | |
---|---|---|
committer | 2016-05-18 13:49:38 +0000 | |
commit | 9f046cba37de6088b2f81717bc263889a5146d86 (patch) | |
tree | 4051c02bfbe6d9e06ecf692cdf9ff838f41d6a99 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java | |
parent | 67116c7443c93b71e522cee36c72fc4af358358d (diff) |
Rollback of commit b8946eabd60a199a66a1892701d52d9801c7fb1a.
--
MOS_MIGRATED_REVID=122620007
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java index b798b4f00b..aa565155a0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java @@ -1079,7 +1079,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { @Nullable Artifact mainDexProguardSpec, JavaTargetAttributes attributes) throws InterruptedException { - boolean isFinalJarDerived = isBinaryJarFiltered || binaryJar != proguardedJar; + boolean finalJarIsDerived = isBinaryJarFiltered || binaryJar != proguardedJar; List<String> dexopts = ruleContext.getTokenizedStringListAttr("dexopts"); MultidexMode multidexMode = getMultidexMode(ruleContext); if (!supportsMultidexMode(ruleContext, multidexMode)) { @@ -1111,7 +1111,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { // Always OFF if finalJarIsDerived ImmutableSet<AndroidBinaryType> incrementalDexing = - getEffectiveIncrementalDexing(ruleContext, dexopts, isFinalJarDerived, isBinaryJarFiltered); + getEffectiveIncrementalDexing(ruleContext, dexopts, finalJarIsDerived); if (multidexMode == MultidexMode.OFF) { // Single dex mode: generate classes.dex directly from the input jar. if (incrementalDexing.contains(AndroidBinaryType.MONODEX)) { @@ -1148,7 +1148,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { createShuffleJarAction( ruleContext, incrementalDexing.contains(AndroidBinaryType.MULTIDEX_SHARDED), - isFinalJarDerived ? proguardedJar : null, + finalJarIsDerived ? proguardedJar : null, shards, common, dexopts, @@ -1219,43 +1219,18 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { } private static ImmutableSet<AndroidBinaryType> getEffectiveIncrementalDexing( - RuleContext ruleContext, List<String> dexopts, boolean isFinalJarDerived, - boolean isBinaryJarFiltered) { - TriState override = ruleContext.attributes().get("incremental_dexing", BuildType.TRISTATE); - // Ignore --incremental_dexing_binary_types if the incremental_dexing attribute is set, but - // raise an error if proguard is enabled (b/c incompatible with incremental dexing ATM). - if (isFinalJarDerived && override == TriState.YES) { - ruleContext.attributeError("incremental_dexing", - "target cannot be incrementally dexed because " - + (isBinaryJarFiltered ? "it builds a partial APK" : "the target uses Proguard")); - return ImmutableSet.of(); - } - if (isFinalJarDerived || override == TriState.NO) { + RuleContext ruleContext, List<String> dexopts, boolean finalJarIsDerived) { + if (finalJarIsDerived) { return ImmutableSet.of(); } ImmutableSet<AndroidBinaryType> result = - override == TriState.YES - ? ImmutableSet.copyOf(AndroidBinaryType.values()) - : AndroidCommon.getAndroidConfig(ruleContext).getIncrementalDexingBinaries(); - if (!result.isEmpty()) { - Iterable<String> blacklistedDexopts = - Iterables.filter( - dexopts, - new DexArchiveAspect.FlagMatcher(AndroidCommon - .getAndroidConfig(ruleContext) - .getTargetDexoptsThatPreventIncrementalDexing())); - if (!Iterables.isEmpty(blacklistedDexopts)) { - // target's dexopts include flags blacklisted with --non_incremental_per_target_dexopts. If - // incremental_dexing attribute is explicitly set for this target then we'll warn and - // incrementally dex anyway. Otherwise, just don't incrementally dex. - if (override == TriState.YES) { - ruleContext.attributeWarning("incremental_dexing", - "Using incremental dexing even though the following dexopts indicate this target " - + "may be unsuitable for incremental dexing for the moment: " + blacklistedDexopts); - } else { - result = ImmutableSet.of(); - } - } + AndroidCommon.getAndroidConfig(ruleContext).getIncrementalDexingBinaries(); + if (!result.isEmpty() + && Iterables.any(dexopts, + new DexArchiveAspect.FlagMatcher(AndroidCommon + .getAndroidConfig(ruleContext) + .getTargetDexoptsThatPreventIncrementalDexing()))) { + result = ImmutableSet.of(); } return result; } |