diff options
| author | 2023-02-16 14:46:19 +0000 | |
|---|---|---|
| committer | 2023-02-16 14:46:19 +0000 | |
| commit | c004bf3b7ed9d23d9e7aef69fe2d63d6478b2db3 (patch) | |
| tree | fe34465e60e619f6a1bc0d5ab21508e08f974009 /java/java.go | |
| parent | ec8f7543f64c816458c79c3ecedfd6fc85bf9fe8 (diff) | |
| parent | 81e468171f4822d1f9a6a2aed78589c74a1ee940 (diff) | |
Merge changes I55a5a295,I9c09451d,I05177388
* changes:
Use the profiles in the APEX to dexpreopt system server jars.
Add tests for the ignored "profile_guided: true" property.
Output dex_preopt to SDK snapshot.
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/java/java.go b/java/java.go index a003162eb..c2fcccf2f 100644 --- a/java/java.go +++ b/java/java.go @@ -801,6 +801,8 @@ type librarySdkMemberProperties struct { // The value of the min_sdk_version property, translated into a number where possible. MinSdkVersion *string `supported_build_releases:"Tiramisu+"` + + DexPreoptProfileGuided *bool `supported_build_releases:"UpsideDownCake+"` } func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { @@ -818,6 +820,10 @@ func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberCo canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String()) p.MinSdkVersion = proptools.StringPtr(canonical) } + + if j.dexpreopter.dexpreoptProperties.Dex_preopt_result.Profile_guided { + p.DexPreoptProfileGuided = proptools.BoolPtr(true) + } } func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { @@ -844,6 +850,11 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte propertySet.AddProperty("permitted_packages", p.PermittedPackages) } + dexPreoptSet := propertySet.AddPropertySet("dex_preopt") + if p.DexPreoptProfileGuided != nil { + dexPreoptSet.AddProperty("profile_guided", proptools.Bool(p.DexPreoptProfileGuided)) + } + // Do not copy anything else to the snapshot. if memberType.onlyCopyJarToSnapshot { return @@ -2014,7 +2025,8 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { if di == nil { return // An error has been reported by FindDeapexerProviderForModule. } - if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil { + dexJarFileApexRootRelative := apexRootRelativePathToJavaLib(j.BaseModuleName()) + if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil { dexJarFile := makeDexJarPathFromPath(dexOutputPath) j.dexJarFile = dexJarFile installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName())) @@ -2023,6 +2035,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, installPath) setUncompressDex(ctx, &j.dexpreopter, &j.dexer) j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex + + if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil { + j.dexpreopter.inputProfilePathOnHost = profilePath + } + j.dexpreopt(ctx, dexOutputPath) // Initialize the hiddenapi structure. @@ -2157,11 +2174,16 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, // requiredFilesFromPrebuiltApexForImport returns information about the files that a java_import or // java_sdk_library_import with the specified base module name requires to be exported from a // prebuilt_apex/apex_set. -func requiredFilesFromPrebuiltApexForImport(name string) []string { +func requiredFilesFromPrebuiltApexForImport(name string, d *dexpreopter) []string { + dexJarFileApexRootRelative := apexRootRelativePathToJavaLib(name) // Add the dex implementation jar to the set of exported files. - return []string{ - apexRootRelativePathToJavaLib(name), + files := []string{ + dexJarFileApexRootRelative, + } + if BoolDefault(d.importDexpreoptProperties.Dex_preopt.Profile_guided, false) { + files = append(files, dexJarFileApexRootRelative+".prof") } + return files } // apexRootRelativePathToJavaLib returns the path, relative to the root of the apex's contents, for @@ -2174,7 +2196,7 @@ var _ android.RequiredFilesFromPrebuiltApex = (*Import)(nil) func (j *Import) RequiredFilesFromPrebuiltApex(_ android.BaseModuleContext) []string { name := j.BaseModuleName() - return requiredFilesFromPrebuiltApexForImport(name) + return requiredFilesFromPrebuiltApexForImport(name, &j.dexpreopter) } // Add compile time check for interface implementation @@ -2215,6 +2237,7 @@ func ImportFactory() android.Module { module.AddProperties( &module.properties, &module.dexer.dexProperties, + &module.importDexpreoptProperties, ) module.initModuleAndImport(module) |