Merge "Move requiredDeps to OverridableDepsMutator" into main
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index 9c71d92..bb73f0b 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -248,7 +248,7 @@
// Please only access the module's internal data through providers.
func getContainerUsingProviders(ctx OtherModuleProviderContext, m Module) string {
container := "system"
- commonInfo, _ := OtherModuleProvider(ctx, m, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, m, CommonModuleInfoProvider)
if commonInfo.Vendor || commonInfo.Proprietary || commonInfo.SocSpecific {
container = "vendor"
} else if commonInfo.ProductSpecific {
diff --git a/android/all_teams.go b/android/all_teams.go
index 5e76e53..18a050f 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -116,7 +116,7 @@
testOnly: testModInfo.TestOnly,
topLevelTestTarget: testModInfo.TopLevelTarget,
kind: ctx.ModuleType(module),
- teamName: OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).Team,
+ teamName: OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).Team,
}
t.teams_for_mods[module.Name()] = entry
diff --git a/android/androidmk.go b/android/androidmk.go
index 694f5d6..7845593 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -888,14 +888,14 @@
}
}
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
if commonInfo.SkipAndroidMkProcessing {
continue
}
if info, ok := OtherModuleProvider(ctx, mod, AndroidMkInfoProvider); ok {
// Deep copy the provider info since we need to modify the info later
info := deepCopyAndroidMkProviderInfo(info)
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
if info.PrimaryInfo.disabled() {
continue
}
@@ -1320,7 +1320,7 @@
// Please only access the module's internal data through providers.
func translateAndroidMkEntriesInfoModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
mod Module, providerInfo *AndroidMkProviderInfo) error {
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
if commonInfo.SkipAndroidMkProcessing {
return nil
}
@@ -1331,11 +1331,11 @@
aconfigUpdateAndroidMkInfos(ctx, mod, &info)
// Any new or special cases here need review to verify correct propagation of license information.
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
info.PrimaryInfo.write(w)
if len(info.ExtraInfo) > 0 {
for _, ei := range info.ExtraInfo {
- ei.fillInEntries(ctx, mod, &commonInfo)
+ ei.fillInEntries(ctx, mod, commonInfo)
ei.write(w)
}
}
diff --git a/android/base_module_context.go b/android/base_module_context.go
index eba3670..5cb9e71 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -410,7 +410,7 @@
return &aModule
}
- if !OtherModuleProviderOrDefault(b, module, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(b, module, CommonModuleInfoProvider).Enabled {
if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) {
if b.Config().AllowMissingDependencies() {
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
@@ -440,7 +440,7 @@
func (b *baseModuleContext) getDirectDepsProxyInternal(name string, tag blueprint.DependencyTag) []ModuleProxy {
var deps []ModuleProxy
b.VisitDirectDepsProxy(func(module ModuleProxy) {
- if OtherModuleProviderOrDefault(b, module, CommonModuleInfoProvider).BaseModuleName == name {
+ if OtherModulePointerProviderOrDefault(b, module, CommonModuleInfoProvider).BaseModuleName == name {
returnedTag := b.OtherModuleDependencyTag(module)
if tag == nil || returnedTag == tag {
deps = append(deps, module)
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index c15a206..16a3853 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -304,7 +304,7 @@
rowId := -1
ctx.VisitAllModuleProxies(func(module ModuleProxy) {
- commonInfo, _ := OtherModuleProvider(ctx, module, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider)
if !commonInfo.Enabled {
return
}
diff --git a/android/container.go b/android/container.go
index 5d223b8..547fe81 100644
--- a/android/container.go
+++ b/android/container.go
@@ -39,7 +39,7 @@
// Returns true if the dependency module is a stubs module
var depIsStubsModule exceptionHandleFunc = func(mctx ModuleContext, _ Module, dep ModuleProxy) bool {
- return OtherModuleProviderOrDefault(mctx, dep, CommonModuleInfoProvider).IsStubsModule
+ return OtherModulePointerProviderOrDefault(mctx, dep, CommonModuleInfoProvider).IsStubsModule
}
// Returns true if the dependency module belongs to any of the apexes.
diff --git a/android/gen_notice.go b/android/gen_notice.go
index ae83118..45f90f4 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -60,7 +60,7 @@
for _, name := range gm.For {
mods := ctx.ModuleVariantsFromName(m, name)
for _, mod := range mods {
- if !OtherModuleProviderOrDefault(ctx, mod, CommonModuleInfoProvider).Enabled { // don't depend on variants without build rules
+ if !OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider).Enabled { // don't depend on variants without build rules
continue
}
modules = append(modules, mod)
diff --git a/android/license_metadata.go b/android/license_metadata.go
index e79febb..0b880dd 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -65,7 +65,7 @@
var allDepMetadataDepSets []depset.DepSet[Path]
ctx.VisitDirectDepsProxy(func(dep ModuleProxy) {
- if !OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider).Enabled {
return
}
diff --git a/android/logtags.go b/android/logtags.go
index ef7a612..074f402 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -43,7 +43,7 @@
func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) {
var allLogtags Paths
ctx.VisitAllModuleProxies(func(module ModuleProxy) {
- if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ExportedToMake {
+ if !OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ExportedToMake {
return
}
if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok {
diff --git a/android/makevars.go b/android/makevars.go
index e1d947d..7017e7d 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -259,7 +259,7 @@
singletonDists.lock.Unlock()
ctx.VisitAllModuleProxies(func(m ModuleProxy) {
- commonInfo, _ := OtherModuleProvider(ctx, m, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, m, CommonModuleInfoProvider)
if provider, ok := OtherModuleProvider(ctx, m, ModuleMakeVarsInfoProvider); ok &&
commonInfo.Enabled {
mctx := &makeVarsContext{
diff --git a/android/module.go b/android/module.go
index 2bdf49a..a3fe837 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1496,7 +1496,7 @@
// Installation is still handled by Make, so anything hidden from Make is not
// installable.
info := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider)
- commonInfo := OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider)
if !commonInfo.HideFromMake && !commonInfo.SkipInstall {
installDeps = append(installDeps, info.TransitiveInstallFiles)
}
@@ -1513,7 +1513,7 @@
// should also install the output files of the given dependency and dependency tag.
func isInstallDepNeeded(ctx ModuleContext, dep ModuleProxy) bool {
// Don't add a dependency from the platform to a library provided by an apex.
- if OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant {
+ if OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant {
return false
}
// Only install modules if the dependency tag is an InstallDepNeeded tag.
@@ -1936,7 +1936,7 @@
IsPlatform bool
}
-var CommonModuleInfoProvider = blueprint.NewProvider[CommonModuleInfo]()
+var CommonModuleInfoProvider = blueprint.NewProvider[*CommonModuleInfo]()
type PrebuiltModuleInfo struct {
SourceExists bool
@@ -2344,7 +2344,7 @@
if mm, ok := m.module.(interface{ BaseModuleName() string }); ok {
commonData.BaseModuleName = mm.BaseModuleName()
}
- SetProvider(ctx, CommonModuleInfoProvider, commonData)
+ SetProvider(ctx, CommonModuleInfoProvider, &commonData)
if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil {
SetProvider(ctx, PrebuiltModuleInfoProvider, PrebuiltModuleInfo{
SourceExists: p.Prebuilt().SourceExists(),
@@ -2662,6 +2662,8 @@
return proptools.ConfigurableValueBool(ctx.Config().UseDebugArt())
case "selinux_ignore_neverallows":
return proptools.ConfigurableValueBool(ctx.Config().SelinuxIgnoreNeverallows())
+ case "always_use_prebuilt_sdks":
+ return proptools.ConfigurableValueBool(ctx.Config().AlwaysUsePrebuiltSdks())
default:
// TODO(b/323382414): Might add these on a case-by-case basis
ctx.OtherModulePropertyErrorf(m, property, fmt.Sprintf("TODO(b/323382414): Product variable %q is not yet supported in selects", variable))
diff --git a/android/neverallow.go b/android/neverallow.go
index a7bfd2d..5c90501 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -252,6 +252,7 @@
NotModuleType("prebuilt_system").
NotModuleType("prebuilt_first_stage_ramdisk").
NotModuleType("prebuilt_res").
+ NotModuleType("prebuilt_any").
Because("install_in_root is only for init_first_stage or librecovery_ui_ext."),
}
}
@@ -309,6 +310,10 @@
"trusty_tee_package_goog",
"trusty_tee_package",
// Trusty vm target names
+ "trusty_desktop_vm_arm64.bin",
+ "trusty_desktop_vm_x86_64.elf",
+ "trusty_desktop_test_vm_arm64.bin",
+ "trusty_desktop_test_vm_x86_64.elf",
"trusty_test_vm_arm64.bin",
"trusty_test_vm_x86_64.elf",
"trusty_test_vm_os_arm64.bin",
@@ -364,6 +369,7 @@
func createPrebuiltEtcBpDefineRule() Rule {
return NeverAllow().
ModuleType(
+ "prebuilt_any",
"prebuilt_usr_srec",
"prebuilt_priv_app",
"prebuilt_rfs",
@@ -381,6 +387,7 @@
"prebuilt_first_stage_ramdisk",
"prebuilt_radio",
"prebuilt_gpu",
+ "prebuilt_vendor_overlay",
).
DefinedInBpFile().
Because("module type not allowed to be defined in bp file")
diff --git a/android/package.go b/android/package.go
index 0f6a767..52bddf9 100644
--- a/android/package.go
+++ b/android/package.go
@@ -62,7 +62,7 @@
}
func (p *packageModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
- ctx.SetProvider(CommonModuleInfoProvider, CommonModuleInfo{
+ ctx.SetProvider(CommonModuleInfoProvider, &CommonModuleInfo{
Enabled: true,
PrimaryLicensesProperty: p.primaryLicensesProperty,
})
diff --git a/android/paths.go b/android/paths.go
index f7fcd35..977473f 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -683,7 +683,7 @@
if module == nil {
return nil, missingDependencyError{[]string{moduleName}}
}
- if !OtherModuleProviderOrDefault(ctx, *module, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(ctx, *module, CommonModuleInfoProvider).Enabled {
return nil, missingDependencyError{[]string{moduleName}}
}
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 0178f76..1ff009b 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -358,7 +358,7 @@
}
func IsModulePreferredProxy(ctx OtherModuleProviderContext, module ModuleProxy) bool {
- if OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
+ if OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
// A source module that has been replaced by a prebuilt counterpart.
return false
}
@@ -397,7 +397,7 @@
// the right module. This function is only safe to call after all TransitionMutators
// have run, e.g. in GenerateAndroidBuildActions.
func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module {
- if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
+ if !OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
return module
}
if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleInfoProvider); ok {
diff --git a/android/provider.go b/android/provider.go
index d005daf..aae93ef 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -41,6 +41,14 @@
return value
}
+func OtherModulePointerProviderOrDefault[K *T, T any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+ if value, ok := OtherModuleProvider(ctx, module, provider); ok {
+ return value
+ }
+ var val T
+ return &val
+}
+
// ModuleProviderContext is a helper interface that is a subset of ModuleContext or BottomUpMutatorContext
// for use in ModuleProvider.
type ModuleProviderContext interface {
diff --git a/android/testing.go b/android/testing.go
index 08c8083..d2949ec 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1197,11 +1197,11 @@
info := OtherModuleProviderOrDefault(ctx, mod, AndroidMkInfoProvider)
aconfigUpdateAndroidMkInfos(ctx, mod, info)
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
if len(info.ExtraInfo) > 0 {
for _, ei := range info.ExtraInfo {
- ei.fillInEntries(ctx, mod, &commonInfo)
+ ei.fillInEntries(ctx, mod, commonInfo)
}
}
diff --git a/apex/apex.go b/apex/apex.go
index dc44e58..c6566e1 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1502,7 +1502,7 @@
func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module android.Module,
javaInfo *java.JavaInfo, dexImplementationJar android.Path) apexFile {
dirInApex := "javalib"
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
af := newApexFile(ctx, dexImplementationJar, commonInfo.BaseModuleName, dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = javaInfo.JacocoReportClassesFile
if lintInfo, ok := android.OtherModuleProvider(ctx, module, java.LintProvider); ok {
@@ -1608,7 +1608,7 @@
// modules. This is used in check* functions below.
func (a *apexBundle) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) {
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).CanHaveApexVariants {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).CanHaveApexVariants {
return false
}
// Filter-out unwanted depedendencies
@@ -1821,7 +1821,7 @@
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
return false
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider)
if !commonInfo.Enabled {
return false
}
@@ -1839,7 +1839,7 @@
if ch.IsStubs {
ctx.PropertyErrorf(propertyName, "%q is a stub. Remove it from the list.", depName)
}
- fi := apexFileForNativeLibrary(ctx, child, &commonInfo, ch, vctx.handleSpecialLibs)
+ fi := apexFileForNativeLibrary(ctx, child, commonInfo, ch, vctx.handleSpecialLibs)
fi.isJniLib = isJniLib
vctx.filesInfo = append(vctx.filesInfo, fi)
// Collect the list of stub-providing libs except:
@@ -1856,11 +1856,11 @@
case executableTag:
if ccInfo, ok := android.OtherModuleProvider(ctx, child, cc.CcInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, child, &commonInfo, ccInfo))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, child, commonInfo, ccInfo))
return true // track transitive dependencies
}
if _, ok := android.OtherModuleProvider(ctx, child, rust.RustInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, child, &commonInfo))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, child, commonInfo))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("binaries",
@@ -1868,7 +1868,7 @@
}
case shBinaryTag:
if csh, ok := android.OtherModuleProvider(ctx, child, sh.ShBinaryInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForShBinary(ctx, child, &commonInfo, &csh))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForShBinary(ctx, child, commonInfo, &csh))
} else {
ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName)
}
@@ -1922,7 +1922,7 @@
af.certificate = java.PresignedCertificate
vctx.filesInfo = append(vctx.filesInfo, af)
} else {
- vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, child, &commonInfo, appInfo)...)
+ vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, child, commonInfo, appInfo)...)
if !appInfo.Prebuilt && !appInfo.TestHelperApp {
return true // track transitive dependencies
}
@@ -1969,7 +1969,7 @@
}
case testTag:
if ccInfo, ok := android.OtherModuleProvider(ctx, child, cc.CcInfoProvider); ok {
- af := apexFileForExecutable(ctx, child, &commonInfo, ccInfo)
+ af := apexFileForExecutable(ctx, child, commonInfo, ccInfo)
af.class = nativeTest
vctx.filesInfo = append(vctx.filesInfo, af)
return true // track transitive dependencies
@@ -2006,7 +2006,7 @@
// tags used below are private (e.g. `cc.sharedDepTag`).
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
if ch, ok := android.OtherModuleProvider(ctx, child, cc.LinkableInfoProvider); ok {
- af := apexFileForNativeLibrary(ctx, child, &commonInfo, ch, vctx.handleSpecialLibs)
+ af := apexFileForNativeLibrary(ctx, child, commonInfo, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
if ch.IsStubs || ch.HasStubsVariants {
@@ -2068,7 +2068,7 @@
}
linkableInfo := android.OtherModuleProviderOrDefault(ctx, child, cc.LinkableInfoProvider)
- af := apexFileForNativeLibrary(ctx, child, &commonInfo, linkableInfo, vctx.handleSpecialLibs)
+ af := apexFileForNativeLibrary(ctx, child, commonInfo, linkableInfo, vctx.handleSpecialLibs)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
return true // track transitive dependencies
@@ -2100,7 +2100,7 @@
javaInfo := android.OtherModuleProviderOrDefault(ctx, child, java.JavaInfoProvider)
af := apexFileForJavaModule(ctx, child, javaInfo)
vctx.filesInfo = append(vctx.filesInfo, af)
- if profileAf := apexFileForJavaModuleProfile(ctx, &commonInfo, javaInfo); profileAf != nil {
+ if profileAf := apexFileForJavaModuleProfile(ctx, commonInfo, javaInfo); profileAf != nil {
vctx.filesInfo = append(vctx.filesInfo, *profileAf)
}
return true // track transitive dependencies
@@ -2116,7 +2116,7 @@
ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
} else if android.IsVintfDepTag(depTag) {
if vf, ok := android.OtherModuleProvider(ctx, child, android.VintfFragmentInfoProvider); ok {
- apexFile := apexFileForVintfFragment(ctx, child, &commonInfo, &vf)
+ apexFile := apexFileForVintfFragment(ctx, child, commonInfo, &vf)
vctx.filesInfo = append(vctx.filesInfo, apexFile)
}
}
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 0bf4ba7..797f47b 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -164,7 +164,7 @@
prebuiltInfo, exists := android.OtherModuleProvider(ctx, m, android.PrebuiltInfoProvider)
// Use prebuiltInfoProvider to filter out non apex soong modules.
// Use HideFromMake to filter out the unselected variants of a specific apex.
- if exists && !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).HideFromMake {
+ if exists && !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).HideFromMake {
prebuiltInfos = append(prebuiltInfos, prebuiltInfo)
}
})
diff --git a/apex/builder.go b/apex/builder.go
index 8042a3b..23c2ed8 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -1111,7 +1111,7 @@
// Skip dependencies that are only available to APEXes; they are developed with updatability
// in mind and don't need manual approval.
- if android.OtherModuleProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
+ if android.OtherModulePointerProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
return !externalDep
}
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index a076d47..d78a907 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -85,7 +85,7 @@
func (singleton *sizesSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var deps android.Paths
ctx.VisitAllModuleProxies(func(m android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).ExportedToMake {
+ if !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).ExportedToMake {
return
}
filePaths, ok := android.OtherModuleProvider(ctx, m, fileSizeMeasurerKey)
diff --git a/cc/cc.go b/cc/cc.go
index ae6f3b0..85d2ebf 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3422,7 +3422,7 @@
return
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if commonInfo.Target.Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q (%s) and %q (%s)", ctx.ModuleName(), ctx.Os().Name, depName, dep.Target().Os.Name)
return
@@ -3676,7 +3676,7 @@
c.sabi.Properties.ReexportedSystemIncludes, depExporterInfo.SystemIncludeDirs.Strings()...)
}
- makeLibName := MakeLibName(ccInfo, linkableInfo, &commonInfo, commonInfo.BaseModuleName) + libDepTag.makeSuffix
+ makeLibName := MakeLibName(ccInfo, linkableInfo, commonInfo, commonInfo.BaseModuleName) + libDepTag.makeSuffix
switch {
case libDepTag.header():
c.Properties.AndroidMkHeaderLibs = append(
@@ -3703,7 +3703,7 @@
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
- c.Properties.AndroidMkRuntimeLibs, MakeLibName(ccInfo, linkableInfo, &commonInfo,
+ c.Properties.AndroidMkRuntimeLibs, MakeLibName(ccInfo, linkableInfo, commonInfo,
commonInfo.BaseModuleName)+libDepTag.makeSuffix)
case objDepTag:
depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
@@ -3779,7 +3779,7 @@
// platform APIs, use stubs only when it is from an APEX (and not from
// platform) However, for host, ramdisk, vendor_ramdisk, recovery or
// bootstrap modules, always link to non-stub variant
- isNotInPlatform := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider).NotInPlatform
+ isNotInPlatform := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider).NotInPlatform
useStubs = isNotInPlatform && !bootstrap
} else {
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 0dcf2cf..45b1580 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -44,7 +44,7 @@
// On ARMv9 and later, Pointer Authentication Codes (PAC) are mandatory,
// so -fstack-protector is unnecessary.
"armv9-a": []string{
- "-march=armv8.2-a+dotprod",
+ "-march=armv9-a",
"-mbranch-protection=standard",
"-fno-stack-protector",
},
diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go
index ddc86c2..d2f88ef 100644
--- a/cc/config/x86_linux_bionic_host.go
+++ b/cc/config/x86_linux_bionic_host.go
@@ -28,7 +28,7 @@
"-fno-omit-frame-pointer",
"-U_FORTIFY_SOURCE",
- "-D_FORTIFY_SOURCE=2",
+ "-D_FORTIFY_SOURCE=3",
"-fstack-protector-strong",
// From x86_64_device
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index c070050..c3f25aa 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -29,7 +29,7 @@
"-fno-omit-frame-pointer",
"-U_FORTIFY_SOURCE",
- "-D_FORTIFY_SOURCE=2",
+ "-D_FORTIFY_SOURCE=3",
"-fstack-protector",
"--gcc-toolchain=${LinuxGccRoot}",
diff --git a/cc/fuzz.go b/cc/fuzz.go
index ba34387..79874fc 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -486,7 +486,7 @@
sharedLibsInstallDirPrefix = "lib/vendor"
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
isHost := commonInfo.Target.Os.Class == android.Host
hostOrTargetString := "target"
if commonInfo.Target.HostCross {
diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go
index a59cc11..b96a779 100644
--- a/cc/ndk_abi.go
+++ b/cc/ndk_abi.go
@@ -40,7 +40,7 @@
func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
@@ -78,7 +78,7 @@
func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 82a19d0..1677862 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -212,7 +212,7 @@
var licensePaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index db99a53..b704ef4 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -79,7 +79,7 @@
minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer,undefined",
"-fno-sanitize-recover=integer,undefined"}
- memtagStackCommonFlags = []string{"-march=armv8-a+memtag"}
+ memtagStackCommonFlags = []string{"-Xclang -target-feature -Xclang +mte"}
memtagStackLlvmFlags = []string{"-dom-tree-reachability-max-bbs-to-explore=128"}
hostOnlySanitizeFlags = []string{"-fno-sanitize-recover=all"}
diff --git a/cc/tidy.go b/cc/tidy.go
index e8e1dc2..bf273e9 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -220,7 +220,7 @@
// (1) Collect all obj/tidy files into OS-specific groups.
ctx.VisitAllModuleVariantProxies(module, func(variant android.ModuleProxy) {
- osName := android.OtherModuleProviderOrDefault(ctx, variant, android.CommonModuleInfoProvider).Target.Os.Name
+ osName := android.OtherModulePointerProviderOrDefault(ctx, variant, android.CommonModuleInfoProvider).Target.Os.Name
info := android.OtherModuleProviderOrDefault(ctx, variant, CcObjectInfoProvider)
addToOSGroup(osName, info.ObjFiles, allObjFileGroups, subsetObjFileGroups)
addToOSGroup(osName, info.TidyFiles, allTidyFileGroups, subsetTidyFileGroups)
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 9cec9db..e57384f 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -464,7 +464,7 @@
func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy(
ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
- return android.OtherModuleProviderOrDefault(
+ return android.OtherModulePointerProviderOrDefault(
ctx, target, android.CommonModuleInfoProvider).ReplacedByPrebuilt
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index d0da728..3b0c032 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -81,6 +81,7 @@
ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
+ ctx.RegisterModuleType("prebuilt_vendor_overlay", PrebuiltVendorOverlayFactory)
ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
@@ -89,6 +90,7 @@
ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
+ ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory)
ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
@@ -115,12 +117,6 @@
// set. May use globs in filenames.
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
- // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
- // set filename_from_src. This can be used to install each source file to a different directory
- // and/or change filenames when files are installed. Must be exactly one entry per source file,
- // which means care must be taken if srcs has globs.
- Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
-
// Optional name for the installed file. If unspecified, name of the module is used as the file
// name. Only available when using a single source (src).
Filename *string `android:"arch_variant"`
@@ -159,6 +155,20 @@
Oem_specific *bool `android:"arch_variant"`
}
+// Dsts is useful in that it allows prebuilt_* modules to easily map the source files to the
+// install path within the partition. Dsts values are allowed to contain filepath separator
+// so that the source files can be installed in subdirectories within the partition.
+// However, this functionality should not be supported for prebuilt_root module type, as it
+// allows the module to install to any arbitrary location. Thus, this property is defined in
+// a separate struct so that it's not available to be set in prebuilt_root module type.
+type PrebuiltDstsProperties struct {
+ // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
+ // set filename_from_src. This can be used to install each source file to a different directory
+ // and/or change filenames when files are installed. Must be exactly one entry per source file,
+ // which means care must be taken if srcs has globs.
+ Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
+}
+
type prebuiltSubdirProperties struct {
// Optional subdirectory under which this file is installed into, cannot be specified with
// relative_install_path, prefer relative_install_path.
@@ -194,6 +204,8 @@
properties PrebuiltEtcProperties
+ dstsProperties PrebuiltDstsProperties
+
// rootProperties is used to return the value of the InstallInRoot() method. Currently, only
// prebuilt_avb and prebuilt_root modules use this.
rootProperties prebuiltRootProperties
@@ -384,7 +396,7 @@
if srcProperty.IsPresent() && len(srcsProperty) > 0 {
ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
}
- dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
+ dstsProperty := p.dstsProperties.Dsts.GetOrDefault(ctx, nil)
if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
}
@@ -612,6 +624,7 @@
p.AddProperties(&p.properties)
p.AddProperties(&p.subdirProperties)
p.AddProperties(&p.rootProperties)
+ p.AddProperties(&p.dstsProperties)
}
func InitPrebuiltRootModule(p *PrebuiltEtc) {
@@ -623,6 +636,7 @@
func InitPrebuiltAvbModule(p *PrebuiltEtc) {
p.installDirBase = "avb"
p.AddProperties(&p.properties)
+ p.AddProperties(&p.dstsProperties)
p.rootProperties.Install_in_root = proptools.BoolPtr(true)
}
@@ -666,6 +680,20 @@
return module
}
+// prebuilt_any is a special module where the module can define the subdirectory that the files
+// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
+// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
+// modules allow installing the file at the desired location, introduce a new prebuilt_* module
+// type instead.
+func PrebuiltAnyFactory() android.Module {
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, ".")
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(module)
+ return module
+}
+
// prebuilt_etc_host is for a host prebuilt artifact that is installed in
// <partition>/etc/<sub_dir> directory.
func PrebuiltEtcCaCertsFactory() android.Module {
@@ -1052,6 +1080,16 @@
return module
}
+// prebuilt_vendor_overlay is for a prebuilt artifact in <partition>/vendor_overlay directory.
+func PrebuiltVendorOverlayFactory() android.Module {
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "vendor_overlay")
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(module)
+ return module
+}
+
// prebuilt_sbin installs files in <partition>/sbin directory.
func PrebuiltSbinFactory() android.Module {
module := &PrebuiltEtc{}
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 45a8620..3f6348d 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -780,6 +780,31 @@
builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo)
}
+ if a.partitionProps.Super_partition_name != nil {
+ superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+ if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
+ // cat dynamic_partition_info.txt
+ builder.Command().Text("cat").Input(info.DynamicPartitionsInfo).Textf(" >> %s", miscInfo)
+ } else {
+ ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
+ }
+ }
+ bootImgNames := []*string{
+ a.partitionProps.Boot_partition_name,
+ a.partitionProps.Init_boot_partition_name,
+ a.partitionProps.Vendor_boot_partition_name,
+ }
+ for _, bootImgName := range bootImgNames {
+ if bootImgName == nil {
+ continue
+ }
+
+ bootImg := ctx.GetDirectDepProxyWithTag(proptools.String(bootImgName), filesystemDepTag)
+ bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider)
+ // cat avb_ metadata of the boot images
+ builder.Command().Text("cat").Input(bootImgInfo.PropFileForMiscInfo).Textf(" >> %s", miscInfo)
+ }
+
builder.Build("misc_info", "Building misc_info")
return miscInfo
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index c06c200..7959365 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -238,11 +238,12 @@
// Set BootimgInfo for building target_files.zip
dtbPath := b.getDtbPath(ctx)
android.SetProvider(ctx, BootimgInfoProvider, BootimgInfo{
- Cmdline: b.properties.Cmdline,
- Kernel: kernelPath,
- Dtb: dtbPath,
- Bootconfig: b.getBootconfigPath(ctx),
- Output: output,
+ Cmdline: b.properties.Cmdline,
+ Kernel: kernelPath,
+ Dtb: dtbPath,
+ Bootconfig: b.getBootconfigPath(ctx),
+ Output: output,
+ PropFileForMiscInfo: b.buildPropFileForMiscInfo(ctx),
})
extractedPublicKey := android.PathForModuleOut(ctx, b.partitionName()+".avbpubkey")
@@ -285,11 +286,12 @@
var BootimgInfoProvider = blueprint.NewProvider[BootimgInfo]()
type BootimgInfo struct {
- Cmdline []string
- Kernel android.Path
- Dtb android.Path
- Bootconfig android.Path
- Output android.Path
+ Cmdline []string
+ Kernel android.Path
+ Dtb android.Path
+ Bootconfig android.Path
+ Output android.Path
+ PropFileForMiscInfo android.Path
}
func (b *bootimg) getKernelPath(ctx android.ModuleContext) android.Path {
@@ -508,6 +510,25 @@
return propFile, deps
}
+func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path {
+ var sb strings.Builder
+ addStr := func(name string, value string) {
+ fmt.Fprintf(&sb, "%s=%s\n", name, value)
+ }
+
+ bootImgType := proptools.String(b.properties.Boot_image_type)
+ addStr("avb_"+bootImgType+"_add_hash_footer_args", "TODO(b/398036609)")
+ if b.properties.Avb_private_key != nil {
+ addStr("avb_"+bootImgType+"_algorithm", proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096"))
+ addStr("avb_"+bootImgType+"_key_path", android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)).String())
+ addStr("avb_"+bootImgType+"_rollback_index_location", strconv.Itoa(proptools.Int(b.properties.Avb_rollback_index_location)))
+ }
+
+ propFile := android.PathForModuleOut(ctx, "prop_for_misc_info")
+ android.WriteFileRuleVerbatim(ctx, propFile, sb.String())
+ return propFile
+}
+
var _ android.AndroidMkEntriesProvider = (*bootimg)(nil)
// Implements android.AndroidMkEntriesProvider
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index d5188d7..b854880 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -375,6 +375,20 @@
return fs == unknown
}
+// Type string that build_image.py accepts.
+func (t fsType) String() string {
+ switch t {
+ // TODO(372522486): add more types like f2fs, erofs, etc.
+ case ext4Type:
+ return "ext4"
+ case erofsType:
+ return "erofs"
+ case f2fsType:
+ return "f2fs"
+ }
+ panic(fmt.Errorf("unsupported fs type %d", t))
+}
+
type InstalledFilesStruct struct {
Txt android.Path
Json android.Path
@@ -1031,21 +1045,7 @@
deps = append(deps, path)
}
- // Type string that build_image.py accepts.
- fsTypeStr := func(t fsType) string {
- switch t {
- // TODO(372522486): add more types like f2fs, erofs, etc.
- case ext4Type:
- return "ext4"
- case erofsType:
- return "erofs"
- case f2fsType:
- return "f2fs"
- }
- panic(fmt.Errorf("unsupported fs type %v", t))
- }
-
- addStr("fs_type", fsTypeStr(f.fsType(ctx)))
+ addStr("fs_type", f.fsType(ctx).String())
addStr("mount_point", proptools.StringDefault(f.properties.Mount_point, "/"))
addStr("use_dynamic_partition_size", "true")
addPath("ext_mkuserimg", ctx.Config().HostToolPath(ctx, "mkuserimg_mke2fs"))
@@ -1064,28 +1064,7 @@
addPath("avb_key_path", key)
}
addStr("partition_name", f.partitionName())
- avb_add_hashtree_footer_args := ""
- if !proptools.BoolDefault(f.properties.Use_fec, true) {
- avb_add_hashtree_footer_args += " --do_not_generate_fec"
- }
- hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256")
- avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
- if f.properties.Rollback_index != nil {
- rollbackIndex := proptools.Int(f.properties.Rollback_index)
- if rollbackIndex < 0 {
- ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
- }
- avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex)
- }
- avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable())
- // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because
- // the build number changed, and we don't want to trigger rebuilds solely based on the build
- // number.
- avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx))
- if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" {
- avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch))
- }
- addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args)
+ addStr("avb_add_hashtree_footer_args", f.getAvbAddHashtreeFooterArgs(ctx))
}
if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil {
@@ -1134,7 +1113,7 @@
addStr("f2fs_sparse_flag", "-S")
}
}
- f.checkFsTypePropertyError(ctx, fst, fsTypeStr(fst))
+ f.checkFsTypePropertyError(ctx, fst, fst.String())
if f.properties.Partition_size != nil {
addStr("partition_size", strconv.FormatInt(*f.properties.Partition_size, 10))
@@ -1165,6 +1144,31 @@
return propFile, deps
}
+func (f *filesystem) getAvbAddHashtreeFooterArgs(ctx android.ModuleContext) string {
+ avb_add_hashtree_footer_args := ""
+ if !proptools.BoolDefault(f.properties.Use_fec, true) {
+ avb_add_hashtree_footer_args += " --do_not_generate_fec"
+ }
+ hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256")
+ avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
+ if f.properties.Rollback_index != nil {
+ rollbackIndex := proptools.Int(f.properties.Rollback_index)
+ if rollbackIndex < 0 {
+ ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
+ }
+ avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex)
+ }
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable())
+ // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because
+ // the build number changed, and we don't want to trigger rebuilds solely based on the build
+ // number.
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx))
+ if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" {
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch))
+ }
+ return avb_add_hashtree_footer_args
+}
+
// This method checks if there is any property set for the fstype(s) other than
// the current fstype.
func (f *filesystem) checkFsTypePropertyError(ctx android.ModuleContext, t fsType, fs string) {
@@ -1469,7 +1473,7 @@
deps := f.gatherFilteredPackagingSpecs(ctx)
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
return false
}
for _, ps := range android.OtherModuleProviderOrDefault(
@@ -1490,7 +1494,7 @@
var requireModules []android.ModuleProxy
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
return false
}
_, parentInPackage := modulesInPackageByModule[parent]
diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go
index 58ebcc4..0ba0a90 100644
--- a/fsgen/boot_imgs.go
+++ b/fsgen/boot_imgs.go
@@ -69,6 +69,7 @@
ctx.CreateModule(
filesystem.BootimgFactory,
&filesystem.BootimgProperties{
+ Boot_image_type: proptools.StringPtr("boot"),
Kernel_prebuilt: proptools.StringPtr(":" + kernelFilegroupName),
Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
Partition_size: partitionSize,
diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go
index 418e48b..81236a0 100644
--- a/fsgen/filesystem_creator_test.go
+++ b/fsgen/filesystem_creator_test.go
@@ -287,6 +287,8 @@
"some/non/existing/file.txt:system/etc/file.txt",
"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf.xml:google",
"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml",
+ "device/sample/etc/apns-full-conf.xml:system/foo/file.txt",
+ "device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml",
}
config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
map[string]android.PartitionQualifiedVariablesType{
@@ -364,15 +366,25 @@
eval := generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
android.AssertBoolEquals(
t,
- "module expected to set correct srcs and dsts properties",
+ "module expected to set correct srcs property",
true,
checkModuleProp(generatedModule0, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
- dsts := p.Dsts.GetOrDefault(eval, nil)
return len(srcs) == 1 &&
- srcs[0] == "apns-full-conf.xml" &&
- len(dsts) == 1 &&
+ srcs[0] == "apns-full-conf.xml"
+ }
+ return false
+ }),
+ )
+ android.AssertBoolEquals(
+ t,
+ "module expected to set correct dsts property",
+ true,
+ checkModuleProp(generatedModule0, func(actual interface{}) bool {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ return len(dsts) == 1 &&
dsts[0] == "apns-conf.xml"
}
return false
@@ -383,15 +395,25 @@
eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
android.AssertBoolEquals(
t,
- "module expected to set correct srcs and dsts properties",
+ "module expected to set correct srcs property",
true,
checkModuleProp(generatedModule1, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
- dsts := p.Dsts.GetOrDefault(eval, nil)
return len(srcs) == 1 &&
- srcs[0] == "apns-full-conf.xml" &&
- len(dsts) == 1 &&
+ srcs[0] == "apns-full-conf.xml"
+ }
+ return false
+ }),
+ )
+ android.AssertBoolEquals(
+ t,
+ "module expected to set correct dsts property",
+ true,
+ checkModuleProp(generatedModule1, func(actual interface{}) bool {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ return len(dsts) == 1 &&
dsts[0] == "apns-conf-2.xml"
}
return false
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index d34ae77..4f3d2a7 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -187,6 +187,10 @@
(*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config())
}
+ if len(ctx.Config().DeviceManifestFiles()) > 0 {
+ (*fsGenState.fsDeps["vendor"])["vendor_manifest.xml"] = defaultDepCandidateProps(ctx.Config())
+ }
+
// Add common resources `prebuilt_res` module as dep of recovery partition
(*fsGenState.fsDeps["recovery"])[fmt.Sprintf("recovery-resources-common-%s", getDpi(ctx))] = defaultDepCandidateProps(ctx.Config())
(*fsGenState.fsDeps["recovery"])[getRecoveryFontModuleName(ctx)] = defaultDepCandidateProps(ctx.Config())
diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go
index 2025c91..df36197 100644
--- a/fsgen/prebuilt_etc_modules_gen.go
+++ b/fsgen/prebuilt_etc_modules_gen.go
@@ -164,7 +164,6 @@
Ramdisk *bool
Srcs []string
- Dsts []string
No_full_install *bool
@@ -227,6 +226,7 @@
"usr/idc": etc.PrebuiltUserIdcFactory,
"vendor": etc.PrebuiltVendorFactory,
"vendor_dlkm": etc.PrebuiltVendorDlkmFactory,
+ "vendor_overlay": etc.PrebuiltVendorOverlayFactory,
"wallpaper": etc.PrebuiltWallpaperFactory,
"wlc_upt": etc.PrebuiltWlcUptFactory,
}
@@ -301,6 +301,7 @@
etcInstallPathKey = etcInstallPath
}
}
+ moduleFactory := etcInstallPathToFactoryList[etcInstallPathKey]
relDestDirFromInstallDirBase, _ := filepath.Rel(etcInstallPathKey, destDir)
for fileIndex := range maxLen {
@@ -350,15 +351,23 @@
})
}
} else {
- modulePropsPtr.Srcs = srcBaseFiles
- dsts := []string{}
- for _, installBaseFile := range installBaseFiles {
- dsts = append(dsts, filepath.Join(relDestDirFromInstallDirBase, installBaseFile))
+ // If dsts property has to be set and the selected module type is prebuilt_root,
+ // use prebuilt_any instead.
+ if etcInstallPathKey == "" {
+ moduleFactory = etc.PrebuiltAnyFactory
}
- modulePropsPtr.Dsts = dsts
+ modulePropsPtr.Srcs = srcBaseFiles
+ dsts := proptools.NewConfigurable[[]string](nil, nil)
+ for _, installBaseFile := range installBaseFiles {
+ dsts.AppendSimpleValue([]string{filepath.Join(relDestDirFromInstallDirBase, installBaseFile)})
+ }
+
+ propsList = append(propsList, &etc.PrebuiltDstsProperties{
+ Dsts: dsts,
+ })
}
- ctx.CreateModuleInDirectory(etcInstallPathToFactoryList[etcInstallPathKey], srcDir, propsList...)
+ ctx.CreateModuleInDirectory(moduleFactory, srcDir, propsList...)
moduleNames = append(moduleNames, moduleName)
}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index e976e6b..710ec95 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -112,7 +112,7 @@
func (t hostToolDependencyTag) AllowDisabledModuleDependencyProxy(
ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
- return android.OtherModuleProviderOrDefault(
+ return android.OtherModulePointerProviderOrDefault(
ctx, target, android.CommonModuleInfoProvider).ReplacedByPrebuilt
}
@@ -353,7 +353,7 @@
if h, ok := android.OtherModuleProvider(ctx, module, android.HostToolProviderInfoProvider); ok {
// A HostToolProvider provides the path to a tool, which will be copied
// into the sandbox.
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool})
} else {
diff --git a/java/app.go b/java/app.go
index 560129b..553c658 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1233,7 +1233,7 @@
seenModulePaths := make(map[string]bool)
ctx.WalkDepsProxy(func(module, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return false
}
otherName := ctx.OtherModuleName(module)
@@ -1253,7 +1253,7 @@
}
seenModulePaths[path.String()] = true
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
if checkNativeSdkVersion && commonInfo.SdkVersion == "" {
ctx.PropertyErrorf("jni_libs", "JNI dependency %q uses platform APIs, but this module does not",
otherName)
@@ -1316,7 +1316,7 @@
// Skip dependencies that are only available to APEXes; they are developed with updatability
// in mind and don't need manual approval.
- if android.OtherModuleProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
+ if android.OtherModulePointerProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
return true
}
diff --git a/java/app_import.go b/java/app_import.go
index b9e91cd..c0e8171 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -177,7 +177,7 @@
Prebuilt_info *string `android:"path"`
// Path of extracted apk which is extracted from prebuilt apk. Use this extracted to import.
- Extract_apk *string
+ Extract_apk proptools.Configurable[string]
// Compress the output APK using gzip. Defaults to false.
Compress_apk proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
@@ -307,7 +307,7 @@
func (a *AndroidAppImport) extractSubApk(
ctx android.ModuleContext, inputPath android.Path, outputPath android.WritablePath) {
- extractApkPath := *a.properties.Extract_apk
+ extractApkPath := a.properties.Extract_apk.GetOrDefault(ctx, "")
ctx.Build(pctx, android.BuildParams{
Rule: extractApkRule,
Input: inputPath,
@@ -405,7 +405,7 @@
// TODO: LOCAL_PACKAGE_SPLITS
srcApk := a.prebuilt.SingleSourcePath(ctx)
- if a.properties.Extract_apk != nil {
+ if a.properties.Extract_apk.GetOrDefault(ctx, "") != "" {
extract_apk := android.PathForModuleOut(ctx, "extract-apk", ctx.ModuleName()+".apk")
a.extractSubApk(ctx, srcApk, extract_apk)
srcApk = extract_apk
diff --git a/java/base.go b/java/base.go
index 8453a68..1a12075 100644
--- a/java/base.go
+++ b/java/base.go
@@ -629,7 +629,7 @@
return nil
}
if info.SdkVersion.Kind == android.SdkCorePlatform {
- if useLegacyCorePlatformApi(ctx, android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).BaseModuleName) {
+ if useLegacyCorePlatformApi(ctx, android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).BaseModuleName) {
return fmt.Errorf("non stable SDK %v - uses legacy core platform", info.SdkVersion)
} else {
// Treat stable core platform as stable.
diff --git a/java/java.go b/java/java.go
index 7f897a0..dd9f852 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2235,7 +2235,7 @@
// install these alongside the java binary.
ctx.VisitDirectDepsProxyWithTag(jniInstallTag, func(jni android.ModuleProxy) {
// Use the BaseModuleName of the dependency (without any prebuilt_ prefix)
- commonInfo, _ := android.OtherModuleProvider(ctx, jni, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, jni, android.CommonModuleInfoProvider)
j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, commonInfo.BaseModuleName+":"+commonInfo.Target.Arch.ArchType.Bitness())
})
// Check that native libraries are not listed in `required`. Prompt users to use `jni_libs` instead.
diff --git a/java/jdeps.go b/java/jdeps.go
index 7ef6c89..56142c8 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -46,7 +46,7 @@
moduleInfos := make(map[string]android.IdeInfo)
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/java/lint.go b/java/lint.go
index 61b50dc..dc1e51f 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -659,7 +659,7 @@
var outputs []*LintInfo
var dirs []string
ctx.VisitAllModuleProxies(func(m android.ModuleProxy) {
- commonInfo, _ := android.OtherModuleProvider(ctx, m, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider)
if ctx.Config().KatiEnabled() && !commonInfo.ExportedToMake {
return
}
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index b2d6ca1..d2ec8bd 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -277,7 +277,7 @@
var compatConfigMetadata android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
if c, ok := android.OtherModuleProvider(ctx, module, PlatformCompatConfigMetadataInfoProvider); ok {
diff --git a/java/ravenwood.go b/java/ravenwood.go
index c4078c5..a942dc6 100644
--- a/java/ravenwood.go
+++ b/java/ravenwood.go
@@ -117,6 +117,8 @@
"ravenwood-tests",
}
module.testProperties.Test_options.Unit_test = proptools.BoolPtr(false)
+ module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
+ module.Module.sourceProperties.Top_level_test_target = true
InitJavaModule(module, android.DeviceSupported)
android.InitDefaultableModule(module)
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
index 24a02bb..d6493bc 100644
--- a/java/ravenwood_test.go
+++ b/java/ravenwood_test.go
@@ -230,4 +230,15 @@
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/libred.so")
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar")
+
+ // Ensure they are listed as "test" modules for code coverage
+ expectedTestOnlyModules := []string{
+ "ravenwood-test",
+ "ravenwood-test-empty",
+ }
+ expectedTopLevelTests := []string{
+ "ravenwood-test",
+ "ravenwood-test-empty",
+ }
+ assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests)
}
diff --git a/java/robolectric.go b/java/robolectric.go
index be369f7..1d204a4 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -284,6 +284,11 @@
android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
TestSuites: r.TestSuites(),
})
+
+ android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
+ TestOnly: Bool(r.sourceProperties.Test_only),
+ TopLevelTarget: r.sourceProperties.Top_level_test_target,
+ })
}
func generateSameDirRoboTestConfigJar(ctx android.ModuleContext, outputFile android.ModuleOutPath) {
@@ -335,7 +340,8 @@
module.Module.dexpreopter.isTest = true
module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
-
+ module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
+ module.Module.sourceProperties.Top_level_test_target = true
module.testProperties.Test_suites = []string{"robolectric-tests"}
InitJavaModule(module, android.DeviceSupported)
diff --git a/java/robolectric_test.go b/java/robolectric_test.go
index 4bf224b..cc16c6a 100644
--- a/java/robolectric_test.go
+++ b/java/robolectric_test.go
@@ -107,4 +107,15 @@
// Check that the .so files make it into the output.
module := ctx.ModuleForTests(t, "robo-test", "android_common")
module.Output(installPathPrefix + "/robo-test/lib64/jni-lib1.so")
+
+ // Ensure they are listed as "test" modules for code coverage
+ expectedTestOnlyModules := []string{
+ "robo-test",
+ }
+
+ expectedTopLevelTests := []string{
+ "robo-test",
+ }
+ assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests)
+
}
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index d117c52..925d7b1 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -127,7 +127,7 @@
for _, m := range requireModules {
if _, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok {
if android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider).HasStubsVariants &&
- !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).Host {
+ !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).Host {
name := ctx.OtherModuleName(m)
if ccInfo, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok && ccInfo.LinkerInfo != nil && ccInfo.LinkerInfo.ImplementationModuleName != nil {
name = *ccInfo.LinkerInfo.ImplementationModuleName
diff --git a/python/binary.go b/python/binary.go
index af7d30f..f894299 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -125,6 +125,7 @@
func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
embeddedLauncher := p.isEmbeddedLauncherEnabled()
depsSrcsZips := p.collectPathsFromTransitiveDeps(ctx, embeddedLauncher)
+ bundleSharedLibs := p.collectSharedLibDeps(ctx)
main := ""
if p.autorun() {
main = p.getPyMainFile(ctx, p.srcsPathMappings)
@@ -149,6 +150,11 @@
srcsZips = append(srcsZips, p.srcsZip)
}
srcsZips = append(srcsZips, depsSrcsZips...)
+ if ctx.Host() && len(bundleSharedLibs) > 0 {
+ // only bundle shared libs for host binaries
+ sharedLibZip := p.zipSharedLibs(ctx, bundleSharedLibs)
+ srcsZips = append(srcsZips, sharedLibZip)
+ }
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
"python3", main, p.getStem(ctx), srcsZips)
diff --git a/python/python.go b/python/python.go
index 10c11ad..de21e39 100644
--- a/python/python.go
+++ b/python/python.go
@@ -20,11 +20,13 @@
"fmt"
"path/filepath"
"regexp"
+ "sort"
"strings"
"android/soong/cc"
"github.com/google/blueprint"
+ "github.com/google/blueprint/depset"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -36,6 +38,7 @@
SrcsZip android.Path
PrecompiledSrcsZip android.Path
PkgPath string
+ BundleSharedLibs android.Paths
}
var PythonLibraryInfoProvider = blueprint.NewProvider[PythonLibraryInfo]()
@@ -105,6 +108,10 @@
// list of the Python libraries compatible both with Python2 and Python3.
Libs []string `android:"arch_variant"`
+ // TODO: b/403060602 - add unit tests for this property and related code
+ // list of shared libraries that should be packaged with the python code for this module.
+ Shared_libs []string `android:"arch_variant"`
+
Version struct {
// Python2-specific properties, including whether Python2 is supported for this module
// and version-specific sources, exclusions and dependencies.
@@ -158,6 +165,10 @@
precompiledSrcsZip android.Path
sourceProperties android.SourceProperties
+
+ // The shared libraries that should be bundled with the python code for
+ // any standalone python binaries that depend on this module.
+ bundleSharedLibs android.Paths
}
// newModule generates new Python base module
@@ -197,6 +208,10 @@
return &p.properties
}
+func (p *PythonLibraryModule) getBundleSharedLibs() android.Paths {
+ return p.bundleSharedLibs
+}
+
func (p *PythonLibraryModule) init() android.Module {
p.AddProperties(&p.properties, &p.protoProperties, &p.sourceProperties)
android.InitAndroidArchModule(p, p.hod, p.multilib)
@@ -224,6 +239,7 @@
var (
pythonLibTag = dependencyTag{name: "pythonLib"}
javaDataTag = dependencyTag{name: "javaData"}
+ sharedLibTag = dependencyTag{name: "sharedLib"}
// The python interpreter, with soong module name "py3-launcher" or "py3-launcher-autorun".
launcherTag = dependencyTag{name: "launcher"}
launcherSharedLibTag = installDependencyTag{name: "launcherSharedLib"}
@@ -288,6 +304,12 @@
javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
+ if ctx.Host() {
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), sharedLibTag, p.properties.Shared_libs...)
+ } else if len(p.properties.Shared_libs) > 0 {
+ ctx.PropertyErrorf("shared_libs", "shared_libs is not supported for device builds")
+ }
+
p.AddDepsOnPythonLauncherAndStdlib(ctx, hostStdLibTag, hostLauncherTag, hostlauncherSharedLibTag, false, ctx.Config().BuildOSTarget)
}
@@ -377,6 +399,25 @@
expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
}
+ var directImplementationDeps android.Paths
+ var transitiveImplementationDeps []depset.DepSet[android.Path]
+ ctx.VisitDirectDepsProxyWithTag(sharedLibTag, func(dep android.ModuleProxy) {
+ sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider)
+ if sharedLibInfo.SharedLibrary != nil {
+ expandedData = append(expandedData, android.OutputFilesForModule(ctx, dep, "")...)
+ directImplementationDeps = append(directImplementationDeps, android.OutputFilesForModule(ctx, dep, "")...)
+ if info, ok := android.OtherModuleProvider(ctx, dep, cc.ImplementationDepInfoProvider); ok {
+ transitiveImplementationDeps = append(transitiveImplementationDeps, info.ImplementationDeps)
+ p.bundleSharedLibs = append(p.bundleSharedLibs, info.ImplementationDeps.ToList()...)
+ }
+ } else {
+ ctx.PropertyErrorf("shared_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
+ }
+ })
+ android.SetProvider(ctx, cc.ImplementationDepInfoProvider, &cc.ImplementationDepInfo{
+ ImplementationDeps: depset.New(depset.PREORDER, directImplementationDeps, transitiveImplementationDeps),
+ })
+
// Validate pkg_path property
pkgPath := String(p.properties.Pkg_path)
if pkgPath != "" {
@@ -408,6 +449,7 @@
SrcsZip: p.getSrcsZip(),
PkgPath: p.getPkgPath(),
PrecompiledSrcsZip: p.getPrecompiledSrcsZip(),
+ BundleSharedLibs: p.getBundleSharedLibs(),
})
}
@@ -684,6 +726,56 @@
return result
}
+func (p *PythonLibraryModule) collectSharedLibDeps(ctx android.ModuleContext) android.Paths {
+ seen := make(map[android.Module]bool)
+
+ var result android.Paths
+
+ ctx.WalkDepsProxy(func(child, _ android.ModuleProxy) bool {
+ // we only collect dependencies tagged as python library deps
+ if ctx.OtherModuleDependencyTag(child) != pythonLibTag {
+ return false
+ }
+ if seen[child] {
+ return false
+ }
+ seen[child] = true
+ dep, isLibrary := android.OtherModuleProvider(ctx, child, PythonLibraryInfoProvider)
+ if isLibrary {
+ result = append(result, dep.BundleSharedLibs...)
+ }
+ return true
+ })
+ return result
+}
+
+func (p *PythonLibraryModule) zipSharedLibs(ctx android.ModuleContext, bundleSharedLibs android.Paths) android.Path {
+ // sort the paths to keep the output deterministic
+ sort.Slice(bundleSharedLibs, func(i, j int) bool {
+ return bundleSharedLibs[i].String() < bundleSharedLibs[j].String()
+ })
+
+ parArgs := []string{"-symlinks=false", "-P lib64"}
+ paths := android.Paths{}
+ for _, path := range bundleSharedLibs {
+ // specify relative root of file in following -f arguments
+ parArgs = append(parArgs, `-C `+filepath.Dir(path.String()))
+ parArgs = append(parArgs, `-f `+path.String())
+ paths = append(paths, path)
+ }
+ srcsZip := android.PathForModuleOut(ctx, ctx.ModuleName()+".sharedlibs.srcszip")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: zip,
+ Description: "bundle shared libraries for python binary",
+ Output: srcsZip,
+ Implicits: paths,
+ Args: map[string]string{
+ "args": strings.Join(parArgs, " "),
+ },
+ })
+ return srcsZip
+}
+
// chckForDuplicateOutputPath checks whether outputPath has already been included in map m, which
// would result in two files being placed in the same location.
// If there is a duplicate path, an error is thrown and true is returned
diff --git a/python/scripts/main.py b/python/scripts/main.py
index 225dbe4..35cdfc4 100644
--- a/python/scripts/main.py
+++ b/python/scripts/main.py
@@ -1,5 +1,13 @@
+
+import os
import runpy
+import shutil
import sys
+import tempfile
+import zipfile
+
+from pathlib import PurePath
+
sys.argv[0] = __loader__.archive
@@ -9,4 +17,32 @@
# when people try to use it.
sys.executable = None
-runpy._run_module_as_main("ENTRY_POINT", alter_argv=False)
+# Extract the shared libraries from the zip file into a temporary directory.
+# This works around the limitations of dynamic linker. Some Python libraries
+# reference the .so files relatively and so extracting only the .so files
+# does not work, so we extract the entire parent directory of the .so files to a
+# tempdir and then add that to sys.path.
+tempdir = None
+with zipfile.ZipFile(__loader__.archive) as z:
+ # any root so files or root directories that contain so files will be
+ # extracted to the tempdir so the linker load them, this minimizes the
+ # number of files that need to be extracted to a tempdir
+ extract_paths = {}
+ for member in z.infolist():
+ if member.filename.endswith('.so'):
+ extract_paths[PurePath(member.filename).parts[0]] = member.filename
+ if extract_paths:
+ tempdir = tempfile.mkdtemp()
+ for member in z.infolist():
+ if not PurePath(member.filename).parts[0] in extract_paths.keys():
+ continue
+ if member.is_dir():
+ os.makedirs(os.path.join(tempdir, member.filename))
+ else:
+ z.extract(member, tempdir)
+ sys.path.insert(0, tempdir)
+try:
+ runpy._run_module_as_main("ENTRY_POINT", alter_argv=False)
+finally:
+ if tempdir is not None:
+ shutil.rmtree(tempdir)
diff --git a/rust/doc.go b/rust/doc.go
index cf2f8b3..3616c8e 100644
--- a/rust/doc.go
+++ b/rust/doc.go
@@ -38,7 +38,7 @@
FlagWithArg("-D ", docDir.String())
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/rust/rust.go b/rust/rust.go
index 5f3d7a9..54b5d92 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1480,10 +1480,10 @@
rustInfo, hasRustInfo := android.OtherModuleProvider(ctx, dep, RustInfoProvider)
ccInfo, _ := android.OtherModuleProvider(ctx, dep, cc.CcInfoProvider)
linkableInfo, hasLinkableInfo := android.OtherModuleProvider(ctx, dep, cc.LinkableInfoProvider)
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if hasRustInfo && !linkableInfo.Static && !linkableInfo.Shared {
//Handle Rust Modules
- makeLibName := rustMakeLibName(rustInfo, linkableInfo, &commonInfo, depName+rustInfo.RustSubName)
+ makeLibName := rustMakeLibName(rustInfo, linkableInfo, commonInfo, depName+rustInfo.RustSubName)
switch {
case depTag == dylibDepTag:
@@ -1628,7 +1628,7 @@
}
} else if hasLinkableInfo {
//Handle C dependencies
- makeLibName := cc.MakeLibName(ccInfo, linkableInfo, &commonInfo, depName)
+ makeLibName := cc.MakeLibName(ccInfo, linkableInfo, commonInfo, depName)
if !hasRustInfo {
if commonInfo.Target.Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
diff --git a/rust/test.go b/rust/test.go
index 2fed0d6..cedced2 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -165,7 +165,7 @@
if linkableDep.OutputFile.Valid() {
// Copy the output in "lib[64]" so that it's compatible with
// the default rpath values.
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
libDir := "lib"
if commonInfo.Target.Arch.ArchType.Multilib == "lib64" {
libDir = "lib64"
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 7041642..57f5ad1 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -510,7 +510,7 @@
// so that it's compatible with the default rpath values.
var relPath string
linkableInfo := android.OtherModuleProviderOrDefault(ctx, dep, cc.LinkableInfoProvider)
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if commonInfo.Target.Arch.ArchType.Multilib == "lib64" {
relPath = filepath.Join("lib64", linkableInfo.OutputFile.Path().Base())
@@ -613,6 +613,8 @@
entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", s.extraTestConfigs.Strings()...)
}
+ entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !proptools.BoolDefault(s.testProperties.Auto_gen_config, true))
+
s.testProperties.Test_options.SetAndroidMkEntries(entries)
},
},