diff options
author | 2024-10-29 18:09:44 -0700 | |
---|---|---|
committer | 2024-12-20 13:45:58 -0800 | |
commit | 3afd79532e243948feff6cc0377f1f629ede87eb (patch) | |
tree | c095c8f7671e0bbb707f270e868c4873bd119845 | |
parent | 5faf0f5c4effa1e1b5e66e1d62f2f18060dc9800 (diff) |
Add support for aapt2 png compression level
aapt2 by default uses the slowest compression level for png
images, and it makes sense for the final release. On the other
hand, it takes ~5x longer than zlib level 6 which is still
just ~1-2% larger for Framework resources. Allowing faster
compression saves over a minute of Platform compilation time
for eng builds, so let's support it
Test: manual, build + boot Android
Flag: EXEMPT build system feature disabled without uses
Change-Id: I74462c182ab78e37647f1dfe1ec5f449458e5dc1
-rw-r--r-- | android/util.go | 14 | ||||
-rw-r--r-- | android/variable.go | 1 | ||||
-rw-r--r-- | java/aar.go | 5 |
3 files changed, 18 insertions, 2 deletions
diff --git a/android/util.go b/android/util.go index 3fc4608e0..30d8ec6b3 100644 --- a/android/util.go +++ b/android/util.go @@ -308,6 +308,20 @@ func FilterList(list []string, filter []string) (remainder []string, filtered [] return } +// FilterListByPrefixes performs the same splitting as FilterList does, but treats the passed +// filters as prefixes +func FilterListByPrefix(list []string, filter []string) (remainder []string, filtered []string) { + for _, l := range list { + if HasAnyPrefix(l, filter) { + filtered = append(filtered, l) + } else { + remainder = append(remainder, l) + } + } + + return +} + // FilterListPred returns the elements of the given list for which the predicate // returns true. Order is kept. func FilterListPred(list []string, pred func(s string) bool) (filtered []string) { diff --git a/android/variable.go b/android/variable.go index e06fb8a0c..933ddfd18 100644 --- a/android/variable.go +++ b/android/variable.go @@ -162,6 +162,7 @@ type variableProperties struct { Optimize struct { Enabled *bool } + Aaptflags []string } Uml struct { diff --git a/java/aar.go b/java/aar.go index e0e642e36..68ce3f4bd 100644 --- a/java/aar.go +++ b/java/aar.go @@ -386,8 +386,9 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte versionName = proptools.NinjaEscape(versionName) linkFlags = append(linkFlags, "--version-name ", versionName) } - - linkFlags, compileFlags = android.FilterList(linkFlags, []string{"--legacy"}) + // Split the flags by prefix, as --png-compression-level has the "=value" suffix. + linkFlags, compileFlags = android.FilterListByPrefix(linkFlags, + []string{"--legacy", "--png-compression-level"}) // Always set --pseudo-localize, it will be stripped out later for release // builds that don't want it. |