aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-06-20 22:08:17 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-06-21 09:59:11 +0000
commit1f1f207573c7b9c3e2d3ca1ffb0780a8fd592214 (patch)
tree4de90d7b6426fece22e4bfd8a5425f226a91f0c9 /src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java
parent81a89997be258d6978ead96608c240aee9ec95ea (diff)
Add action to write android_binary and lib R.classes directly
For android_binary rules, we regenerate all of the R.java of the libraries to get the final resource IDs. Compiling all of them together can be slow with the normal JavaBuilder, so add a specialized class writer. Example build with many R.java classes: - R.java -> R.class via JavaBuilder: over 80s - ErrorProne takes about 40% of that. So turning off ErrorProne would be projected to be 48s. Some of ErrorProne slowness is from static field checks (e.g., on Flag classes), which may look up the same Type over and over. In comparison, if we write our own bytecode with ASM: - ~16s total - 4.7s to parse R.txt - 4.8s to write class files - 5.8s to copy and compress .jar TODO: clean up SymbolLoader patching (upstream) This only creates the action. We will need to separately wire this up in blaze. NOTE: This also makes the exising R.txt loading used by live code multi-threaded, since that is partly I/O-bound. Something to watch out for (for flakiness, etc.) once this is submitted. -- MOS_MIGRATED_REVID=125384467
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.java9
1 files changed, 4 insertions, 5 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 69317a135b..7846844273 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
@@ -160,11 +160,10 @@ public class ResourceShrinkerAction {
options = optionsParser.getOptions(Options.class);
AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger);
- try {
- // Setup temporary working directories.
- Path working = Files.createTempDirectory("resource_shrinker_tmp");
- working.toFile().deleteOnExit();
-
+ // Setup temporary working directories.
+ try (ScopedTemporaryDirectory scopedTmp =
+ new ScopedTemporaryDirectory("resource_shrinker_tmp")) {
+ Path working = scopedTmp.getPath();
final Path resourceFiles = working.resolve("resource_files");
final Path shrunkResources = working.resolve("shrunk_resources");