aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-10-16 14:10:16 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-10-16 15:16:18 +0000
commit26ac1f51215edffa87f8c139cd2f56bd499dbff0 (patch)
tree6475f08983a7e8a7ec7d54642385efe2e2495bfd /src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
parent5afe76c3cb20c542f51613c5db1a7840700d116d (diff)
*** 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
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.java43
1 files changed, 18 insertions, 25 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 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.<String>of("deps"));
+ RuleConfiguredTargetBuilder builder =
+ init(ruleContext, filesBuilder,
+ AndroidCommon.getTransitiveResourceContainers(ruleContext, true),
+ javaCommon, androidCommon, javaSemantics, androidSemantics,
+ ImmutableList.<String>of("deps"));
if (builder == null) {
return null;
}
@@ -123,7 +116,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
private static RuleConfiguredTargetBuilder init(
RuleContext ruleContext,
NestedSetBuilder<Artifact> filesBuilder,
- ResourceDependencies resourceDeps,
+ NestedSet<ResourceContainer> 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 {
* </ul>
*/
public static boolean shouldRegenerate(RuleContext ruleContext,
- ResourceDependencies resourceDeps) {
- return Iterables.size(resourceDeps.getResources()) > 1
+ Iterable<ResourceContainer> resourceContainers) {
+ return Iterables.size(resourceContainers) > 1
|| ruleContext.attributes().isAttributeValueExplicitlySpecified("densities")
|| ruleContext.attributes().isAttributeValueExplicitlySpecified(
"resource_configuration_filters")