diff options
author | 2025-02-27 08:23:49 +0100 | |
---|---|---|
committer | 2025-03-07 00:44:23 -0800 | |
commit | 914fe6843fc5773c32b810347cbfc669aa473647 (patch) | |
tree | 6603e24be200c4a05cb3ab11ac100315f1973ed9 | |
parent | e8d5d13b78ffe0db056f1329d87130c2068b75f7 (diff) |
Add support for R8 partial compilation in soong
This adds a new property Optimize.Exclude, which takes a path to a file containing a list of class names that should not be compiled using R8.
Example:
$ cat r8.exclude:
com.example.Foo
com.example.Bar
com.example.Bar
By default all classes are compiled using R8 when Optimize.Enabled is set.
Bug: 376196706
Test: existing
Change-Id: Ibc62f137e9c9251618d4ffbb655bc41b8b5b95e9
-rw-r--r-- | java/dex.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/java/dex.go b/java/dex.go index ed2df2103..b32d5aee0 100644 --- a/java/dex.go +++ b/java/dex.go @@ -103,6 +103,19 @@ type DexProperties struct { // If true, transitive reverse dependencies of this module will have this // module's proguard spec appended to their optimization action Export_proguard_flags_files *bool + + // Path to a file containing a list of class names that should not be compiled using R8. + // These classes will be compiled by D8 similar to when Optimize.Enabled is false. + // + // Example: + // + // r8.exclude: + // com.example.Foo + // com.example.Bar + // com.example.Bar$Baz + // + // By default all classes are compiled using R8 when Optimize.Enabled is set. + Exclude *string `android:"path"` } // Keep the data uncompressed. We always need uncompressed dex for execution, @@ -528,6 +541,11 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams, r8Flags = append(r8Flags, "--store-store-fence-constructor-inlining") } + if opt.Exclude != nil { + r8Flags = append(r8Flags, "--exclude", *opt.Exclude) + r8Deps = append(r8Deps, android.PathForModuleSrc(ctx, *opt.Exclude)) + } + return r8Flags, r8Deps, artProfileOutput } |