Merge "Delete multitree api imports code" into main

This commit is contained in:
Spandan Das
2024-09-11 22:20:52 +00:00
committed by Gerrit Code Review
17 changed files with 6 additions and 1426 deletions

121
cc/cc.go
View File

@@ -34,7 +34,6 @@ import (
"android/soong/cc/config"
"android/soong/fuzz"
"android/soong/genrule"
"android/soong/multitree"
)
func init() {
@@ -2361,24 +2360,6 @@ func AddSharedLibDependenciesWithVersions(ctx android.BottomUpMutatorContext, mo
}
}
func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) multitree.ApiImportInfo {
apiImportInfo := multitree.ApiImportInfo{}
if c.Device() {
var apiImportModule []blueprint.Module
if actx.OtherModuleExists("api_imports") {
apiImportModule = actx.AddDependency(c, nil, "api_imports")
if len(apiImportModule) > 0 && apiImportModule[0] != nil {
apiInfo, _ := android.OtherModuleProvider(actx, apiImportModule[0], multitree.ApiImportsProvider)
apiImportInfo = apiInfo
android.SetProvider(actx, multitree.ApiImportsProvider, apiInfo)
}
}
}
return apiImportInfo
}
func GetReplaceModuleName(lib string, replaceMap map[string]string) string {
if snapshot, ok := replaceMap[lib]; ok {
return snapshot
@@ -2448,11 +2429,6 @@ func (c *Module) shouldUseApiSurface() bool {
// NDK Variant
return true
}
if c.isImportedApiLibrary() {
// API Library should depend on API headers
return true
}
}
return false
@@ -2472,19 +2448,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
ctx.ctx = ctx
deps := c.deps(ctx)
apiImportInfo := GetApiImports(c, actx)
apiNdkLibs := []string{}
apiLateNdkLibs := []string{}
if c.shouldUseApiSurface() {
deps.SharedLibs, apiNdkLibs = rewriteLibsForApiImports(c, deps.SharedLibs, apiImportInfo.SharedLibs, ctx.Config())
deps.LateSharedLibs, apiLateNdkLibs = rewriteLibsForApiImports(c, deps.LateSharedLibs, apiImportInfo.SharedLibs, ctx.Config())
deps.SystemSharedLibs, _ = rewriteLibsForApiImports(c, deps.SystemSharedLibs, apiImportInfo.SharedLibs, ctx.Config())
deps.ReexportHeaderLibHeaders, _ = rewriteLibsForApiImports(c, deps.ReexportHeaderLibHeaders, apiImportInfo.SharedLibs, ctx.Config())
deps.ReexportSharedLibHeaders, _ = rewriteLibsForApiImports(c, deps.ReexportSharedLibHeaders, apiImportInfo.SharedLibs, ctx.Config())
}
c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs
variantNdkLibs := []string{}
@@ -2501,11 +2468,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
depTag.reexportFlags = true
}
// Check header lib replacement from API surface first, and then check again with VSDK
if c.shouldUseApiSurface() {
lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs)
}
if c.isNDKStubLibrary() {
variationExists := actx.OtherModuleDependencyVariantExists(nil, lib)
if variationExists {
@@ -2515,7 +2477,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// any variants.
actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
}
} else if c.IsStubs() && !c.isImportedApiLibrary() {
} else if c.IsStubs() {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
depTag, lib)
} else {
@@ -2591,22 +2553,12 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
name, version := StubsLibNameAndVersion(lib)
if apiLibraryName, ok := apiImportInfo.SharedLibs[name]; ok && !ctx.OtherModuleExists(name) {
name = apiLibraryName
}
sharedLibNames = append(sharedLibNames, name)
variations := []blueprint.Variation{
{Mutator: "link", Variation: "shared"},
}
if _, ok := apiImportInfo.ApexSharedLibs[name]; !ok || ctx.OtherModuleExists(name) {
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, name, version, false)
}
if apiLibraryName, ok := apiImportInfo.ApexSharedLibs[name]; ok {
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, apiLibraryName, version, false)
}
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, name, version, false)
}
for _, lib := range deps.LateStaticLibs {
@@ -2701,7 +2653,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
)
}
updateImportedLibraryDependency(ctx)
}
func BeginMutator(ctx android.BottomUpMutatorContext) {
@@ -2730,10 +2681,6 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
return
}
// TODO(b/244244438) : Remove this once all variants are implemented
if ccFrom, ok := from.(*Module); ok && ccFrom.isImportedApiLibrary() {
return
}
if from.SdkVersion() == "" {
// Platform code can link to anything
return
@@ -2756,10 +2703,6 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
// the NDK.
return
}
if c.isImportedApiLibrary() {
// Imported library from the API surface is a stub library built against interface definition.
return
}
}
if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" {
@@ -2935,47 +2878,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
skipModuleList := map[string]bool{}
var apiImportInfo multitree.ApiImportInfo
hasApiImportInfo := false
ctx.VisitDirectDeps(func(dep android.Module) {
if dep.Name() == "api_imports" {
apiImportInfo, _ = android.OtherModuleProvider(ctx, dep, multitree.ApiImportsProvider)
hasApiImportInfo = true
}
})
if hasApiImportInfo {
targetStubModuleList := map[string]string{}
targetOrigModuleList := map[string]string{}
// Search for dependency which both original module and API imported library with APEX stub exists
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
if apiLibrary, ok := apiImportInfo.ApexSharedLibs[depName]; ok {
targetStubModuleList[apiLibrary] = depName
}
})
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
if origLibrary, ok := targetStubModuleList[depName]; ok {
targetOrigModuleList[origLibrary] = depName
}
})
// Decide which library should be used between original and API imported library
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
if apiLibrary, ok := targetOrigModuleList[depName]; ok {
if ShouldUseStubForApex(ctx, dep) {
skipModuleList[depName] = true
} else {
skipModuleList[apiLibrary] = true
}
}
})
}
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
@@ -3404,17 +3306,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
// bootstrap modules, always link to non-stub variant
isNotInPlatform := dep.(android.ApexModule).NotInPlatform()
isApexImportedApiLibrary := false
if cc, ok := dep.(*Module); ok {
if apiLibrary, ok := cc.linker.(*apiLibraryDecorator); ok {
if apiLibrary.hasApexStubs() {
isApexImportedApiLibrary = true
}
}
}
useStubs = (isNotInPlatform || isApexImportedApiLibrary) && !bootstrap
useStubs = isNotInPlatform && !bootstrap
if useStubs {
// Another exception: if this module is a test for an APEX, then
@@ -3439,7 +3331,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
// only partially overlapping apex_available. For that test_for
// modules would need to be split into APEX variants and resolved
// separately for each APEX they have access to.
if !isApexImportedApiLibrary && android.AvailableToSameApexes(thisModule, dep.(android.ApexModule)) {
if android.AvailableToSameApexes(thisModule, dep.(android.ApexModule)) {
useStubs = false
}
}
@@ -4023,11 +3915,6 @@ func (c *Module) IsSdkVariant() bool {
return c.Properties.IsSdkVariant
}
func (c *Module) isImportedApiLibrary() bool {
_, ok := c.linker.(*apiLibraryDecorator)
return ok
}
func kytheExtractAllFactory() android.Singleton {
return &kytheExtractAllSingleton{}
}