diff options
author | Googler <noreply@google.com> | 2016-06-20 22:08:17 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2016-06-21 09:59:11 +0000 |
commit | 1f1f207573c7b9c3e2d3ca1ffb0780a8fd592214 (patch) | |
tree | 4de90d7b6426fece22e4bfd8a5425f226a91f0c9 /src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java | |
parent | 81a89997be258d6978ead96608c240aee9ec95ea (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/AndroidResourceProcessingAction.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java index 373f1612e1..69f58d6fbb 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceProcessingAction.java @@ -40,7 +40,6 @@ import com.android.utils.StdLogger; import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; -import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.concurrent.TimeUnit; @@ -217,11 +216,9 @@ public class AndroidResourceProcessingAction { Path working = fileSystem.getPath("").toAbsolutePath(); final AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(STD_LOGGER); - try { - final Path tmp = Files.createTempDirectory("android_resources_tmp"); - // Clean up the tmp file on exit to keep diskspace low. - tmp.toFile().deleteOnExit(); - + try (ScopedTemporaryDirectory scopedTmp = + new ScopedTemporaryDirectory("android_resources_tmp")) { + final Path tmp = scopedTmp.getPath(); final Path expandedOut = tmp.resolve("tmp-expanded"); final Path deduplicatedOut = tmp.resolve("tmp-deduplicated"); final Path mergedAssets = tmp.resolve("merged_assets"); |