Define getSnapshotNameSuffix()

By sharing a single function for generating snapshot name suffix,
make sure both the DepsMutator and the snapshot modules use the same
names.

Bug: 179666286
Test: m nothing
Change-Id: I9efa94f2981a6bd1b4128bf0e84ca44873ebf3b7
This commit is contained in:
Justin Yun
2021-02-26 14:00:03 +09:00
parent a777d960ab
commit 07b9f86f0c
2 changed files with 20 additions and 29 deletions

View File

@@ -280,41 +280,36 @@ func (s *snapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Nothing, the snapshot module is only used to forward dependency information in DepsMutator. // Nothing, the snapshot module is only used to forward dependency information in DepsMutator.
} }
func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) { func getSnapshotNameSuffix(moduleSuffix, version, arch string) string {
collectSnapshotMap := func(variations []blueprint.Variation, depTag blueprint.DependencyTag, versionSuffix := version
names []string, snapshotSuffix, moduleSuffix string) map[string]string { if arch != "" {
versionSuffix += "." + arch
}
return moduleSuffix + versionSuffix
}
func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string {
snapshotMap := make(map[string]string) snapshotMap := make(map[string]string)
for _, name := range names { for _, name := range names {
snapshotMap[name] = name + snapshotMap[name] = name +
snapshotSuffix + moduleSuffix + getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
s.baseSnapshot.version() + s.baseSnapshot.version(), ctx.Arch().ArchType.Name)
"." + ctx.Arch().ArchType.Name
} }
return snapshotMap return snapshotMap
} }
snapshotSuffix := s.image.moduleNameSuffix() snapshotSuffix := s.image.moduleNameSuffix()
headers := collectSnapshotMap(nil, HeaderDepTag(), s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix) headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
binaries := collectSnapshotMap(nil, nil, s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix) binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
objects := collectSnapshotMap(nil, nil, s.properties.Objects, snapshotSuffix, snapshotObjectSuffix) objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)
staticLibs := collectSnapshotMap([]blueprint.Variation{ sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)
{Mutator: "link", Variation: "static"}, vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
}, StaticDepTag(), s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)
sharedLibs := collectSnapshotMap([]blueprint.Variation{
{Mutator: "link", Variation: "shared"},
}, SharedDepTag(), s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)
vndkLibs := collectSnapshotMap([]blueprint.Variation{
{Mutator: "link", Variation: "shared"},
}, SharedDepTag(), s.properties.Vndk_libs, "", vndkSuffix)
for k, v := range vndkLibs { for k, v := range vndkLibs {
sharedLibs[k] = v sharedLibs[k] = v
} }
ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{ ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{
HeaderLibs: headers, HeaderLibs: headers,
Binaries: binaries, Binaries: binaries,
@@ -386,12 +381,7 @@ func (p *baseSnapshotDecorator) Name(name string) string {
} }
func (p *baseSnapshotDecorator) NameSuffix() string { func (p *baseSnapshotDecorator) NameSuffix() string {
versionSuffix := p.version() return getSnapshotNameSuffix(p.moduleSuffix(), p.version(), p.arch())
if p.arch() != "" {
versionSuffix += "." + p.arch()
}
return p.baseProperties.ModuleSuffix + versionSuffix
} }
func (p *baseSnapshotDecorator) version() string { func (p *baseSnapshotDecorator) version() string {

View File

@@ -421,6 +421,7 @@ func TestVendorSnapshotUse(t *testing.T) {
shared_libs: [ shared_libs: [
"libvendor_without_snapshot", "libvendor_without_snapshot",
"libvendor_available", "libvendor_available",
"libvndk",
], ],
arch: { arch: {
arm64: { arm64: {