From 26ac1f51215edffa87f8c139cd2f56bd499dbff0 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 16 Oct 2015 14:10:16 +0000 Subject: []Rollback of commit 65425810207c9fd6892abfaa95da65e25db5e515. *** Reason for rollback *** Breaks []. *** Original change description *** Change the resource dependency handling to separate between the transitive and direct resources from libraries. This slightly increases the complexity of resource propagation. The initial algorithm was to simply merge all transitive ResourceContainers together with any new ResourceContainer and propagate them via the AndroidResourcesProvider. The new algorithm is encapsulated inside a new ResourceDependencies class which works as follows: 1. Collect resources from the deps into transitive and... *** -- MOS_MIGRATED_REVID=105598448 --- .../build/lib/rules/android/AndroidBinary.java | 43 +++++++++------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java') 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 6c8fd51b0b..876d796fc8 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 @@ -49,6 +49,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.TriState; import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; +import com.google.devtools.build.lib.rules.android.AndroidResourcesProvider.ResourceContainer; import com.google.devtools.build.lib.rules.android.AndroidRuleClasses.MultidexMode; import com.google.devtools.build.lib.rules.cpp.CcToolchainProvider; import com.google.devtools.build.lib.rules.cpp.CppHelper; @@ -96,19 +97,11 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { AndroidCommon androidCommon = new AndroidCommon( ruleContext, javaCommon, true /* asNeverLink */, true /* exportDeps */); try { - ResourceDependencies resourceDeps = LocalResourceContainer.definesAndroidResources( - ruleContext.attributes()) - ? ResourceDependencies.fromRuleDeps(ruleContext) - : ResourceDependencies.fromRuleResourceAndDeps(ruleContext); - RuleConfiguredTargetBuilder builder = init( - ruleContext, - filesBuilder, - resourceDeps, - javaCommon, - androidCommon, - javaSemantics, - androidSemantics, - ImmutableList.of("deps")); + RuleConfiguredTargetBuilder builder = + init(ruleContext, filesBuilder, + AndroidCommon.getTransitiveResourceContainers(ruleContext, true), + javaCommon, androidCommon, javaSemantics, androidSemantics, + ImmutableList.of("deps")); if (builder == null) { return null; } @@ -123,7 +116,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { private static RuleConfiguredTargetBuilder init( RuleContext ruleContext, NestedSetBuilder filesBuilder, - ResourceDependencies resourceDeps, + NestedSet resourceContainers, JavaCommon javaCommon, AndroidCommon androidCommon, JavaSemantics javaSemantics, @@ -190,11 +183,11 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { throw new RuleConfigurationException(); } applicationManifest = androidSemantics.getManifestForRule(ruleContext) - .mergeWith(ruleContext, resourceDeps); + .mergeWith(ruleContext, resourceContainers); resourceApk = applicationManifest.packWithDataAndResources( ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK), ruleContext, - resourceDeps, + resourceContainers, null, /* Artifact rTxt */ null, /* Artifact symbolsTxt */ ruleContext.getTokenizedStringListAttr("resource_configuration_filters"), @@ -208,7 +201,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { .packWithDataAndResources(ruleContext .getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_INCREMENTAL_RESOURCES_APK), ruleContext, - resourceDeps, + resourceContainers, null, /* Artifact rTxt */ null, /* Artifact symbolsTxt */ ruleContext.getTokenizedStringListAttr("resource_configuration_filters"), @@ -222,7 +215,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { .createSplitManifest(ruleContext, "android_resources", false) .packWithDataAndResources(getDxArtifact(ruleContext, "android_resources.ap_"), ruleContext, - resourceDeps, + resourceContainers, null, /* Artifact rTxt */ null, /* Artifact symbolsTxt */ ruleContext.getTokenizedStringListAttr("resource_configuration_filters"), @@ -236,13 +229,13 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { // Retrieve the resources from the resources attribute on the android_binary rule // and recompile them if necessary. applicationManifest = ApplicationManifest.fromResourcesRule(ruleContext).mergeWith( - ruleContext, resourceDeps); + ruleContext, resourceContainers); // Always recompiling resources causes AndroidTest to fail in certain circumstances. - if (shouldRegenerate(ruleContext, resourceDeps)) { + if (shouldRegenerate(ruleContext, resourceContainers)) { resourceApk = applicationManifest.packWithResources( ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK), ruleContext, - resourceDeps, + resourceContainers, true, getProguardConfigArtifact(ruleContext, "")); } else { @@ -255,7 +248,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { ruleContext.getImplicitOutputArtifact( AndroidRuleClasses.ANDROID_INCREMENTAL_RESOURCES_APK), ruleContext, - resourceDeps, + resourceContainers, false, getProguardConfigArtifact(ruleContext, "incremental")); @@ -263,7 +256,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { .createSplitManifest(ruleContext, "android_resources", false) .packWithResources(getDxArtifact(ruleContext, "android_resources.ap_"), ruleContext, - resourceDeps, + resourceContainers, false, getProguardConfigArtifact(ruleContext, "incremental_split")); } @@ -1279,8 +1272,8 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { * */ public static boolean shouldRegenerate(RuleContext ruleContext, - ResourceDependencies resourceDeps) { - return Iterables.size(resourceDeps.getResources()) > 1 + Iterable resourceContainers) { + return Iterables.size(resourceContainers) > 1 || ruleContext.attributes().isAttributeValueExplicitlySpecified("densities") || ruleContext.attributes().isAttributeValueExplicitlySpecified( "resource_configuration_filters") -- cgit v1.2.3