aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
diff options
context:
space:
mode:
authorGravatar Andrew Pellegrini <apell@google.com>2016-03-07 20:02:36 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-03-08 03:45:14 +0000
commit52048e36215a70028ca355808f9ee36e2a9ca986 (patch)
treefb301a69cd414b06d56a03b4cb641832f1514ffb /src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
parent4b1999792537270b46d0750ff8b4155b10b0320c (diff)
Adds ResourceShrinkerAction to android_binary targets if they use Proguard and specify --experimental_android_resource_shrinking on the command line.
RELNOTES: Specifying --experimental_android_resource_shrinking on the command line will enable a resource shrinking pass on android_binary targets that already use Proguard. -- MOS_MIGRATED_REVID=116572863
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
index 465d2bfcfd..8b0b314ffc 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
@@ -76,6 +76,8 @@ public class AndroidResourcesProcessorBuilder {
private Artifact symbolsTxt;
private Artifact manifestOut;
+ private Artifact mergedResourcesOut;
+ private boolean isLibrary;
/**
* @param ruleContext The RuleContext that was used to create the SpawnAction.Builder.
@@ -156,6 +158,16 @@ public class AndroidResourcesProcessorBuilder {
return this;
}
+ public AndroidResourcesProcessorBuilder setMergedResourcesOut(Artifact mergedResourcesOut) {
+ this.mergedResourcesOut = mergedResourcesOut;
+ return this;
+ }
+
+ public AndroidResourcesProcessorBuilder setLibrary(boolean isLibrary) {
+ this.isLibrary = isLibrary;
+ return this;
+ }
+
private static class ResourceContainerToArg implements Function<ResourceContainer, String> {
private boolean includeSymbols;
@@ -257,7 +269,7 @@ public class AndroidResourcesProcessorBuilder {
Iterables.unmodifiableIterable(
Iterables.transform(dependencies.getDirectResources(), RESOURCE_DEP_TO_ARG)));
}
- // This flattens the nested set. Since each ResourceContainer needs to be transformed into
+ // This flattens the nested set. Since each ResourceContainer needs to be transformed into
// Artifacts, and the NestedSetBuilder.wrap doesn't support lazy Iterator evaluation
// and SpawnActionBuilder.addInputs evaluates Iterables, it becomes necessary to make the
// best effort and let it get flattened.
@@ -268,13 +280,13 @@ public class AndroidResourcesProcessorBuilder {
.transformAndConcat(RESOURCE_DEP_TO_ARTIFACTS)));
}
+ if (isLibrary) {
+ builder.add("--packageType").add("LIBRARY");
+ }
+
if (rTxtOut != null) {
builder.addExecPath("--rOutput", rTxtOut);
outs.add(rTxtOut);
- // If R.txt is not null, dependency R.javas will not be regenerated from the R.txt found in
- // the deps, which means the resource processor needs to be told it is creating a library so
- // that it will generate the R.txt.
- builder.add("--packageType").add("LIBRARY");
}
if (symbolsTxt != null) {
@@ -289,12 +301,17 @@ public class AndroidResourcesProcessorBuilder {
builder.addExecPath("--proguardOutput", proguardOut);
outs.add(proguardOut);
}
-
+
if (manifestOut != null) {
builder.addExecPath("--manifestOutput", manifestOut);
outs.add(manifestOut);
}
-
+
+ if (mergedResourcesOut != null) {
+ builder.addExecPath("--resourcesOutput", mergedResourcesOut);
+ outs.add(mergedResourcesOut);
+ }
+
if (apkOut != null) {
builder.addExecPath("--packagePath", apkOut);
outs.add(apkOut);