summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2016-06-20 22:08:17 +0000
committerColin Cross <ccross@android.com>2017-02-16 22:34:44 -0800
commitb5e221bb7b3896f459e723391fb03b0ff29f6126 (patch)
treeba60db6e3fae708c812256f98fa5a52802096539
parentc0a8492f041f6b9b4e263be4dca530724db97e06 (diff)
downloaddesugar-b5e221bb7b3896f459e723391fb03b0ff29f6126.tar.gz
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 GitOrigin-RevId: 1f1f207573c7b9c3e2d3ca1ffb0780a8fd592214 Change-Id: I4c8335a7222181b2f400cacfed8faefc549d311d
-rw-r--r--java/com/google/devtools/build/android/Converters.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/java/com/google/devtools/build/android/Converters.java b/java/com/google/devtools/build/android/Converters.java
index 54d1150..5fae682 100644
--- a/java/com/google/devtools/build/android/Converters.java
+++ b/java/com/google/devtools/build/android/Converters.java
@@ -95,6 +95,38 @@ public final class Converters {
}
/**
+ * Converter for a list of {@link DependencySymbolFileProvider}. Relies on
+ * {@code DependencySymbolFileProvider#valueOf(String)} to perform conversion and validation.
+ */
+ public static class DependencySymbolFileProviderListConverter
+ implements Converter<List<DependencySymbolFileProvider>> {
+
+ @Override
+ public List<DependencySymbolFileProvider> convert(String input) throws OptionsParsingException {
+ if (input.isEmpty()) {
+ return ImmutableList.<DependencySymbolFileProvider>of();
+ }
+ try {
+ ImmutableList.Builder<DependencySymbolFileProvider> builder = ImmutableList.builder();
+ for (String item : input.split(",")) {
+ builder.add(DependencySymbolFileProvider.valueOf(item));
+ }
+ return builder.build();
+ } catch (IllegalArgumentException e) {
+ throw new OptionsParsingException(
+ String.format("invalid DependencyAndroidData: %s", e.getMessage()), e);
+ }
+ }
+
+ @Override
+ public String getTypeDescription() {
+ return String.format("a list of dependency android data in the format: %s[%s]",
+ DependencySymbolFileProvider.commandlineFormat("1"),
+ DependencySymbolFileProvider.commandlineFormat("2"));
+ }
+ }
+
+ /**
* Converter for {@link FullRevision}. Relies on {@code FullRevision#parseRevision(String)} to
* perform conversion and validation.
*/