Delete multitree api imports code
The mutltiree workflow has not been in use for a while. This CL cleans
up the code that was added to support multitree.
Details
- Delete cc_api_library, cc_api_headers, cc_api_variant module types.
These module types contain build rules for prebuilt stub .so and .h
files
- Update the DepsMutator of cc.Module to not create a dependency on a
sibling cc_api_* module if it exists. e.g. do not create a dependency
on libfoo.apiimports if libfoo is listed in `shared_libs`.
- Remove cc_api_library from the stub/impl selection logic for cc
modules
Test: m nothing --no-skip-soong-tests
Test: presbumits
Change-Id: Ie194157fb3bbc630f384cdd9b694b0fba6786ded
diff --git a/cc/Android.bp b/cc/Android.bp
index e68e4a3..2952614 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -16,7 +16,6 @@
"soong-etc",
"soong-fuzz",
"soong-genrule",
- "soong-multitree",
"soong-testing",
"soong-tradefed",
],
@@ -65,7 +64,6 @@
"library.go",
"library_headers.go",
"library_sdk_member.go",
- "library_stub.go",
"native_bridge_sdk_trait.go",
"object.go",
"test.go",
diff --git a/cc/androidmk.go b/cc/androidmk.go
index cecaae2..6966f76 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -21,7 +21,6 @@
"strings"
"android/soong/android"
- "android/soong/multitree"
)
var (
@@ -479,34 +478,6 @@
androidMkWritePrebuiltOptions(p.baseLinker, entries)
}
-func (a *apiLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
- entries.Class = "SHARED_LIBRARIES"
- entries.SubName += multitree.GetApiImportSuffix()
-
- entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
- a.libraryDecorator.androidMkWriteExportedFlags(entries)
- src := *a.properties.Src
- path, file := filepath.Split(src)
- stem, suffix, ext := android.SplitFileExt(file)
- entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
- entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
- entries.SetString("LOCAL_MODULE_STEM", stem)
- entries.SetString("LOCAL_MODULE_PATH", path)
- entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
- entries.SetString("LOCAL_SOONG_TOC", a.toc().String())
- })
-}
-
-func (a *apiHeadersDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
- entries.Class = "HEADER_LIBRARIES"
- entries.SubName += multitree.GetApiImportSuffix()
-
- entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
- a.libraryDecorator.androidMkWriteExportedFlags(entries)
- entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
- })
-}
-
func androidMkWritePrebuiltOptions(linker *baseLinker, entries *android.AndroidMkEntries) {
allow := linker.Properties.Allow_undefined_symbols
if allow != nil {
diff --git a/cc/cc.go b/cc/cc.go
index b534737..dd0e581 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -34,7 +34,6 @@
"android/soong/cc/config"
"android/soong/fuzz"
"android/soong/genrule"
- "android/soong/multitree"
)
func init() {
@@ -2361,24 +2360,6 @@
}
}
-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 @@
// NDK Variant
return true
}
-
- if c.isImportedApiLibrary() {
- // API Library should depend on API headers
- return true
- }
}
return false
@@ -2472,19 +2448,10 @@
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 @@
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 @@
// 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 @@
}
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 @@
)
}
- updateImportedLibraryDependency(ctx)
}
func BeginMutator(ctx android.BottomUpMutatorContext) {
@@ -2730,10 +2681,6 @@
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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
return c.Properties.IsSdkVariant
}
-func (c *Module) isImportedApiLibrary() bool {
- _, ok := c.linker.(*apiLibraryDecorator)
- return ok
-}
-
func kytheExtractAllFactory() android.Singleton {
return &kytheExtractAllSingleton{}
}
diff --git a/cc/library.go b/cc/library.go
index 03f7174..ebc4c5f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2350,9 +2350,8 @@
if library := moduleLibraryInterface(ctx.Module()); library != nil && canBeVersionVariant(m) {
isLLNDK := m.IsLlndk()
isVendorPublicLibrary := m.IsVendorPublicLibrary()
- isImportedApiLibrary := m.isImportedApiLibrary()
- if variation != "" || isLLNDK || isVendorPublicLibrary || isImportedApiLibrary {
+ if variation != "" || isLLNDK || isVendorPublicLibrary {
// A stubs or LLNDK stubs variant.
if m.sanitize != nil {
m.sanitize.Properties.ForceDisable = true
diff --git a/cc/library_stub.go b/cc/library_stub.go
deleted file mode 100644
index 6367825..0000000
--- a/cc/library_stub.go
+++ /dev/null
@@ -1,512 +0,0 @@
-// Copyright 2021 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package cc
-
-import (
- "regexp"
- "strings"
-
- "android/soong/android"
- "android/soong/multitree"
-
- "github.com/google/blueprint/proptools"
-)
-
-var (
- ndkVariantRegex = regexp.MustCompile("ndk\\.([a-zA-Z0-9]+)")
- stubVariantRegex = regexp.MustCompile("apex\\.([a-zA-Z0-9]+)")
-)
-
-func init() {
- RegisterLibraryStubBuildComponents(android.InitRegistrationContext)
-}
-
-func RegisterLibraryStubBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("cc_api_library", CcApiLibraryFactory)
- ctx.RegisterModuleType("cc_api_headers", CcApiHeadersFactory)
- ctx.RegisterModuleType("cc_api_variant", CcApiVariantFactory)
-}
-
-func updateImportedLibraryDependency(ctx android.BottomUpMutatorContext) {
- m, ok := ctx.Module().(*Module)
- if !ok {
- return
- }
-
- apiLibrary, ok := m.linker.(*apiLibraryDecorator)
- if !ok {
- return
- }
-
- if m.InVendorOrProduct() && apiLibrary.hasLLNDKStubs() {
- // Add LLNDK variant dependency
- if inList("llndk", apiLibrary.properties.Variants) {
- variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "")
- ctx.AddDependency(m, nil, variantName)
- }
- } else if m.IsSdkVariant() {
- // Add NDK variant dependencies
- targetVariant := "ndk." + m.StubsVersion()
- if inList(targetVariant, apiLibrary.properties.Variants) {
- variantName := BuildApiVariantName(m.BaseModuleName(), targetVariant, "")
- ctx.AddDependency(m, nil, variantName)
- }
- } else if m.IsStubs() {
- targetVariant := "apex." + m.StubsVersion()
- if inList(targetVariant, apiLibrary.properties.Variants) {
- variantName := BuildApiVariantName(m.BaseModuleName(), targetVariant, "")
- ctx.AddDependency(m, nil, variantName)
- }
- }
-}
-
-// 'cc_api_library' is a module type which is from the exported API surface
-// with C shared library type. The module will replace original module, and
-// offer a link to the module that generates shared library object from the
-// map file.
-type apiLibraryProperties struct {
- Src *string `android:"arch_variant"`
- Variants []string
-}
-
-type apiLibraryDecorator struct {
- *libraryDecorator
- properties apiLibraryProperties
-}
-
-func CcApiLibraryFactory() android.Module {
- module, decorator := NewLibrary(android.DeviceSupported)
- apiLibraryDecorator := &apiLibraryDecorator{
- libraryDecorator: decorator,
- }
- apiLibraryDecorator.BuildOnlyShared()
-
- module.stl = nil
- module.sanitize = nil
- decorator.disableStripping()
-
- module.compiler = nil
- module.linker = apiLibraryDecorator
- module.installer = nil
- module.library = apiLibraryDecorator
- module.AddProperties(&module.Properties, &apiLibraryDecorator.properties)
-
- // Prevent default system libs (libc, libm, and libdl) from being linked
- if apiLibraryDecorator.baseLinker.Properties.System_shared_libs == nil {
- apiLibraryDecorator.baseLinker.Properties.System_shared_libs = []string{}
- }
-
- apiLibraryDecorator.baseLinker.Properties.No_libcrt = BoolPtr(true)
- apiLibraryDecorator.baseLinker.Properties.Nocrt = BoolPtr(true)
-
- module.Init()
-
- return module
-}
-
-func (d *apiLibraryDecorator) Name(basename string) string {
- return basename + multitree.GetApiImportSuffix()
-}
-
-// Export include dirs without checking for existence.
-// The directories are not guaranteed to exist during Soong analysis.
-func (d *apiLibraryDecorator) exportIncludes(ctx ModuleContext) {
- exporterProps := d.flagExporter.Properties
- for _, dir := range exporterProps.Export_include_dirs.GetOrDefault(ctx, nil) {
- d.dirs = append(d.dirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
- }
- // system headers
- for _, dir := range exporterProps.Export_system_include_dirs {
- d.systemDirs = append(d.systemDirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
- }
-}
-
-func (d *apiLibraryDecorator) linkerInit(ctx BaseModuleContext) {
- d.baseLinker.linkerInit(ctx)
-
- if d.hasNDKStubs() {
- // Set SDK version of module as current
- ctx.Module().(*Module).Properties.Sdk_version = StringPtr("current")
-
- // Add NDK stub as NDK known libs
- name := ctx.ModuleName()
-
- ndkKnownLibsLock.Lock()
- ndkKnownLibs := getNDKKnownLibs(ctx.Config())
- if !inList(name, *ndkKnownLibs) {
- *ndkKnownLibs = append(*ndkKnownLibs, name)
- }
- ndkKnownLibsLock.Unlock()
- }
-}
-
-func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objects Objects) android.Path {
- m, _ := ctx.Module().(*Module)
-
- var in android.Path
-
- // src might not exist during the beginning of soong analysis in Multi-tree
- if src := String(d.properties.Src); src != "" {
- in = android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), src)
- }
-
- libName := m.BaseModuleName() + multitree.GetApiImportSuffix()
-
- load_cc_variant := func(apiVariantModule string) {
- var mod android.Module
-
- ctx.VisitDirectDeps(func(depMod android.Module) {
- if depMod.Name() == apiVariantModule {
- mod = depMod
- libName = apiVariantModule
- }
- })
-
- if mod != nil {
- variantMod, ok := mod.(*CcApiVariant)
- if ok {
- in = variantMod.Src()
-
- // Copy LLDNK properties to cc_api_library module
- exportIncludeDirs := append(d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil),
- variantMod.exportProperties.Export_include_dirs...)
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
- nil,
- []proptools.ConfigurableCase[[]string]{
- proptools.NewConfigurableCase[[]string](nil, &exportIncludeDirs),
- },
- )
-
- // Export headers as system include dirs if specified. Mostly for libc
- if Bool(variantMod.exportProperties.Export_headers_as_system) {
- d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs = append(
- d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs,
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil)...)
- d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](nil, nil)
- }
- }
- }
- }
-
- if m.InVendorOrProduct() && d.hasLLNDKStubs() {
- // LLNDK variant
- load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", ""))
- } else if m.IsSdkVariant() {
- // NDK Variant
- load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "ndk", m.StubsVersion()))
- } else if m.IsStubs() {
- // APEX Variant
- load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "apex", m.StubsVersion()))
- }
-
- // Flags reexported from dependencies. (e.g. vndk_prebuilt_shared)
- d.exportIncludes(ctx)
- d.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
- d.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
- d.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
- d.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
- d.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
-
- if in == nil {
- ctx.PropertyErrorf("src", "Unable to locate source property")
- return nil
- }
-
- // Make the _compilation_ of rdeps have an order-only dep on cc_api_library.src (an .so file)
- // The .so file itself has an order-only dependency on the headers contributed by this library.
- // Creating this dependency ensures that the headers are assembled before compilation of rdeps begins.
- d.libraryDecorator.reexportDeps(in)
- d.libraryDecorator.flagExporter.setProvider(ctx)
-
- d.unstrippedOutputFile = in
- libName += flags.Toolchain.ShlibSuffix()
-
- tocFile := android.PathForModuleOut(ctx, libName+".toc")
- d.tocFile = android.OptionalPathForPath(tocFile)
- TransformSharedObjectToToc(ctx, in, tocFile)
-
- outputFile := android.PathForModuleOut(ctx, libName)
-
- // TODO(b/270485584) This copies with a new name, just to avoid conflict with prebuilts.
- // We can just use original input if there is any way to avoid name conflict without copy.
- ctx.Build(pctx, android.BuildParams{
- Rule: android.Cp,
- Description: "API surface imported library",
- Input: in,
- Output: outputFile,
- Args: map[string]string{
- "cpFlags": "-L",
- },
- })
-
- android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
- SharedLibrary: outputFile,
- Target: ctx.Target(),
-
- TableOfContents: d.tocFile,
- })
-
- d.shareStubs(ctx)
-
- return outputFile
-}
-
-// Share additional information about stub libraries with provider
-func (d *apiLibraryDecorator) shareStubs(ctx ModuleContext) {
- stubs := ctx.GetDirectDepsWithTag(stubImplDepTag)
- if len(stubs) > 0 {
- var stubsInfo []SharedStubLibrary
- for _, stub := range stubs {
- stubInfo, _ := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
- flagInfo, _ := android.OtherModuleProvider(ctx, stub, FlagExporterInfoProvider)
- stubsInfo = append(stubsInfo, SharedStubLibrary{
- Version: moduleLibraryInterface(stub).stubsVersion(),
- SharedLibraryInfo: stubInfo,
- FlagExporterInfo: flagInfo,
- })
- }
- android.SetProvider(ctx, SharedLibraryStubsProvider, SharedLibraryStubsInfo{
- SharedStubLibraries: stubsInfo,
-
- IsLLNDK: ctx.IsLlndk(),
- })
- }
-}
-
-func (d *apiLibraryDecorator) availableFor(what string) bool {
- // Stub from API surface should be available for any APEX.
- return true
-}
-
-func (d *apiLibraryDecorator) hasApexStubs() bool {
- for _, variant := range d.properties.Variants {
- if strings.HasPrefix(variant, "apex") {
- return true
- }
- }
- return false
-}
-
-func (d *apiLibraryDecorator) hasStubsVariants() bool {
- return d.hasApexStubs()
-}
-
-func (d *apiLibraryDecorator) stubsVersions(ctx android.BaseModuleContext) []string {
- m, ok := ctx.Module().(*Module)
-
- if !ok {
- return nil
- }
-
- // TODO(b/244244438) Create more version information for NDK and APEX variations
- // NDK variants
- if m.IsSdkVariant() {
- // TODO(b/249193999) Do not check if module has NDK stubs once all NDK cc_api_library contains ndk variant of cc_api_variant.
- if d.hasNDKStubs() {
- return d.getNdkVersions()
- }
- }
-
- if d.hasLLNDKStubs() && m.InVendorOrProduct() {
- // LLNDK libraries only need a single stubs variant.
- return []string{android.FutureApiLevel.String()}
- }
-
- stubsVersions := d.getStubVersions()
-
- if len(stubsVersions) != 0 {
- return stubsVersions
- }
-
- if m.MinSdkVersion() == "" {
- return nil
- }
-
- firstVersion, err := nativeApiLevelFromUser(ctx,
- m.MinSdkVersion())
-
- if err != nil {
- return nil
- }
-
- return ndkLibraryVersions(ctx, firstVersion)
-}
-
-func (d *apiLibraryDecorator) hasLLNDKStubs() bool {
- return inList("llndk", d.properties.Variants)
-}
-
-func (d *apiLibraryDecorator) hasNDKStubs() bool {
- for _, variant := range d.properties.Variants {
- if ndkVariantRegex.MatchString(variant) {
- return true
- }
- }
- return false
-}
-
-func (d *apiLibraryDecorator) getNdkVersions() []string {
- ndkVersions := []string{}
-
- for _, variant := range d.properties.Variants {
- if match := ndkVariantRegex.FindStringSubmatch(variant); len(match) == 2 {
- ndkVersions = append(ndkVersions, match[1])
- }
- }
-
- return ndkVersions
-}
-
-func (d *apiLibraryDecorator) getStubVersions() []string {
- stubVersions := []string{}
-
- for _, variant := range d.properties.Variants {
- if match := stubVariantRegex.FindStringSubmatch(variant); len(match) == 2 {
- stubVersions = append(stubVersions, match[1])
- }
- }
-
- return stubVersions
-}
-
-// 'cc_api_headers' is similar with 'cc_api_library', but which replaces
-// header libraries. The module will replace any dependencies to existing
-// original header libraries.
-type apiHeadersDecorator struct {
- *libraryDecorator
-}
-
-func CcApiHeadersFactory() android.Module {
- module, decorator := NewLibrary(android.DeviceSupported)
- apiHeadersDecorator := &apiHeadersDecorator{
- libraryDecorator: decorator,
- }
- apiHeadersDecorator.HeaderOnly()
-
- module.stl = nil
- module.sanitize = nil
- decorator.disableStripping()
-
- module.compiler = nil
- module.linker = apiHeadersDecorator
- module.installer = nil
-
- // Prevent default system libs (libc, libm, and libdl) from being linked
- if apiHeadersDecorator.baseLinker.Properties.System_shared_libs == nil {
- apiHeadersDecorator.baseLinker.Properties.System_shared_libs = []string{}
- }
-
- apiHeadersDecorator.baseLinker.Properties.No_libcrt = BoolPtr(true)
- apiHeadersDecorator.baseLinker.Properties.Nocrt = BoolPtr(true)
-
- module.Init()
-
- return module
-}
-
-func (d *apiHeadersDecorator) Name(basename string) string {
- return basename + multitree.GetApiImportSuffix()
-}
-
-func (d *apiHeadersDecorator) availableFor(what string) bool {
- // Stub from API surface should be available for any APEX.
- return true
-}
-
-type ccApiexportProperties struct {
- Src *string `android:"arch_variant"`
- Variant *string
- Version *string
-}
-
-type variantExporterProperties struct {
- // Header directory to export
- Export_include_dirs []string `android:"arch_variant"`
-
- // Export all headers as system include
- Export_headers_as_system *bool
-}
-
-type CcApiVariant struct {
- android.ModuleBase
-
- properties ccApiexportProperties
- exportProperties variantExporterProperties
-
- src android.Path
-}
-
-var _ android.Module = (*CcApiVariant)(nil)
-var _ android.ImageInterface = (*CcApiVariant)(nil)
-
-func CcApiVariantFactory() android.Module {
- module := &CcApiVariant{}
-
- module.AddProperties(&module.properties)
- module.AddProperties(&module.exportProperties)
-
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
- return module
-}
-
-func (v *CcApiVariant) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- // No need to build
-
- if String(v.properties.Src) == "" {
- ctx.PropertyErrorf("src", "src is a required property")
- }
-
- // Skip the existence check of the stub prebuilt file.
- // The file is not guaranteed to exist during Soong analysis.
- // Build orchestrator will be responsible for creating a connected ninja graph.
- v.src = android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), String(v.properties.Src))
-}
-
-func (v *CcApiVariant) Name() string {
- version := String(v.properties.Version)
- return BuildApiVariantName(v.BaseModuleName(), *v.properties.Variant, version)
-}
-
-func (v *CcApiVariant) Src() android.Path {
- return v.src
-}
-
-func BuildApiVariantName(baseName string, variant string, version string) string {
- names := []string{baseName, variant}
- if version != "" {
- names = append(names, version)
- }
-
- return strings.Join(names[:], ".") + multitree.GetApiImportSuffix()
-}
-
-// Implement ImageInterface to generate image variants
-func (v *CcApiVariant) ImageMutatorBegin(ctx android.BaseModuleContext) {}
-func (v *CcApiVariant) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
- return String(v.properties.Variant) == "llndk"
-}
-func (v *CcApiVariant) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
- return String(v.properties.Variant) == "llndk"
-}
-func (v *CcApiVariant) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
- return inList(String(v.properties.Variant), []string{"ndk", "apex"})
-}
-func (v *CcApiVariant) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { return false }
-func (v *CcApiVariant) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { return false }
-func (v *CcApiVariant) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { return false }
-func (v *CcApiVariant) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { return false }
-func (v *CcApiVariant) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
-func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string) {
-}
diff --git a/cc/sdk.go b/cc/sdk.go
index dc1261d..5dd44d8 100644
--- a/cc/sdk.go
+++ b/cc/sdk.go
@@ -51,13 +51,6 @@
return []string{""}
}
}
- case *CcApiVariant:
- ccApiVariant, _ := ctx.Module().(*CcApiVariant)
- if String(ccApiVariant.properties.Variant) == "ndk" {
- return []string{"sdk"}
- } else {
- return []string{""}
- }
}
return []string{""}
@@ -84,11 +77,6 @@
return incomingVariation
}
}
- case *CcApiVariant:
- ccApiVariant, _ := ctx.Module().(*CcApiVariant)
- if String(ccApiVariant.properties.Variant) == "ndk" {
- return "sdk"
- }
}
if ctx.IsAddingDependency() {
diff --git a/cc/testing.go b/cc/testing.go
index 159f86c..14a6b7a 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -20,7 +20,6 @@
"android/soong/android"
"android/soong/genrule"
- "android/soong/multitree"
)
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
@@ -29,9 +28,6 @@
RegisterBinaryBuildComponents(ctx)
RegisterLibraryBuildComponents(ctx)
RegisterLibraryHeadersBuildComponents(ctx)
- RegisterLibraryStubBuildComponents(ctx)
-
- multitree.RegisterApiImportsModule(ctx)
ctx.RegisterModuleType("prebuilt_build_tool", android.NewPrebuiltBuildTool)
ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)