diff options
author | 2017-03-21 14:59:07 +0000 | |
---|---|---|
committer | 2017-03-22 10:53:36 +0000 | |
commit | efa0dd662a702c3757e3c85abdd563be11930a82 (patch) | |
tree | 640d883fa1c199cb27cca387d0d93842ea1ee6f6 /src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java | |
parent | 67019326347e2a9c6c5e0db128b5fd7493f6095d (diff) |
If resources were prefiltered, ignore unavailable resources from dependencies
Filtering resources in analysis allows Bazel to save time by not copying
unwanted resources to the execution phase and by having less resource for
execution to process.
However, analysis-phase resource filtering currently happens only for
android_binary targets. android_library dependencies will contain references to
all of their resources in their R and symbol files, even if those resources are
filtered out and not made available to execution.
Eventually, we want to use dynamic configuration to propogate the filters being
used on android_binary targets to android_library dependencies as well, and
filter those in analysis also. Until then, however, we need a way of ignoring
unwanted resources if they don't exist.
This change adds a flag to the AndroidResourceProcessingAction to indicate that
resources were filtered in analysis. If the flag is passed, if a resource
referred to in a parsed symbols file is not actually visible, it will be
ignored (otherwise, the action would go on to merging and eventually crash when
it tried to use the missing resource).
If the flag is passed, execution-time resource filtering by density will also
be skipped (execution-time filtering by other resource qualifiers happens in
aapt, but is a much simpler process).
--
PiperOrigin-RevId: 150752270
MOS_MIGRATED_REVID=150752270
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java index d616839b81..b3cea45fa7 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java @@ -15,7 +15,6 @@ package com.google.devtools.build.android; import com.android.builder.core.VariantType; import com.android.ide.common.res2.MergingException; -import com.android.utils.StdLogger; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Stopwatch; @@ -112,9 +111,6 @@ public class AarGeneratorAction { checkFlags(options); - AndroidResourceProcessor resourceProcessor = - new AndroidResourceProcessor(new StdLogger(com.android.utils.StdLogger.Level.VERBOSE)); - try (ScopedTemporaryDirectory scopedTmp = new ScopedTemporaryDirectory("aar_gen_tmp")) { Path tmp = scopedTmp.getPath(); Path resourcesOut = tmp.resolve("merged_resources"); @@ -133,7 +129,8 @@ public class AarGeneratorAction { assetsOut, null, VariantType.LIBRARY, - null); + null, + /* filteredResources= */ ImmutableList.<String>of()); logger.fine(String.format("Merging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS))); writeAar(options.aarOutput, mergedData, options.manifest, options.rtxt, options.classes); |