Merge "Added EXTRA_ALLOWED_DEPS_TXT to allow arbitrary allowedlist text files that enforces min_sdk_version for apex dependencies to avoid regression" into main
diff --git a/android/Android.bp b/android/Android.bp
index c2bef0b..eb8c64d 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -71,6 +71,7 @@
"module.go",
"module_context.go",
"module_info_json.go",
+ "module_proxy.go",
"mutator.go",
"namespace.go",
"neverallow.go",
diff --git a/android/base_module_context.go b/android/base_module_context.go
index c7d7573..670537f 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -33,6 +33,8 @@
blueprintBaseModuleContext() blueprint.BaseModuleContext
+ EqualModules(m1, m2 Module) bool
+
// OtherModuleName returns the name of another Module. See BaseModuleContext.ModuleName for more information.
// It is intended for use inside the visit functions of Visit* and WalkDeps.
OtherModuleName(m blueprint.Module) string
@@ -130,6 +132,14 @@
// function, it may be invalidated by future mutators.
VisitDirectDepsAllowDisabled(visit func(Module))
+ // VisitDirectDepsProxyAllowDisabled calls visit for each direct dependency. If there are
+ // multiple direct dependencies on the same module visit will be called multiple times on
+ // that module and OtherModuleDependencyTag will return a different tag for each.
+ //
+ // The Module passed to the visit function should not be retained outside of the visit function, it may be
+ // invalidated by future mutators.
+ VisitDirectDepsProxyAllowDisabled(visit func(proxy Module))
+
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
// VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are
@@ -155,6 +165,16 @@
// invalidated by future mutators.
WalkDeps(visit func(child, parent Module) bool)
+ // WalkDeps calls visit for each transitive dependency, traversing the dependency tree in top down order. visit may
+ // be called multiple times for the same (child, parent) pair if there are multiple direct dependencies between the
+ // child and parent with different tags. OtherModuleDependencyTag will return the tag for the currently visited
+ // (child, parent) pair. If visit returns false WalkDeps will not continue recursing down to child. It skips
+ // any dependencies that are not an android.Module.
+ //
+ // The Modules passed to the visit function should not be retained outside of the visit function, they may be
+ // invalidated by future mutators.
+ WalkDepsProxy(visit func(child, parent Module) bool)
+
// GetWalkPath is supposed to be called in visit function passed in WalkDeps()
// and returns a top-down dependency path from a start module to current child module.
GetWalkPath() []Module
@@ -214,15 +234,26 @@
}
+func getWrappedModule(module blueprint.Module) blueprint.Module {
+ if mp, isProxy := module.(ModuleProxy); isProxy {
+ return mp.module
+ }
+ return module
+}
+
+func (b *baseModuleContext) EqualModules(m1, m2 Module) bool {
+ return b.bp.EqualModules(getWrappedModule(m1), getWrappedModule(m2))
+}
+
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string {
- return b.bp.OtherModuleName(m)
+ return b.bp.OtherModuleName(getWrappedModule(m))
}
func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string { return b.bp.OtherModuleDir(m) }
func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) {
b.bp.OtherModuleErrorf(m, fmt, args...)
}
func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag {
- return b.bp.OtherModuleDependencyTag(m)
+ return b.bp.OtherModuleDependencyTag(getWrappedModule(m))
}
func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) }
func (b *baseModuleContext) OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool {
@@ -395,6 +426,14 @@
})
}
+func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) {
+ b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) {
+ visit(ModuleProxy{
+ module: module,
+ })
+ })
+}
+
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
b.bp.VisitDirectDeps(func(module blueprint.Module) {
if b.bp.OtherModuleDependencyTag(module) == tag {
@@ -466,6 +505,23 @@
})
}
+func (b *baseModuleContext) WalkDepsProxy(visit func(Module, Module) bool) {
+ b.walkPath = []Module{ModuleProxy{blueprint.CreateModuleProxy(b.Module())}}
+ b.tagPath = []blueprint.DependencyTag{}
+ b.bp.WalkDepsProxy(func(child, parent blueprint.ModuleProxy) bool {
+ childAndroidModule := ModuleProxy{child}
+ parentAndroidModule := ModuleProxy{parent}
+ // record walkPath before visit
+ for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
+ b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
+ b.tagPath = b.tagPath[0 : len(b.tagPath)-1]
+ }
+ b.walkPath = append(b.walkPath, childAndroidModule)
+ b.tagPath = append(b.tagPath, b.OtherModuleDependencyTag(childAndroidModule))
+ return visit(childAndroidModule, parentAndroidModule)
+ })
+}
+
func (b *baseModuleContext) GetWalkPath() []Module {
return b.walkPath
}
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index 38f1382..d28831e 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -17,7 +17,6 @@
import (
"bytes"
"encoding/csv"
- "encoding/gob"
"fmt"
"slices"
"strconv"
@@ -126,32 +125,32 @@
properties map[string]string
}
+type complianceMetadataInfoGob struct {
+ Properties map[string]string
+}
+
func NewComplianceMetadataInfo() *ComplianceMetadataInfo {
return &ComplianceMetadataInfo{
properties: map[string]string{},
}
}
-func (c *ComplianceMetadataInfo) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := encoder.Encode(c.properties)
- if err != nil {
- return nil, err
+func (m *ComplianceMetadataInfo) ToGob() *complianceMetadataInfoGob {
+ return &complianceMetadataInfoGob{
+ Properties: m.properties,
}
+}
- return w.Bytes(), nil
+func (m *ComplianceMetadataInfo) FromGob(data *complianceMetadataInfoGob) {
+ m.properties = data.Properties
+}
+
+func (c *ComplianceMetadataInfo) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[complianceMetadataInfoGob](c)
}
func (c *ComplianceMetadataInfo) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := decoder.Decode(&c.properties)
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[complianceMetadataInfoGob](data, c)
}
func (c *ComplianceMetadataInfo) SetStringValue(propertyName string, value string) {
diff --git a/android/config.go b/android/config.go
index ba80796..06d71c0 100644
--- a/android/config.go
+++ b/android/config.go
@@ -287,6 +287,10 @@
return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE")
}
+func (c Config) ReleaseCreateAconfigStorageFile() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_CREATE_ACONFIG_STORAGE_FILE")
+}
+
// A DeviceConfig object represents the configuration for a particular device
// being built. For now there will only be one of these, but in the future there
// may be multiple devices being built.
diff --git a/android/depset_generic.go b/android/depset_generic.go
index 690987a..d04f88b 100644
--- a/android/depset_generic.go
+++ b/android/depset_generic.go
@@ -15,10 +15,9 @@
package android
import (
- "bytes"
- "encoding/gob"
- "errors"
"fmt"
+
+ "github.com/google/blueprint"
)
// DepSet is designed to be conceptually compatible with Bazel's depsets:
@@ -68,28 +67,38 @@
transitive []*DepSet[T]
}
-func (d *DepSet[T]) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(d.preorder), encoder.Encode(d.reverse),
- encoder.Encode(d.order), encoder.Encode(d.direct), encoder.Encode(d.transitive))
- if err != nil {
- return nil, err
- }
+type depSetGob[T depSettableType] struct {
+ Preorder bool
+ Reverse bool
+ Order DepSetOrder
+ Direct []T
+ Transitive []*DepSet[T]
+}
- return w.Bytes(), nil
+func (d *DepSet[T]) ToGob() *depSetGob[T] {
+ return &depSetGob[T]{
+ Preorder: d.preorder,
+ Reverse: d.reverse,
+ Order: d.order,
+ Direct: d.direct,
+ Transitive: d.transitive,
+ }
+}
+
+func (d *DepSet[T]) FromGob(data *depSetGob[T]) {
+ d.preorder = data.Preorder
+ d.reverse = data.Reverse
+ d.order = data.Order
+ d.direct = data.Direct
+ d.transitive = data.Transitive
+}
+
+func (d *DepSet[T]) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[depSetGob[T]](d)
}
func (d *DepSet[T]) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&d.preorder), decoder.Decode(&d.reverse),
- decoder.Decode(&d.order), decoder.Decode(&d.direct), decoder.Decode(&d.transitive))
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[depSetGob[T]](data, d)
}
// NewDepSet returns an immutable DepSet with the given order, direct and transitive contents.
diff --git a/android/init.go b/android/init.go
index b462292..1ace344 100644
--- a/android/init.go
+++ b/android/init.go
@@ -17,7 +17,12 @@
import "encoding/gob"
func init() {
+ gob.Register(extraFilesZip{})
+ gob.Register(InstallPath{})
+ gob.Register(ModuleGenPath{})
gob.Register(ModuleOutPath{})
+ gob.Register(OutputPath{})
gob.Register(PhonyPath{})
+ gob.Register(SourcePath{})
gob.Register(unstableInfo{})
}
diff --git a/android/module.go b/android/module.go
index a1a9a4a..e3682fa 100644
--- a/android/module.go
+++ b/android/module.go
@@ -15,9 +15,6 @@
package android
import (
- "bytes"
- "encoding/gob"
- "errors"
"fmt"
"net/url"
"path/filepath"
@@ -1806,6 +1803,26 @@
var FinalModuleBuildTargetsProvider = blueprint.NewProvider[FinalModuleBuildTargetsInfo]()
+type CommonPropertiesProviderData struct {
+ Enabled bool
+ // Whether the module has been replaced by a prebuilt
+ ReplacedByPrebuilt bool
+}
+
+var CommonPropertiesProviderKey = blueprint.NewProvider[CommonPropertiesProviderData]()
+
+type PrebuiltModuleProviderData struct {
+ // Empty for now
+}
+
+var PrebuiltModuleProviderKey = blueprint.NewProvider[PrebuiltModuleProviderData]()
+
+type HostToolProviderData struct {
+ HostToolPath OptionalPath
+}
+
+var HostToolProviderKey = blueprint.NewProvider[HostToolProviderData]()
+
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
ctx := &moduleContext{
module: m.module,
@@ -2051,6 +2068,23 @@
})
}
buildComplianceMetadataProvider(ctx, m)
+
+ commonData := CommonPropertiesProviderData{
+ ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
+ }
+ if m.commonProperties.ForcedDisabled {
+ commonData.Enabled = false
+ } else {
+ commonData.Enabled = m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
+ }
+ SetProvider(ctx, CommonPropertiesProviderKey, commonData)
+ if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil {
+ SetProvider(ctx, PrebuiltModuleProviderKey, PrebuiltModuleProviderData{})
+ }
+ if h, ok := m.module.(HostToolProvider); ok {
+ SetProvider(ctx, HostToolProviderKey, HostToolProviderData{
+ HostToolPath: h.HostToolPath()})
+ }
}
func SetJarJarPrefixHandler(handler func(ModuleContext)) {
@@ -2130,36 +2164,47 @@
orderOnlyDeps Paths
executable bool
extraFiles *extraFilesZip
-
- absFrom string
+ absFrom string
}
-func (p *katiInstall) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.from), encoder.Encode(p.to),
- encoder.Encode(p.implicitDeps), encoder.Encode(p.orderOnlyDeps),
- encoder.Encode(p.executable), encoder.Encode(p.extraFiles),
- encoder.Encode(p.absFrom))
- if err != nil {
- return nil, err
- }
-
- return w.Bytes(), nil
+type katiInstallGob struct {
+ From Path
+ To InstallPath
+ ImplicitDeps Paths
+ OrderOnlyDeps Paths
+ Executable bool
+ ExtraFiles *extraFilesZip
+ AbsFrom string
}
-func (p *katiInstall) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.from), decoder.Decode(&p.to),
- decoder.Decode(&p.implicitDeps), decoder.Decode(&p.orderOnlyDeps),
- decoder.Decode(&p.executable), decoder.Decode(&p.extraFiles),
- decoder.Decode(&p.absFrom))
- if err != nil {
- return err
+func (k *katiInstall) ToGob() *katiInstallGob {
+ return &katiInstallGob{
+ From: k.from,
+ To: k.to,
+ ImplicitDeps: k.implicitDeps,
+ OrderOnlyDeps: k.orderOnlyDeps,
+ Executable: k.executable,
+ ExtraFiles: k.extraFiles,
+ AbsFrom: k.absFrom,
}
+}
- return nil
+func (k *katiInstall) FromGob(data *katiInstallGob) {
+ k.from = data.From
+ k.to = data.To
+ k.implicitDeps = data.ImplicitDeps
+ k.orderOnlyDeps = data.OrderOnlyDeps
+ k.executable = data.Executable
+ k.extraFiles = data.ExtraFiles
+ k.absFrom = data.AbsFrom
+}
+
+func (k *katiInstall) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[katiInstallGob](k)
+}
+
+func (k *katiInstall) GobDecode(data []byte) error {
+ return blueprint.CustomGobDecode[katiInstallGob](data, k)
}
type extraFilesZip struct {
@@ -2167,26 +2212,29 @@
dir InstallPath
}
-func (p *extraFilesZip) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.zip), encoder.Encode(p.dir))
- if err != nil {
- return nil, err
- }
-
- return w.Bytes(), nil
+type extraFilesZipGob struct {
+ Zip Path
+ Dir InstallPath
}
-func (p *extraFilesZip) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.zip), decoder.Decode(&p.dir))
- if err != nil {
- return err
+func (e *extraFilesZip) ToGob() *extraFilesZipGob {
+ return &extraFilesZipGob{
+ Zip: e.zip,
+ Dir: e.dir,
}
+}
- return nil
+func (e *extraFilesZip) FromGob(data *extraFilesZipGob) {
+ e.zip = data.Zip
+ e.dir = data.Dir
+}
+
+func (e *extraFilesZip) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[extraFilesZipGob](e)
+}
+
+func (e *extraFilesZip) GobDecode(data []byte) error {
+ return blueprint.CustomGobDecode[extraFilesZipGob](data, e)
}
type katiInstalls []katiInstall
diff --git a/android/module_proxy.go b/android/module_proxy.go
new file mode 100644
index 0000000..bc5090e
--- /dev/null
+++ b/android/module_proxy.go
@@ -0,0 +1,203 @@
+package android
+
+import (
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
+)
+
+type ModuleProxy struct {
+ module blueprint.ModuleProxy
+}
+
+func (m ModuleProxy) Name() string {
+ return m.module.Name()
+}
+
+func (m ModuleProxy) GenerateBuildActions(context blueprint.ModuleContext) {
+ m.module.GenerateBuildActions(context)
+}
+
+func (m ModuleProxy) GenerateAndroidBuildActions(context ModuleContext) {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) ComponentDepsMutator(ctx BottomUpMutatorContext) {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) DepsMutator(context BottomUpMutatorContext) {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) base() *ModuleBase {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) Disable() {
+
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) Enabled(ctx ConfigurableEvaluatorContext) bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) Target() Target {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) MultiTargets() []Target {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) ImageVariation() blueprint.Variation {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) Owner() string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInData() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInTestcases() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInSanitizerDir() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInRamdisk() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInVendorRamdisk() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInDebugRamdisk() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInRecovery() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInRoot() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInOdm() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInProduct() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInVendor() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallInSystemExt() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) InstallForceOS() (*OsType, *ArchType) {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) PartitionTag(d DeviceConfig) string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) HideFromMake() {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) IsHideFromMake() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) IsSkipInstall() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) MakeUninstallable() {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) ReplacedByPrebuilt() {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) IsReplacedByPrebuilt() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) ExportedToMake() bool {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) EffectiveLicenseKinds() []string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) EffectiveLicenseFiles() Paths {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) AddProperties(props ...interface{}) {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) GetProperties() []interface{} {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) BuildParamsForTests() []BuildParams {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) VariablesForTests() map[string]string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) String() string {
+ return m.module.Name()
+}
+
+func (m ModuleProxy) qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) visibilityProperties() []visibilityProperty {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) HostRequiredModuleNames() []string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) TargetRequiredModuleNames() []string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) VintfFragmentModuleNames(ctx ConfigurableEvaluatorContext) []string {
+ panic("method is not implemented on ModuleProxy")
+}
+
+func (m ModuleProxy) ConfigurableEvaluator(ctx ConfigurableEvaluatorContext) proptools.ConfigurableEvaluator {
+ panic("method is not implemented on ModuleProxy")
+}
diff --git a/android/packaging.go b/android/packaging.go
index 0909936..3c64d56 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -15,9 +15,6 @@
package android
import (
- "bytes"
- "encoding/gob"
- "errors"
"fmt"
"path/filepath"
"sort"
@@ -67,34 +64,53 @@
owner string
}
-func (p *PackagingSpec) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.relPathInPackage), encoder.Encode(p.srcPath),
- encoder.Encode(p.symlinkTarget), encoder.Encode(p.executable),
- encoder.Encode(p.effectiveLicenseFiles), encoder.Encode(p.partition),
- encoder.Encode(p.skipInstall), encoder.Encode(p.aconfigPaths),
- encoder.Encode(p.archType))
- if err != nil {
- return nil, err
- }
+type packagingSpecGob struct {
+ RelPathInPackage string
+ SrcPath Path
+ SymlinkTarget string
+ Executable bool
+ Partition string
+ SkipInstall bool
+ AconfigPaths *Paths
+ ArchType ArchType
+ Overrides *[]string
+ Owner string
+}
- return w.Bytes(), nil
+func (p *PackagingSpec) ToGob() *packagingSpecGob {
+ return &packagingSpecGob{
+ RelPathInPackage: p.relPathInPackage,
+ SrcPath: p.srcPath,
+ SymlinkTarget: p.symlinkTarget,
+ Executable: p.executable,
+ Partition: p.partition,
+ SkipInstall: p.skipInstall,
+ AconfigPaths: p.aconfigPaths,
+ ArchType: p.archType,
+ Overrides: p.overrides,
+ Owner: p.owner,
+ }
+}
+
+func (p *PackagingSpec) FromGob(data *packagingSpecGob) {
+ p.relPathInPackage = data.RelPathInPackage
+ p.srcPath = data.SrcPath
+ p.symlinkTarget = data.SymlinkTarget
+ p.executable = data.Executable
+ p.partition = data.Partition
+ p.skipInstall = data.SkipInstall
+ p.aconfigPaths = data.AconfigPaths
+ p.archType = data.ArchType
+ p.overrides = data.Overrides
+ p.owner = data.Owner
+}
+
+func (p *PackagingSpec) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[packagingSpecGob](p)
}
func (p *PackagingSpec) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.relPathInPackage), decoder.Decode(&p.srcPath),
- decoder.Decode(&p.symlinkTarget), decoder.Decode(&p.executable),
- decoder.Decode(&p.effectiveLicenseFiles), decoder.Decode(&p.partition),
- decoder.Decode(&p.skipInstall), decoder.Decode(&p.aconfigPaths),
- decoder.Decode(&p.archType))
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[packagingSpecGob](data, p)
}
func (p *PackagingSpec) Equals(other *PackagingSpec) bool {
diff --git a/android/paths.go b/android/paths.go
index 1c8258e..9c2df65 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -15,9 +15,6 @@
package android
import (
- "bytes"
- "encoding/gob"
- "errors"
"fmt"
"os"
"path/filepath"
@@ -342,6 +339,11 @@
invalidReason string // Not applicable if path != nil. "" if the reason is unknown.
}
+type optionalPathGob struct {
+ Path Path
+ InvalidReason string
+}
+
// OptionalPathForPath returns an OptionalPath containing the path.
func OptionalPathForPath(path Path) OptionalPath {
return OptionalPath{path: path}
@@ -353,6 +355,26 @@
return OptionalPath{invalidReason: reason}
}
+func (p *OptionalPath) ToGob() *optionalPathGob {
+ return &optionalPathGob{
+ Path: p.path,
+ InvalidReason: p.invalidReason,
+ }
+}
+
+func (p *OptionalPath) FromGob(data *optionalPathGob) {
+ p.path = data.Path
+ p.invalidReason = data.InvalidReason
+}
+
+func (p OptionalPath) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[optionalPathGob](&p)
+}
+
+func (p *OptionalPath) GobDecode(data []byte) error {
+ return blueprint.CustomGobDecode[optionalPathGob](data, p)
+}
+
// Valid returns whether there is a valid path
func (p OptionalPath) Valid() bool {
return p.path != nil
@@ -1065,26 +1087,29 @@
rel string
}
-func (p basePath) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.path), encoder.Encode(p.rel))
- if err != nil {
- return nil, err
- }
+type basePathGob struct {
+ Path string
+ Rel string
+}
- return w.Bytes(), nil
+func (p *basePath) ToGob() *basePathGob {
+ return &basePathGob{
+ Path: p.path,
+ Rel: p.rel,
+ }
+}
+
+func (p *basePath) FromGob(data *basePathGob) {
+ p.path = data.Path
+ p.rel = data.Rel
+}
+
+func (p basePath) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[basePathGob](&p)
}
func (p *basePath) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.path), decoder.Decode(&p.rel))
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[basePathGob](data, p)
}
func (p basePath) Ext() string {
@@ -1337,26 +1362,32 @@
fullPath string
}
-func (p OutputPath) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.basePath), encoder.Encode(p.outDir), encoder.Encode(p.fullPath))
- if err != nil {
- return nil, err
- }
+type outputPathGob struct {
+ basePath
+ OutDir string
+ FullPath string
+}
- return w.Bytes(), nil
+func (p *OutputPath) ToGob() *outputPathGob {
+ return &outputPathGob{
+ basePath: p.basePath,
+ OutDir: p.outDir,
+ FullPath: p.fullPath,
+ }
+}
+
+func (p *OutputPath) FromGob(data *outputPathGob) {
+ p.basePath = data.basePath
+ p.outDir = data.OutDir
+ p.fullPath = data.FullPath
+}
+
+func (p OutputPath) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[outputPathGob](&p)
}
func (p *OutputPath) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.basePath), decoder.Decode(&p.outDir), decoder.Decode(&p.fullPath))
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[outputPathGob](data, p)
}
func (p OutputPath) withRel(rel string) OutputPath {
@@ -1756,30 +1787,41 @@
fullPath string
}
-func (p *InstallPath) GobEncode() ([]byte, error) {
- w := new(bytes.Buffer)
- encoder := gob.NewEncoder(w)
- err := errors.Join(encoder.Encode(p.basePath), encoder.Encode(p.soongOutDir),
- encoder.Encode(p.partitionDir), encoder.Encode(p.partition),
- encoder.Encode(p.makePath), encoder.Encode(p.fullPath))
- if err != nil {
- return nil, err
- }
+type installPathGob struct {
+ basePath
+ SoongOutDir string
+ PartitionDir string
+ Partition string
+ MakePath bool
+ FullPath string
+}
- return w.Bytes(), nil
+func (p *InstallPath) ToGob() *installPathGob {
+ return &installPathGob{
+ basePath: p.basePath,
+ SoongOutDir: p.soongOutDir,
+ PartitionDir: p.partitionDir,
+ Partition: p.partition,
+ MakePath: p.makePath,
+ FullPath: p.fullPath,
+ }
+}
+
+func (p *InstallPath) FromGob(data *installPathGob) {
+ p.basePath = data.basePath
+ p.soongOutDir = data.SoongOutDir
+ p.partitionDir = data.PartitionDir
+ p.partition = data.Partition
+ p.makePath = data.MakePath
+ p.fullPath = data.FullPath
+}
+
+func (p InstallPath) GobEncode() ([]byte, error) {
+ return blueprint.CustomGobEncode[installPathGob](&p)
}
func (p *InstallPath) GobDecode(data []byte) error {
- r := bytes.NewBuffer(data)
- decoder := gob.NewDecoder(r)
- err := errors.Join(decoder.Decode(&p.basePath), decoder.Decode(&p.soongOutDir),
- decoder.Decode(&p.partitionDir), decoder.Decode(&p.partition),
- decoder.Decode(&p.makePath), decoder.Decode(&p.fullPath))
- if err != nil {
- return err
- }
-
- return nil
+ return blueprint.CustomGobDecode[installPathGob](data, p)
}
// Will panic if called from outside a test environment.
diff --git a/android/provider.go b/android/provider.go
index 5ded4cc..81d17a1 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -24,7 +24,7 @@
// OtherModuleProviderContext is a helper interface that accepts ModuleContext, BottomUpMutatorContext, or
// TopDownMutatorContext.
func OtherModuleProvider[K any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) (K, bool) {
- value, ok := ctx.otherModuleProvider(module, provider)
+ value, ok := ctx.otherModuleProvider(getWrappedModule(module), provider)
if !ok {
var k K
return k, false
diff --git a/filesystem/aconfig_files.go b/filesystem/aconfig_files.go
index 8af2ffa..608fccd 100644
--- a/filesystem/aconfig_files.go
+++ b/filesystem/aconfig_files.go
@@ -76,10 +76,13 @@
cmd.ImplicitOutput(outputPath)
f.appendToEntry(ctx, outputPath)
}
- generatePartitionAconfigStorageFile("package_map", "package.map")
- generatePartitionAconfigStorageFile("flag_map", "flag.map")
- generatePartitionAconfigStorageFile("flag_val", "flag.val")
- generatePartitionAconfigStorageFile("flag_info", "flag.info")
+
+ if ctx.Config().ReleaseCreateAconfigStorageFile() {
+ generatePartitionAconfigStorageFile("package_map", "package.map")
+ generatePartitionAconfigStorageFile("flag_map", "flag.map")
+ generatePartitionAconfigStorageFile("flag_val", "flag.val")
+ generatePartitionAconfigStorageFile("flag_info", "flag.info")
+ }
android.WriteExecutableFileRuleVerbatim(ctx, aconfigFlagsBuilderPath, sb.String())
}
diff --git a/java/aar.go b/java/aar.go
index 7d73b03..41cc24a 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -483,9 +483,9 @@
}
linkFlags = append(linkFlags, "--no-static-lib-packages")
- if a.isLibrary && a.useResourceProcessorBusyBox(ctx) {
- // When building an android_library using ResourceProcessorBusyBox pass --merge-only to skip resource
- // references validation until the final app link step when all static libraries are present.
+ if a.isLibrary {
+ // Pass --merge-only to skip resource references validation until the final
+ // app link step when when all static libraries are present.
linkFlags = append(linkFlags, "--merge-only")
}
diff --git a/java/base.go b/java/base.go
index fc21c44..7a95735 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1628,7 +1628,7 @@
if j.ravenizer.enabled {
ravenizerInput := outputFile
- ravenizerOutput := android.PathForModuleOut(ctx, "ravenizer", jarName)
+ ravenizerOutput := android.PathForModuleOut(ctx, "ravenizer", "", jarName)
ravenizerArgs := ""
if proptools.Bool(j.properties.Ravenizer.Strip_mockito) {
ravenizerArgs = "--strip-mockito"
@@ -1637,6 +1637,14 @@
outputFile = ravenizerOutput
localImplementationJars = android.Paths{ravenizerOutput}
completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil)
+ if combinedResourceJar != nil {
+ ravenizerInput = combinedResourceJar
+ ravenizerOutput = android.PathForModuleOut(ctx, "ravenizer", "resources", jarName)
+ TransformRavenizer(ctx, ravenizerOutput, ravenizerInput, ravenizerArgs)
+ combinedResourceJar = ravenizerOutput
+ localResourceJars = android.Paths{ravenizerOutput}
+ completeStaticLibsResourceJars = android.NewDepSet(android.PREORDER, localResourceJars, nil)
+ }
}
if j.shouldApiMapper() {