diff options
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java index a4b5f6ba2d..4b52715e77 100644 --- a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java @@ -21,6 +21,7 @@ import com.google.devtools.build.android.AndroidResourceProcessor.FlagAaptOption import com.google.devtools.build.android.Converters.ExistingPathConverter; import com.google.devtools.build.android.Converters.PathConverter; import com.google.devtools.build.android.Converters.PathListConverter; +import com.google.devtools.build.android.Converters.VariantConfigurationTypeConverter; import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; @@ -137,12 +138,27 @@ public class ResourceShrinkerAction { help = "Path to where the shrunk resource.ap_ should be written.") public Path shrunkResources; + @Option(name = "rTxtOutput", + defaultValue = "null", + converter = PathConverter.class, + category = "output", + help = "Path to where the R.txt should be written.") + public Path rTxtOutput; + @Option(name = "log", defaultValue = "null", category = "output", converter = PathConverter.class, help = "Path to where the shrinker log should be written.") public Path log; + + @Option(name = "packageType", + defaultValue = "DEFAULT", + converter = VariantConfigurationTypeConverter.class, + category = "config", + help = "Variant configuration type for packaging the resources." + + " Acceptible values DEFAULT, LIBRARY, TEST") + public VariantConfiguration.Type packageType; } private static AaptConfigOptions aaptConfigOptions; @@ -216,6 +232,11 @@ public class ResourceShrinkerAction { logger.fine(String.format("Shrinking resources finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); + Path generatedSources = null; + if (options.rTxtOutput != null) { + generatedSources = working.resolve("generated_resources"); + } + // Build ap_ with shrunk resources. resourceProcessor.processResources( aaptConfigOptions.aapt, @@ -230,7 +251,7 @@ public class ResourceShrinkerAction { new MergedAndroidData( shrunkResources, resourceFiles.resolve("assets"), options.primaryManifest), ImmutableList.<DependencyAndroidData>of() /* libraries */, - null /* sourceOutputDir */, + generatedSources, options.shrunkApk, null /* proguardOutput */, null /* mainDexProguardOutput */, @@ -240,6 +261,12 @@ public class ResourceShrinkerAction { resourceProcessor.createResourcesZip(shrunkResources, resourceFiles.resolve("assets"), options.shrunkResources, false /* compress */); } + if (options.rTxtOutput != null) { + resourceProcessor.copyRToOutput( + generatedSources, + options.rTxtOutput, + options.packageType == VariantConfiguration.Type.LIBRARY); + } logger.fine(String.format("Packing resources finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); } catch (Exception e) { |