diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/app.go | 62 | ||||
-rw-r--r-- | java/app_import.go | 6 | ||||
-rw-r--r-- | java/app_set.go | 5 | ||||
-rw-r--r-- | java/base.go | 4 | ||||
-rw-r--r-- | java/bootclasspath_fragment.go | 6 | ||||
-rw-r--r-- | java/java.go | 77 | ||||
-rw-r--r-- | java/platform_compat_config.go | 12 | ||||
-rw-r--r-- | java/rro.go | 15 | ||||
-rw-r--r-- | java/sdk_library.go | 28 | ||||
-rw-r--r-- | java/sdk_library_internal.go | 2 |
10 files changed, 176 insertions, 41 deletions
diff --git a/java/app.go b/java/app.go index 89d688d62..ccc60a4e3 100644 --- a/java/app.go +++ b/java/app.go @@ -72,6 +72,16 @@ type AppInfo struct { EmbeddedJNILibs android.Paths MergedManifestFile android.Path + + Prebuilt bool + AppSet bool + Privileged bool + OutputFile android.Path + InstallApkName string + JacocoReportClassesFile android.Path + Certificate Certificate + PrivAppAllowlist android.OptionalPath + OverriddenManifestPackageName *string } var AppInfoProvider = blueprint.NewProvider[*AppInfo]() @@ -401,10 +411,12 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{ TestOnly: true, }) - android.SetProvider(ctx, AppInfoProvider, &AppInfo{ + appInfo := &AppInfo{ Updatable: Bool(a.appProperties.Updatable), TestHelperApp: true, - }) + } + setCommonAppInfo(appInfo, a) + android.SetProvider(ctx, AppInfoProvider, appInfo) moduleInfoJSON := ctx.ModuleInfoJSON() moduleInfoJSON.Tags = append(moduleInfoJSON.Tags, "tests") @@ -428,12 +440,16 @@ func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { embeddedJniLibs = append(embeddedJniLibs, jni.path) } } - android.SetProvider(ctx, AppInfoProvider, &AppInfo{ - Updatable: Bool(a.appProperties.Updatable), - TestHelperApp: false, - EmbeddedJNILibs: embeddedJniLibs, - MergedManifestFile: a.mergedManifest, - }) + overriddenName := a.OverriddenManifestPackageName() + appInfo := &AppInfo{ + Updatable: Bool(a.appProperties.Updatable), + TestHelperApp: false, + EmbeddedJNILibs: embeddedJniLibs, + MergedManifestFile: a.mergedManifest, + OverriddenManifestPackageName: &overriddenName, + } + setCommonAppInfo(appInfo, a) + android.SetProvider(ctx, AppInfoProvider, appInfo) a.requiredModuleNames = a.getRequiredModuleNames(ctx) } @@ -2044,7 +2060,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext if _, ok := android.OtherModuleProvider(ctx, m, SdkLibraryInfoProvider); ok { // Skip java_sdk_library dependencies that provide stubs, but not an implementation. // This will be restricted to optional_uses_libs - if tag == usesLibOptTag && lib.DexJarBuildPath.PathOrNil() == nil { + if tag == usesLibOptTag && javaInfo.DexJarBuildPath.PathOrNil() == nil { u.shouldDisableDexpreopt = true return } @@ -2054,7 +2070,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext libName = *ulib.ProvidesUsesLib } clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional, - lib.DexJarBuildPath.PathOrNil(), lib.DexJarInstallPath, + javaInfo.DexJarBuildPath.PathOrNil(), lib.DexJarInstallPath, lib.ClassLoaderContexts) } else if ctx.Config().AllowMissingDependencies() { ctx.AddMissingDependencies([]string{dep}) @@ -2147,3 +2163,29 @@ func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk andr classLoaderContexts *dexpreopt.ClassLoaderContextMap) { u.verifyUsesLibraries(ctx, apk, nil, classLoaderContexts) // for APKs manifest_check does not write output file } + +// androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in +// the same way. +type androidApp interface { + android.Module + Privileged() bool + InstallApkName() string + OutputFile() android.Path + JacocoReportClassesFile() android.Path + Certificate() Certificate + BaseModuleName() string + PrivAppAllowlist() android.OptionalPath +} + +var _ androidApp = (*AndroidApp)(nil) +var _ androidApp = (*AndroidAppImport)(nil) +var _ androidApp = (*AndroidTestHelperApp)(nil) + +func setCommonAppInfo(appInfo *AppInfo, m androidApp) { + appInfo.Privileged = m.Privileged() + appInfo.OutputFile = m.OutputFile() + appInfo.InstallApkName = m.InstallApkName() + appInfo.JacocoReportClassesFile = m.JacocoReportClassesFile() + appInfo.Certificate = m.Certificate() + appInfo.PrivAppAllowlist = m.PrivAppAllowlist() +} diff --git a/java/app_import.go b/java/app_import.go index 919266f28..37c673ca0 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -354,6 +354,12 @@ func (a *AndroidAppImport) stripEmbeddedJniLibsUnusedArch( func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.generateAndroidBuildActions(ctx) + + appInfo := &AppInfo{ + Prebuilt: true, + } + setCommonAppInfo(appInfo, a) + android.SetProvider(ctx, AppInfoProvider, appInfo) } func (a *AndroidAppImport) InstallApkName() string { diff --git a/java/app_set.go b/java/app_set.go index 7997570aa..2e9d31410 100644 --- a/java/app_set.go +++ b/java/app_set.go @@ -192,6 +192,11 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) }, ) + android.SetProvider(ctx, AppInfoProvider, &AppInfo{ + AppSet: true, + Privileged: as.Privileged(), + OutputFile: as.OutputFile(), + }) } func (as *AndroidAppSet) InstallBypassMake() bool { return true } diff --git a/java/base.go b/java/base.go index 21ad73f84..fccc80691 100644 --- a/java/base.go +++ b/java/base.go @@ -658,11 +658,11 @@ func (j *Module) checkSdkVersions(ctx android.ModuleContext) { // See rank() for details. ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(module) - _, isJavaLibrary := android.OtherModuleProvider(ctx, module, JavaLibraryInfoProvider) + libInfo, isJavaLibrary := android.OtherModuleProvider(ctx, module, JavaLibraryInfoProvider) _, isAndroidLibrary := android.OtherModuleProvider(ctx, module, AndroidLibraryInfoProvider) _, isJavaAconfigLibrary := android.OtherModuleProvider(ctx, module, android.CodegenInfoProvider) // Exclude java_aconfig_library modules to maintain consistency with existing behavior. - if (isJavaLibrary && !isJavaAconfigLibrary) || isAndroidLibrary { + if (isJavaLibrary && !libInfo.Prebuilt && !isJavaAconfigLibrary) || isAndroidLibrary { // TODO(satayev): cover other types as well, e.g. imports switch tag { case bootClasspathTag, sdkLibTag, libTag, staticLibTag, java9LibTag: diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 7a3c21e44..a09416dc4 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -41,6 +41,10 @@ func registerBootclasspathFragmentBuildComponents(ctx android.RegistrationContex ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootclasspathFragmentFactory) } +type BootclasspathFragmentInfo struct{} + +var BootclasspathFragmentInfoProvider = blueprint.NewProvider[BootclasspathFragmentInfo]() + // BootclasspathFragmentSdkMemberType is the member type used to add bootclasspath_fragments to // the SDK snapshot. It is exported for use by apex. var BootclasspathFragmentSdkMemberType = &bootclasspathFragmentMemberType{ @@ -557,6 +561,8 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo if !ctx.IsFinalModule(ctx.Module()) { b.HideFromMake() } + + android.SetProvider(ctx, BootclasspathFragmentInfoProvider, BootclasspathFragmentInfo{}) } // getProfileProviderApex returns the name of the apex that provides a boot image profile, or an diff --git a/java/java.go b/java/java.go index c5dee0c97..0a4a77170 100644 --- a/java/java.go +++ b/java/java.go @@ -259,7 +259,6 @@ type AndroidLibraryDependencyInfo struct { } type UsesLibraryDependencyInfo struct { - DexJarBuildPath OptionalDexJarPath DexJarInstallPath android.Path ClassLoaderContexts dexpreopt.ClassLoaderContextMap } @@ -403,13 +402,6 @@ type JavaInfo struct { BuiltInstalled string - // ApexSystemServerDexpreoptInstalls stores the list of dexpreopt artifacts if this is a system server - // jar in an apex. - ApexSystemServerDexpreoptInstalls []DexpreopterInstall - - // ApexSystemServerDexJars stores the list of dex jars if this is a system server jar in an apex. - ApexSystemServerDexJars android.Paths - // The config is used for two purposes: // - Passing dexpreopt information about libraries from Soong to Make. This is needed when // a <uses-library> is defined in Android.bp, but used in Android.mk (see dex_preopt_config_merger.py). @@ -418,10 +410,6 @@ type JavaInfo struct { // dexpreopt another partition). ConfigPath android.WritablePath - // The path to the profile on host that dexpreopter generates. This is used as the input for - // dex2oat. - OutputProfilePathOnHost android.Path - LogtagsSrcs android.Paths ProguardDictionary android.OptionalPath @@ -438,14 +426,39 @@ type JavaInfo struct { // True if profile-guided optimization is actually enabled. ProfileGuided bool + + Stem string + + DexJarBuildPath OptionalDexJarPath + + DexpreopterInfo *DexpreopterInfo } var JavaInfoProvider = blueprint.NewProvider[*JavaInfo]() -type JavaLibraryInfo struct{} +type DexpreopterInfo struct { + // The path to the profile on host that dexpreopter generates. This is used as the input for + // dex2oat. + OutputProfilePathOnHost android.Path + // If the java module is to be installed into an APEX, this list contains information about the + // dexpreopt outputs to be installed on devices. Note that these dexpreopt outputs are installed + // outside of the APEX. + ApexSystemServerDexpreoptInstalls []DexpreopterInstall + + // ApexSystemServerDexJars returns the list of dex jars if this is an apex system server jar. + ApexSystemServerDexJars android.Paths +} + +type JavaLibraryInfo struct { + Prebuilt bool +} var JavaLibraryInfoProvider = blueprint.NewProvider[JavaLibraryInfo]() +type JavaDexImportInfo struct{} + +var JavaDexImportInfoProvider = blueprint.NewProvider[JavaDexImportInfo]() + // SyspropPublicStubInfo contains info about the sysprop public stub library that corresponds to // the sysprop implementation library. type SyspropPublicStubInfo struct { @@ -1127,7 +1140,9 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { TopLevelTarget: j.sourceProperties.Top_level_test_target, }) - android.SetProvider(ctx, JavaLibraryInfoProvider, JavaLibraryInfo{}) + android.SetProvider(ctx, JavaLibraryInfoProvider, JavaLibraryInfo{ + Prebuilt: false, + }) if javaInfo != nil { setExtraJavaInfo(ctx, j, javaInfo) @@ -1137,11 +1152,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { javaInfo.BootDexJarPath = j.bootDexJarPath javaInfo.UncompressDexState = j.uncompressDexState javaInfo.Active = j.active - javaInfo.ApexSystemServerDexpreoptInstalls = j.apexSystemServerDexpreoptInstalls - javaInfo.ApexSystemServerDexJars = j.apexSystemServerDexJars javaInfo.BuiltInstalled = j.builtInstalled javaInfo.ConfigPath = j.configPath - javaInfo.OutputProfilePathOnHost = j.outputProfilePathOnHost javaInfo.LogtagsSrcs = j.logtagsSrcs javaInfo.ProguardDictionary = j.proguardDictionary javaInfo.ProguardUsageZip = j.proguardUsageZip @@ -3229,6 +3241,10 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { setExtraJavaInfo(ctx, j, javaInfo) android.SetProvider(ctx, JavaInfoProvider, javaInfo) + android.SetProvider(ctx, JavaLibraryInfoProvider, JavaLibraryInfo{ + Prebuilt: true, + }) + ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, "") ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, ".jar") @@ -3508,6 +3524,12 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), j.Stem()+".jar", dexOutputFile) } + + javaInfo := &JavaInfo{} + setExtraJavaInfo(ctx, j, javaInfo) + android.SetProvider(ctx, JavaInfoProvider, javaInfo) + + android.SetProvider(ctx, JavaDexImportInfoProvider, JavaDexImportInfo{}) } func (j *DexImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath { @@ -3695,7 +3717,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.ModuleProxy, } } clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, optional, - dep.UsesLibraryDependencyInfo.DexJarBuildPath.PathOrNil(), + dep.DexJarBuildPath.PathOrNil(), dep.UsesLibraryDependencyInfo.DexJarInstallPath, dep.UsesLibraryDependencyInfo.ClassLoaderContexts) } else { clcMap.AddContextMap(dep.UsesLibraryDependencyInfo.ClassLoaderContexts, depName) @@ -3779,7 +3801,6 @@ func setExtraJavaInfo(ctx android.ModuleContext, module android.Module, javaInfo if ulDep, ok := module.(UsesLibraryDependency); ok { javaInfo.UsesLibraryDependencyInfo = &UsesLibraryDependencyInfo{ - DexJarBuildPath: ulDep.DexJarBuildPath(ctx), DexJarInstallPath: ulDep.DexJarInstallPath(), ClassLoaderContexts: ulDep.ClassLoaderContexts(), } @@ -3808,4 +3829,22 @@ func setExtraJavaInfo(ctx android.ModuleContext, module android.Module, javaInfo Stubs: stubs, } } + + if st, ok := module.(ModuleWithStem); ok { + javaInfo.Stem = st.Stem() + } + + if mm, ok := module.(interface { + DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath + }); ok { + javaInfo.DexJarBuildPath = mm.DexJarBuildPath(ctx) + } + + if di, ok := module.(DexpreopterInterface); ok { + javaInfo.DexpreopterInfo = &DexpreopterInfo{ + OutputProfilePathOnHost: di.OutputProfilePathOnHost(), + ApexSystemServerDexpreoptInstalls: di.ApexSystemServerDexpreoptInstalls(), + ApexSystemServerDexJars: di.ApexSystemServerDexJars(), + } + } } diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index d4d2fb5bb..363521a7f 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -43,6 +43,13 @@ func registerPlatformCompatConfigBuildComponents(ctx android.RegistrationContext ctx.RegisterModuleType("global_compat_config", globalCompatConfigFactory) } +type PlatformCompatConfigInfo struct { + CompatConfig android.OutputPath + SubDir string +} + +var PlatformCompatConfigInfoProvider = blueprint.NewProvider[PlatformCompatConfigInfo]() + var PrepareForTestWithPlatformCompatConfig = android.FixtureRegisterWithContext(registerPlatformCompatConfigBuildComponents) func platformCompatConfigPath(ctx android.PathContext) android.OutputPath { @@ -124,6 +131,11 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon rule.Build(configFileName, "Extract compat/compat_config.xml and install it") ctx.InstallFile(p.installDirPath, p.configFile.Base(), p.configFile) ctx.SetOutputFiles(android.Paths{p.configFile}, "") + + android.SetProvider(ctx, PlatformCompatConfigInfoProvider, PlatformCompatConfigInfo{ + CompatConfig: p.CompatConfig(), + SubDir: p.SubDir(), + }) } func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { diff --git a/java/rro.go b/java/rro.go index d9f4ff7c8..f7f85f001 100644 --- a/java/rro.go +++ b/java/rro.go @@ -34,6 +34,15 @@ func RegisterRuntimeResourceOverlayBuildComponents(ctx android.RegistrationConte ctx.RegisterModuleType("override_runtime_resource_overlay", OverrideRuntimeResourceOverlayModuleFactory) } +type RuntimeResourceOverlayInfo struct { + OutputFile android.Path + Certificate Certificate + Theme string + OverriddenManifestPackageName string +} + +var RuntimeResourceOverlayInfoProvider = blueprint.NewProvider[RuntimeResourceOverlayInfo]() + type RuntimeResourceOverlay struct { android.ModuleBase android.DefaultableModuleBase @@ -207,6 +216,12 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC AconfigTextFiles: aconfigTextFilePaths, }) + android.SetProvider(ctx, RuntimeResourceOverlayInfoProvider, RuntimeResourceOverlayInfo{ + OutputFile: r.OutputFile(), + Certificate: r.Certificate(), + Theme: r.Theme(), + }) + buildComplianceMetadata(ctx) } diff --git a/java/sdk_library.go b/java/sdk_library.go index cf31b5095..7944bb2a8 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -702,7 +702,7 @@ func (paths *scopePaths) extractStubsLibraryInfoFromDependency(ctx android.Modul paths.stubsHeaderPath = lib.HeaderJars paths.stubsImplPath = lib.ImplementationJars - libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider).UsesLibraryDependencyInfo + libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider) paths.stubsDexJarPath = libDep.DexJarBuildPath paths.exportableStubsDexJarPath = libDep.DexJarBuildPath return nil @@ -718,7 +718,7 @@ func (paths *scopePaths) extractEverythingStubsLibraryInfoFromDependency(ctx and paths.stubsImplPath = lib.ImplementationJars } - libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider).UsesLibraryDependencyInfo + libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider) paths.stubsDexJarPath = libDep.DexJarBuildPath return nil } else { @@ -732,7 +732,7 @@ func (paths *scopePaths) extractExportableStubsLibraryInfoFromDependency(ctx and paths.stubsImplPath = lib.ImplementationJars } - libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider).UsesLibraryDependencyInfo + libDep := android.OtherModuleProviderOrDefault(ctx, dep, JavaInfoProvider) paths.exportableStubsDexJarPath = libDep.DexJarBuildPath return nil } else { @@ -1017,10 +1017,6 @@ func (c *commonToSdkLibraryAndImport) generateCommonBuildActions(ctx android.Mod removedApiFilePaths[kind] = removedApiFilePath } - javaInfo := &JavaInfo{} - setExtraJavaInfo(ctx, ctx.Module(), javaInfo) - android.SetProvider(ctx, JavaInfoProvider, javaInfo) - return SdkLibraryInfo{ EverythingStubDexJarPaths: everythingStubPaths, ExportableStubDexJarPaths: exportableStubPaths, @@ -1227,6 +1223,8 @@ type SdkLibraryInfo struct { // Whether if this can be used as a shared library. SharedLibrary bool + + Prebuilt bool } var SdkLibraryInfoProvider = blueprint.NewProvider[SdkLibraryInfo]() @@ -1513,10 +1511,10 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) module.dexJarFile = makeDexJarPathFromPath(module.implLibraryInfo.DexJarFile.Path()) module.headerJarFile = module.implLibraryInfo.HeaderJars[0] module.implementationAndResourcesJar = module.implLibraryInfo.ImplementationAndResourcesJars[0] - module.apexSystemServerDexpreoptInstalls = module.implLibraryInfo.ApexSystemServerDexpreoptInstalls - module.apexSystemServerDexJars = module.implLibraryInfo.ApexSystemServerDexJars + module.apexSystemServerDexpreoptInstalls = module.implLibraryInfo.DexpreopterInfo.ApexSystemServerDexpreoptInstalls + module.apexSystemServerDexJars = module.implLibraryInfo.DexpreopterInfo.ApexSystemServerDexJars module.dexpreopter.configPath = module.implLibraryInfo.ConfigPath - module.dexpreopter.outputProfilePathOnHost = module.implLibraryInfo.OutputProfilePathOnHost + module.dexpreopter.outputProfilePathOnHost = module.implLibraryInfo.DexpreopterInfo.OutputProfilePathOnHost // Properties required for Library.AndroidMkEntries module.logtagsSrcs = module.implLibraryInfo.LogtagsSrcs @@ -1582,7 +1580,12 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) setOutputFilesFromJavaInfo(ctx, module.implLibraryInfo) } + javaInfo := &JavaInfo{} + setExtraJavaInfo(ctx, ctx.Module(), javaInfo) + android.SetProvider(ctx, JavaInfoProvider, javaInfo) + sdkLibInfo.GeneratingLibs = generatingLibs + sdkLibInfo.Prebuilt = false android.SetProvider(ctx, SdkLibraryInfoProvider, sdkLibInfo) } @@ -2236,7 +2239,12 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo setOutputFilesFromJavaInfo(ctx, module.implLibraryInfo) } + javaInfo := &JavaInfo{} + setExtraJavaInfo(ctx, ctx.Module(), javaInfo) + android.SetProvider(ctx, JavaInfoProvider, javaInfo) + sdkLibInfo.GeneratingLibs = generatingLibs + sdkLibInfo.Prebuilt = true android.SetProvider(ctx, SdkLibraryInfoProvider, sdkLibInfo) } diff --git a/java/sdk_library_internal.go b/java/sdk_library_internal.go index 578969223..f5feabeb4 100644 --- a/java/sdk_library_internal.go +++ b/java/sdk_library_internal.go @@ -936,6 +936,8 @@ func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleConte ctx.PackageFile(module.installDirPath, libName+".xml", module.outputFilePath) ctx.SetOutputFiles(android.OutputPaths{module.outputFilePath}.Paths(), "") + + etc.SetCommonPrebuiltEtcInfo(ctx, module) } func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries { |