Merge "Add vendor snapshot modules"
This commit is contained in:
134
cc/cc.go
134
cc/cc.go
@@ -49,6 +49,8 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.BottomUp("version", VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", BeginMutator).Parallel()
|
||||
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
|
||||
ctx.BottomUp("vendor_snapshot", VendorSnapshotMutator).Parallel()
|
||||
ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel()
|
||||
})
|
||||
|
||||
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
@@ -923,8 +925,16 @@ func (c *Module) nativeCoverage() bool {
|
||||
}
|
||||
|
||||
func (c *Module) isSnapshotPrebuilt() bool {
|
||||
_, ok := c.linker.(*vndkPrebuiltLibraryDecorator)
|
||||
return ok
|
||||
if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
|
||||
return true
|
||||
}
|
||||
if _, ok := c.linker.(*vendorSnapshotLibraryDecorator); ok {
|
||||
return true
|
||||
}
|
||||
if _, ok := c.linker.(*vendorSnapshotBinaryDecorator); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Module) ExportedIncludeDirs() android.Paths {
|
||||
@@ -1612,6 +1622,10 @@ func StubsLibNameAndVersion(name string) (string, string) {
|
||||
}
|
||||
|
||||
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
if !c.Enabled() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx := &depsContext{
|
||||
BottomUpMutatorContext: actx,
|
||||
moduleContextImpl: moduleContextImpl{
|
||||
@@ -1627,7 +1641,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
if ctx.Os() == android.Android {
|
||||
version := ctx.sdkVersion()
|
||||
|
||||
// rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
|
||||
// rewriteLibs takes a list of names of shared libraries and scans it for three types
|
||||
// of names:
|
||||
//
|
||||
// 1. Name of an NDK library that refers to a prebuilt module.
|
||||
@@ -1643,7 +1657,26 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
// nonvariantLibs
|
||||
|
||||
vendorPublicLibraries := vendorPublicLibraries(actx.Config())
|
||||
rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
|
||||
vendorSnapshotSharedLibs := vendorSnapshotSharedLibs(actx.Config())
|
||||
|
||||
rewriteVendorLibs := func(lib string) string {
|
||||
if isLlndkLibrary(lib, ctx.Config()) {
|
||||
return lib + llndkLibrarySuffix
|
||||
}
|
||||
|
||||
// only modules with BOARD_VNDK_VERSION uses snapshot.
|
||||
if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
|
||||
return lib
|
||||
}
|
||||
|
||||
if snapshot, ok := vendorSnapshotSharedLibs.get(lib, actx.Arch().ArchType); ok {
|
||||
return snapshot
|
||||
}
|
||||
|
||||
return lib
|
||||
}
|
||||
|
||||
rewriteLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
|
||||
variantLibs = []string{}
|
||||
nonvariantLibs = []string{}
|
||||
for _, entry := range list {
|
||||
@@ -1655,8 +1688,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
} else {
|
||||
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
|
||||
}
|
||||
} else if ctx.useVndk() && isLlndkLibrary(name, ctx.Config()) {
|
||||
nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix)
|
||||
} else if ctx.useVndk() {
|
||||
nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
|
||||
} else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
|
||||
vendorPublicLib := name + vendorPublicLibrarySuffix
|
||||
if actx.OtherModuleExists(vendorPublicLib) {
|
||||
@@ -1675,9 +1708,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
return nonvariantLibs, variantLibs
|
||||
}
|
||||
|
||||
deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
|
||||
deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
|
||||
deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
|
||||
deps.SharedLibs, variantNdkLibs = rewriteLibs(deps.SharedLibs)
|
||||
deps.LateSharedLibs, variantLateNdkLibs = rewriteLibs(deps.LateSharedLibs)
|
||||
deps.ReexportSharedLibHeaders, _ = rewriteLibs(deps.ReexportSharedLibHeaders)
|
||||
if ctx.useVndk() {
|
||||
for idx, lib := range deps.RuntimeLibs {
|
||||
deps.RuntimeLibs[idx] = rewriteVendorLibs(lib)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildStubs := false
|
||||
@@ -1689,11 +1727,28 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
}
|
||||
}
|
||||
|
||||
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
||||
// only modules with BOARD_VNDK_VERSION uses snapshot.
|
||||
if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
|
||||
return lib
|
||||
}
|
||||
|
||||
if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok {
|
||||
return snapshot
|
||||
}
|
||||
|
||||
return lib
|
||||
}
|
||||
|
||||
vendorSnapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config())
|
||||
for _, lib := range deps.HeaderLibs {
|
||||
depTag := headerDepTag
|
||||
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
||||
depTag = headerExportDepTag
|
||||
}
|
||||
|
||||
lib = rewriteSnapshotLibs(lib, vendorSnapshotHeaderLibs)
|
||||
|
||||
if buildStubs {
|
||||
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
|
||||
depTag, lib)
|
||||
@@ -1709,12 +1764,16 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
syspropImplLibraries := syspropImplLibraries(actx.Config())
|
||||
vendorSnapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
|
||||
|
||||
for _, lib := range deps.WholeStaticLibs {
|
||||
depTag := wholeStaticDepTag
|
||||
if impl, ok := syspropImplLibraries[lib]; ok {
|
||||
lib = impl
|
||||
}
|
||||
|
||||
lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, depTag, lib)
|
||||
@@ -1730,14 +1789,18 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
lib = impl
|
||||
}
|
||||
|
||||
lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, depTag, lib)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, lateStaticDepTag, deps.LateStaticLibs...)
|
||||
for _, lib := range deps.LateStaticLibs {
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, lateStaticDepTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs))
|
||||
}
|
||||
|
||||
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
|
||||
var variations []blueprint.Variation
|
||||
@@ -2284,14 +2347,33 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
*depPtr = append(*depPtr, dep.Path())
|
||||
}
|
||||
|
||||
makeLibName := func(depName string) string {
|
||||
vendorSuffixModules := vendorSuffixModules(ctx.Config())
|
||||
|
||||
baseLibName := func(depName string) string {
|
||||
libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
|
||||
libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
|
||||
libName = strings.TrimPrefix(libName, "prebuilt_")
|
||||
return libName
|
||||
}
|
||||
|
||||
makeLibName := func(depName string) string {
|
||||
libName := baseLibName(depName)
|
||||
isLLndk := isLlndkLibrary(libName, ctx.Config())
|
||||
isVendorPublicLib := inList(libName, *vendorPublicLibraries)
|
||||
bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk
|
||||
|
||||
if c, ok := ccDep.(*Module); ok {
|
||||
// Use base module name for snapshots when exporting to Makefile.
|
||||
if c.isSnapshotPrebuilt() && !c.IsVndk() {
|
||||
baseName := c.BaseModuleName()
|
||||
if vendorSuffixModules[baseName] {
|
||||
return baseName + ".vendor"
|
||||
} else {
|
||||
return baseName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRamdisk() && !c.InRecovery() {
|
||||
// The vendor module is a no-vendor-variant VNDK library. Depend on the
|
||||
// core module instead.
|
||||
@@ -2331,8 +2413,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
// they merely serve as Make dependencies and do not affect this lib itself.
|
||||
c.Properties.AndroidMkSharedLibs = append(
|
||||
c.Properties.AndroidMkSharedLibs, makeLibName(depName))
|
||||
// Record depName as-is for snapshots.
|
||||
c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, depName)
|
||||
// Record baseLibName for snapshots.
|
||||
c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, baseLibName(depName))
|
||||
case ndkStubDepTag, ndkLateStubDepTag:
|
||||
c.Properties.AndroidMkSharedLibs = append(
|
||||
c.Properties.AndroidMkSharedLibs,
|
||||
@@ -2343,8 +2425,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
case runtimeDepTag:
|
||||
c.Properties.AndroidMkRuntimeLibs = append(
|
||||
c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
|
||||
// Record depName as-is for snapshots.
|
||||
c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, depName)
|
||||
// Record baseLibName for snapshots.
|
||||
c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, baseLibName(depName))
|
||||
case wholeStaticDepTag:
|
||||
c.Properties.AndroidMkWholeStaticLibs = append(
|
||||
c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
|
||||
@@ -2719,10 +2801,16 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
|
||||
platformVndkVersion,
|
||||
productVndkVersion,
|
||||
)
|
||||
} else if lib, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
|
||||
} else if m.isSnapshotPrebuilt() {
|
||||
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
|
||||
// PRODUCT_EXTRA_VNDK_VERSIONS.
|
||||
vendorVariants = append(vendorVariants, lib.version())
|
||||
if snapshot, ok := m.linker.(interface {
|
||||
version() string
|
||||
}); ok {
|
||||
vendorVariants = append(vendorVariants, snapshot.version())
|
||||
} else {
|
||||
mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
|
||||
}
|
||||
} else if m.HasVendorVariant() && !vendorSpecific {
|
||||
// This will be available in /system, /vendor and /product
|
||||
// or a /system directory that is available to vendor and product.
|
||||
@@ -2819,6 +2907,14 @@ func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string
|
||||
m.Properties.ImageVariationPrefix = VendorVariationPrefix
|
||||
m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
|
||||
squashVendorSrcs(m)
|
||||
|
||||
// Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
|
||||
// Hide other vendor variants to avoid collision.
|
||||
vndkVersion := ctx.DeviceConfig().VndkVersion()
|
||||
if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
|
||||
m.Properties.HideFromMake = true
|
||||
m.SkipInstall()
|
||||
}
|
||||
} else if strings.HasPrefix(variant, ProductVariationPrefix) {
|
||||
m.Properties.ImageVariationPrefix = ProductVariationPrefix
|
||||
m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
|
||||
|
Reference in New Issue
Block a user