aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
diff options
context:
space:
mode:
authorGravatar asteinb <asteinb@google.com>2018-04-18 09:59:55 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-18 10:01:37 -0700
commit9b72ae13744069a6dc5f8f474c7979a3b0c9200d (patch)
treec4674242b68ce0da31fec6312f1df580200e5e39 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
parent3b432394c92614e2848d3000e7d228280ecfe127 (diff)
Wire up decoupled data pipeline in top-level Android targets
The decoupled pipeline is safely hidden behind a flag. I'm explicitly holding off on the MobileInstall code until next review, so we sometimes create an ApplicationManifest object even in the new pipeline to pass data to that code. I'm not thrilled with the 'just call into the resource processor with different settings' approach that I've reproduced in ProcessedAndroidData, but I don't see a better way of doing things, and I think that breaking out the commonly used settings makes things cleaner. RELNOTES: none PiperOrigin-RevId: 193373347
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.java65
1 files changed, 42 insertions, 23 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 1a2e5f8f45..385aedfb1f 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
@@ -186,8 +186,25 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
// Retrieve and compile the resources defined on the android_binary rule.
AndroidResources.validateRuleContext(ruleContext);
- ApplicationManifest applicationManifest =
- androidSemantics.getManifestForRule(ruleContext).mergeWith(ruleContext, resourceDeps);
+ final ApplicationManifest applicationManifest;
+ final ResourceApk resourceApk;
+
+ if (AndroidCommon.getAndroidConfig(ruleContext).decoupleDataProcessing()) {
+ StampedAndroidManifest manifest =
+ AndroidManifest.from(ruleContext, androidSemantics).mergeWithDeps(ruleContext);
+ applicationManifest =
+ ApplicationManifest.fromExplicitManifest(ruleContext, manifest.getManifest());
+
+ resourceApk =
+ ProcessedAndroidData.processBinaryDataFrom(
+ ruleContext,
+ manifest,
+ /* conditionalKeepRules = */ shouldShrinkResourceCycles(
+ ruleContext, shrinkResources))
+ .generateRClass(ruleContext);
+ } else {
+ applicationManifest =
+ androidSemantics.getManifestForRule(ruleContext).mergeWith(ruleContext, resourceDeps);
Artifact featureOfArtifact =
ruleContext.attributes().isAttributeValueExplicitlySpecified("feature_of")
@@ -195,29 +212,31 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
: null;
Artifact featureAfterArtifact =
ruleContext.attributes().isAttributeValueExplicitlySpecified("feature_after")
- ? ruleContext
- .getPrerequisite("feature_after", Mode.TARGET, ApkInfo.PROVIDER)
- .getApk()
+ ? ruleContext.getPrerequisite("feature_after", Mode.TARGET, ApkInfo.PROVIDER).getApk()
: null;
- ResourceApk resourceApk =
- applicationManifest.packBinaryWithDataAndResources(
- ruleContext,
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK),
- resourceDeps,
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
- ResourceFilterFactory.fromRuleContext(ruleContext),
- ruleContext.getExpander().withDataLocations().tokenized("nocompress_extensions"),
- ruleContext.attributes().get("crunch_png", Type.BOOLEAN),
- ProguardHelper.getProguardConfigArtifact(ruleContext, ""),
- createMainDexProguardSpec(ruleContext),
- shouldShrinkResourceCycles(ruleContext, shrinkResources),
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),
- DataBinding.isEnabled(ruleContext) ? DataBinding.getLayoutInfoFile(ruleContext) : null,
- featureOfArtifact,
- featureAfterArtifact);
- ruleContext.assertNoErrors();
+ resourceApk =
+ applicationManifest.packBinaryWithDataAndResources(
+ ruleContext,
+ ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK),
+ resourceDeps,
+ ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),
+ ResourceFilterFactory.fromRuleContext(ruleContext),
+ ruleContext.getExpander().withDataLocations().tokenized("nocompress_extensions"),
+ ruleContext.attributes().get("crunch_png", Type.BOOLEAN),
+ ProguardHelper.getProguardConfigArtifact(ruleContext, ""),
+ createMainDexProguardSpec(ruleContext),
+ shouldShrinkResourceCycles(ruleContext, shrinkResources),
+ ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),
+ ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),
+ DataBinding.isEnabled(ruleContext)
+ ? DataBinding.getLayoutInfoFile(ruleContext)
+ : null,
+ featureOfArtifact,
+ featureAfterArtifact);
+ }
+
+ ruleContext.assertNoErrors();
// Remove the library resource JARs from the binary's runtime classpath.
// Resource classes from android_library dependencies are replaced by the binary's resource