Support for recovery snapshot.

Bug: 171231437

Test: source build/envsetup.sh
Test: ALLOW_MISSING_DEPENDENCIES=true m -j nothing

Change-Id: I74636cf7f97e027a229a5ef7c776f2b7a42ead95
This commit is contained in:
Jose Galmes
2020-12-11 13:36:29 -08:00
parent e794b1e302
commit 6f843bc4ba
12 changed files with 520 additions and 119 deletions

View File

@@ -52,6 +52,8 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
ctx.BottomUp("vendor_snapshot", VendorSnapshotMutator).Parallel()
ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel()
ctx.BottomUp("recovery_snapshot", RecoverySnapshotMutator).Parallel()
ctx.BottomUp("recovery_snapshot_source", RecoverySnapshotSourceMutator).Parallel()
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -334,10 +336,16 @@ type BaseProperties struct {
// Normally Soong uses the directory structure to decide which modules
// should be included (framework) or excluded (non-framework) from the
// different snapshots (vendor, recovery, etc.), but these properties
// allow a partner to exclude a module normally thought of as a
// framework module from a snapshot.
Exclude_from_vendor_snapshot *bool
// different snapshots (vendor, recovery, etc.), but this property
// allows a partner to exclude a module normally thought of as a
// framework module from the vendor snapshot.
Exclude_from_vendor_snapshot *bool
// Normally Soong uses the directory structure to decide which modules
// should be included (framework) or excluded (non-framework) from the
// different snapshots (vendor, recovery, etc.), but this property
// allows a partner to exclude a module normally thought of as a
// framework module from the recovery snapshot.
Exclude_from_recovery_snapshot *bool
// List of APEXes that this module has private access to for testing purpose. The module
@@ -1599,8 +1607,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// Note: this is still non-installable
}
// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current.
if i, ok := c.linker.(snapshotLibraryInterface); ok && ctx.DeviceConfig().VndkVersion() == "current" {
// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or
// RECOVERY_SNAPSHOT_VERSION is current.
if i, ok := c.linker.(snapshotLibraryInterface); ok {
if shouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
i.collectHeadersForSnapshot(ctx)
}
@@ -1842,6 +1851,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
vendorPublicLibraries := vendorPublicLibraries(actx.Config())
vendorSnapshotSharedLibs := vendorSnapshotSharedLibs(actx.Config())
recoverySnapshotSharedLibs := recoverySnapshotSharedLibs(actx.Config())
rewriteVendorLibs := func(lib string) string {
// only modules with BOARD_VNDK_VERSION uses snapshot.
@@ -1862,7 +1872,19 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
for _, entry := range list {
// strip #version suffix out
name, _ := StubsLibNameAndVersion(entry)
if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) {
if c.InRecovery() {
recoverySnapshotVersion :=
actx.DeviceConfig().RecoverySnapshotVersion()
if recoverySnapshotVersion == "current" ||
recoverySnapshotVersion == "" {
nonvariantLibs = append(nonvariantLibs, name)
} else if snapshot, ok := recoverySnapshotSharedLibs.get(
name, actx.Arch().ArchType); ok {
nonvariantLibs = append(nonvariantLibs, snapshot)
} else {
nonvariantLibs = append(nonvariantLibs, name)
}
} else if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) {
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
} else if ctx.useVndk() {
nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
@@ -1907,14 +1929,36 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
return lib
}
vendorSnapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config())
snapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config())
snapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
snapshotObjects := vendorSnapshotObjects(actx.Config())
if c.InRecovery() {
rewriteSnapshotLibs = func(lib string, snapshotMap *snapshotMap) string {
recoverySnapshotVersion :=
actx.DeviceConfig().RecoverySnapshotVersion()
if recoverySnapshotVersion == "current" ||
recoverySnapshotVersion == "" {
return lib
} else if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok {
return snapshot
}
return lib
}
snapshotHeaderLibs = recoverySnapshotHeaderLibs(actx.Config())
snapshotStaticLibs = recoverySnapshotStaticLibs(actx.Config())
snapshotObjects = recoverySnapshotObjects(actx.Config())
}
for _, lib := range deps.HeaderLibs {
depTag := libraryDependencyTag{Kind: headerLibraryDependency}
if inList(lib, deps.ReexportHeaderLibHeaders) {
depTag.reexportFlags = true
}
lib = rewriteSnapshotLibs(lib, vendorSnapshotHeaderLibs)
lib = rewriteSnapshotLibs(lib, snapshotHeaderLibs)
if c.IsStubs() {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
@@ -1930,7 +1974,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// map from sysprop_library to implementation library; it will be used in whole_static_libs,
// static_libs, and shared_libs.
syspropImplLibraries := syspropImplLibraries(actx.Config())
vendorSnapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
for _, lib := range deps.WholeStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
@@ -1938,7 +1981,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
lib = impl
}
lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
lib = rewriteSnapshotLibs(lib, snapshotStaticLibs)
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
@@ -1958,7 +2001,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
lib = impl
}
lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
lib = rewriteSnapshotLibs(lib, snapshotStaticLibs)
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
@@ -1972,14 +2015,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, rewriteSnapshotLibs(staticUnwinder(actx), vendorSnapshotStaticLibs))
}, depTag, rewriteSnapshotLibs(staticUnwinder(actx), snapshotStaticLibs))
}
for _, lib := range deps.LateStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs))
}, depTag, rewriteSnapshotLibs(lib, snapshotStaticLibs))
}
// shared lib names without the #version suffix
@@ -2039,17 +2082,15 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
actx.AddDependency(c, depTag, gen)
}
vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
crtVariations := GetCrtVariations(ctx, c)
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
if deps.CrtBegin != "" {
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
rewriteSnapshotLibs(deps.CrtBegin, snapshotObjects))
}
if deps.CrtEnd != "" {
actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
rewriteSnapshotLibs(deps.CrtEnd, vendorSnapshotObjects))
rewriteSnapshotLibs(deps.CrtEnd, snapshotObjects))
}
if deps.LinkerFlagsFile != "" {
actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
@@ -2761,6 +2802,7 @@ func baseLibName(depName string) string {
func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface, depName string) string {
vendorSuffixModules := vendorSuffixModules(ctx.Config())
recoverySuffixModules := recoverySuffixModules(ctx.Config())
vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
libName := baseLibName(depName)
@@ -2778,8 +2820,10 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,
return baseName + ".vendor"
}
if vendorSuffixModules[baseName] {
if c.inVendor() && vendorSuffixModules[baseName] {
return baseName + ".vendor"
} else if c.InRecovery() && recoverySuffixModules[baseName] {
return baseName + ".recovery"
} else {
return baseName
}