summaryrefslogtreecommitdiff
path: root/cc/cc.go
diff options
context:
space:
mode:
Diffstat (limited to 'cc/cc.go')
-rw-r--r--cc/cc.go413
1 files changed, 148 insertions, 265 deletions
diff --git a/cc/cc.go b/cc/cc.go
index 0db1bd678..24f6b839c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -49,7 +49,6 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("sdk", sdkMutator).Parallel()
- ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("llndk", llndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
@@ -100,7 +99,6 @@ type Deps struct {
StaticLibs, LateStaticLibs, WholeStaticLibs []string
HeaderLibs []string
RuntimeLibs []string
- Rlibs []string
// UnexportedStaticLibs are static libraries that are also passed to -Wl,--exclude-libs= to
// prevent automatically exporting symbols.
@@ -362,6 +360,8 @@ type BaseProperties struct {
Recovery_available *bool
// Used by imageMutator, set by ImageMutatorBegin()
+ VendorVariantNeeded bool `blueprint:"mutated"`
+ ProductVariantNeeded bool `blueprint:"mutated"`
CoreVariantNeeded bool `blueprint:"mutated"`
RamdiskVariantNeeded bool `blueprint:"mutated"`
VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
@@ -480,19 +480,6 @@ type VendorProperties struct {
// IsLLNDK is set to true for the vendor variant of a cc_library module that has LLNDK stubs.
IsLLNDK bool `blueprint:"mutated"`
- // IsVNDKCore is set if a VNDK module does not set the vndk.support_system_process property.
- IsVNDKCore bool `blueprint:"mutated"`
-
- // IsVNDKSP is set if a VNDK module sets the vndk.support_system_process property.
- IsVNDKSP bool `blueprint:"mutated"`
-
- // IsVNDKPrivate is set if a VNDK module sets the vndk.private property or an LLNDK
- // module sets the llndk.private property.
- IsVNDKPrivate bool `blueprint:"mutated"`
-
- // IsVNDKProduct is set if a VNDK module sets the product_available property.
- IsVNDKProduct bool `blueprint:"mutated"`
-
// IsVendorPublicLibrary is set for the core and product variants of a library that has
// vendor_public_library stubs.
IsVendorPublicLibrary bool `blueprint:"mutated"`
@@ -519,12 +506,7 @@ type ModuleContextIntf interface {
useVndk() bool
isNdk(config android.Config) bool
IsLlndk() bool
- IsLlndkPublic() bool
isImplementationForLLNDKPublic() bool
- IsVndkPrivate() bool
- isVndk() bool
- isVndkSp() bool
- IsVndkExt() bool
IsVendorPublicLibrary() bool
inProduct() bool
inVendor() bool
@@ -534,7 +516,6 @@ type ModuleContextIntf interface {
InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
- getVndkExtendsModuleName() string
isAfdoCompile(ctx ModuleContext) bool
isOrderfileCompile() bool
isCfi() bool
@@ -764,11 +745,6 @@ func (d libraryDependencyTag) static() bool {
return d.Kind == staticLibraryDependency
}
-// rlib returns true if the libraryDependencyTag is tagging an rlib dependency.
-func (d libraryDependencyTag) rlib() bool {
- return d.Kind == rlibLibraryDependency
-}
-
func (d libraryDependencyTag) LicenseAnnotations() []android.LicenseAnnotation {
if d.shared() {
return []android.LicenseAnnotation{android.LicenseAnnotationSharedDependency}
@@ -900,7 +876,6 @@ type Module struct {
coverage *coverage
fuzzer *fuzzer
sabi *sabi
- vndkdep *vndkdep
lto *lto
afdo *afdo
orderfile *orderfile
@@ -936,6 +911,8 @@ type Module struct {
hideApexVariantFromMake bool
logtagsPaths android.Paths
+
+ WholeRustStaticlib bool
}
func (c *Module) AddJSONData(d *map[string]interface{}) {
@@ -974,12 +951,7 @@ func (c *Module) AddJSONData(d *map[string]interface{}) {
"InstallInVendorRamdisk": c.InstallInVendorRamdisk(),
"InstallInRecovery": c.InstallInRecovery(),
"InstallInRoot": c.InstallInRoot(),
- "IsVndk": c.IsVndk(),
- "IsVndkExt": c.IsVndkExt(),
- "IsVndkPrivate": c.IsVndkPrivate(),
- "IsVndkSp": c.IsVndkSp(),
"IsLlndk": c.IsLlndk(),
- "IsLlndkPublic": c.IsLlndkPublic(),
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
"ApexSdkVersion": c.apexSdkVersion,
"TestFor": c.TestFor(),
@@ -1007,8 +979,8 @@ func (c *Module) HiddenFromMake() bool {
return c.Properties.HideFromMake
}
-func (c *Module) RequiredModuleNames() []string {
- required := android.CopyOf(c.ModuleBase.RequiredModuleNames())
+func (c *Module) RequiredModuleNames(ctx android.ConfigAndErrorContext) []string {
+ required := android.CopyOf(c.ModuleBase.RequiredModuleNames(ctx))
if c.ImageVariation().Variation == android.CoreVariation {
required = append(required, c.Properties.Target.Platform.Required...)
required = removeListFromList(required, c.Properties.Target.Platform.Exclude_required)
@@ -1216,6 +1188,16 @@ func (c *Module) BuildSharedVariant() bool {
panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", c.BaseModuleName()))
}
+func (c *Module) BuildRlibVariant() bool {
+ // cc modules can never build rlib variants
+ return false
+}
+
+func (c *Module) IsRustFFI() bool {
+ // cc modules are not Rust modules
+ return false
+}
+
func (c *Module) Module() android.Module {
return c
}
@@ -1289,9 +1271,6 @@ func (c *Module) Init() android.Module {
if c.sabi != nil {
c.AddProperties(c.sabi.props()...)
}
- if c.vndkdep != nil {
- c.AddProperties(c.vndkdep.props()...)
- }
if c.lto != nil {
c.AddProperties(c.lto.props()...)
}
@@ -1346,10 +1325,6 @@ func (c *Module) IsLlndk() bool {
return c.VendorProperties.IsLLNDK
}
-func (c *Module) IsLlndkPublic() bool {
- return c.VendorProperties.IsLLNDK && !c.VendorProperties.IsVNDKPrivate
-}
-
func (m *Module) NeedsLlndkVariants() bool {
lib := moduleLibraryInterface(m)
return lib != nil && (lib.hasLLNDKStubs() || lib.hasLLNDKHeaders())
@@ -1396,31 +1371,6 @@ func (c *Module) isImplementationForLLNDKPublic() bool {
!Bool(library.Properties.Llndk.Private)
}
-// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
-func (c *Module) IsVndkPrivate() bool {
- // Check if VNDK-core-private or VNDK-SP-private
- if c.IsVndk() {
- return Bool(c.vndkdep.Properties.Vndk.Private)
- }
-
- // Check if LLNDK-private
- if library, ok := c.library.(*libraryDecorator); ok && c.IsLlndk() {
- return Bool(library.Properties.Llndk.Private)
- }
-
- return false
-}
-
-// IsVndk() returns true if this module has a vndk variant.
-// Note that IsVndk() returns true for all variants of vndk-enabled libraries. Not only vendor variant,
-// but also platform and product variants of vndk-enabled libraries return true for IsVndk().
-func (c *Module) IsVndk() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndk()
- }
- return false
-}
-
func (c *Module) isAfdoCompile(ctx ModuleContext) bool {
if afdo := c.afdo; afdo != nil {
return afdo.isAfdoCompile(ctx)
@@ -1456,31 +1406,10 @@ func (c *Module) isNDKStubLibrary() bool {
return false
}
-func (c *Module) IsVndkSp() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndkSp()
- }
- return false
-}
-
-func (c *Module) IsVndkExt() bool {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.isVndkExt()
- }
- return false
-}
-
func (c *Module) SubName() string {
return c.Properties.SubName
}
-func (c *Module) getVndkExtendsModuleName() string {
- if vndkdep := c.vndkdep; vndkdep != nil {
- return vndkdep.getVndkExtendsModuleName()
- }
- return ""
-}
-
func (c *Module) IsStubs() bool {
if lib := c.library; lib != nil {
return lib.buildStubs()
@@ -1638,14 +1567,6 @@ func (ctx *moduleContextImpl) useSdk() bool {
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
- config := ctx.ctx.Config()
- if !config.IsVndkDeprecated() && ctx.useVndk() {
- vndkVer := ctx.mod.VndkVersion()
- if inList(vndkVer, config.PlatformVersionActiveCodenames()) {
- return "current"
- }
- return vndkVer
- }
return String(ctx.mod.Properties.Sdk_version)
}
return ""
@@ -1662,7 +1583,7 @@ func (ctx *moduleContextImpl) minSdkVersion() string {
if ctx.ctx.Device() {
config := ctx.ctx.Config()
- if config.IsVndkDeprecated() && ctx.inVendor() {
+ if ctx.inVendor() {
// If building for vendor with final API, then use the latest _stable_ API as "current".
if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
ver = config.PlatformSdkVersion().String()
@@ -1722,22 +1643,10 @@ func (ctx *moduleContextImpl) IsLlndk() bool {
return ctx.mod.IsLlndk()
}
-func (ctx *moduleContextImpl) IsLlndkPublic() bool {
- return ctx.mod.IsLlndkPublic()
-}
-
func (ctx *moduleContextImpl) isImplementationForLLNDKPublic() bool {
return ctx.mod.isImplementationForLLNDKPublic()
}
-func (ctx *moduleContextImpl) IsVndkPrivate() bool {
- return ctx.mod.IsVndkPrivate()
-}
-
-func (ctx *moduleContextImpl) isVndk() bool {
- return ctx.mod.IsVndk()
-}
-
func (ctx *moduleContextImpl) isAfdoCompile(mctx ModuleContext) bool {
return ctx.mod.isAfdoCompile(mctx)
}
@@ -1758,14 +1667,6 @@ func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
return ctx.mod.isNDKStubLibrary()
}
-func (ctx *moduleContextImpl) isVndkSp() bool {
- return ctx.mod.IsVndkSp()
-}
-
-func (ctx *moduleContextImpl) IsVndkExt() bool {
- return ctx.mod.IsVndkExt()
-}
-
func (ctx *moduleContextImpl) IsVendorPublicLibrary() bool {
return ctx.mod.IsVendorPublicLibrary()
}
@@ -1785,10 +1686,6 @@ func (ctx *moduleContextImpl) baseModuleName() string {
return ctx.mod.BaseModuleName()
}
-func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
- return ctx.mod.getVndkExtendsModuleName()
-}
-
func (ctx *moduleContextImpl) isForPlatform() bool {
apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
return apexInfo.IsForPlatform()
@@ -1853,7 +1750,6 @@ func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Mo
module.coverage = &coverage{}
module.fuzzer = &fuzzer{}
module.sabi = &sabi{}
- module.vndkdep = &vndkdep{}
module.lto = &lto{}
module.afdo = &afdo{}
module.orderfile = &orderfile{}
@@ -2229,10 +2125,60 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
moduleInfoJSON.Uninstallable = true
}
+ }
+ buildComplianceMetadataInfo(ctx, c, deps)
+
+ c.setOutputFiles(ctx)
+}
+
+func (c *Module) setOutputFiles(ctx ModuleContext) {
+ if c.outputFile.Valid() {
+ ctx.SetOutputFiles(android.Paths{c.outputFile.Path()}, "")
+ } else {
+ ctx.SetOutputFiles(android.Paths{}, "")
+ }
+ if c.linker != nil {
+ ctx.SetOutputFiles(android.PathsIfNonNil(c.linker.unstrippedOutputFilePath()), "unstripped")
+ ctx.SetOutputFiles(android.PathsIfNonNil(c.linker.strippedAllOutputFilePath()), "stripped_all")
}
}
+func buildComplianceMetadataInfo(ctx ModuleContext, c *Module, deps PathDeps) {
+ // Dump metadata that can not be done in android/compliance-metadata.go
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ complianceMetadataInfo.SetStringValue(android.ComplianceMetadataProp.IS_STATIC_LIB, strconv.FormatBool(ctx.static()))
+ complianceMetadataInfo.SetStringValue(android.ComplianceMetadataProp.BUILT_FILES, c.outputFile.String())
+
+ // Static deps
+ staticDeps := ctx.GetDirectDepsWithTag(StaticDepTag(false))
+ staticDepNames := make([]string, 0, len(staticDeps))
+ for _, dep := range staticDeps {
+ staticDepNames = append(staticDepNames, dep.Name())
+ }
+
+ staticDepPaths := make([]string, 0, len(deps.StaticLibs))
+ for _, dep := range deps.StaticLibs {
+ staticDepPaths = append(staticDepPaths, dep.String())
+ }
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEPS, android.FirstUniqueStrings(staticDepNames))
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEP_FILES, android.FirstUniqueStrings(staticDepPaths))
+
+ // Whole static deps
+ wholeStaticDeps := ctx.GetDirectDepsWithTag(StaticDepTag(true))
+ wholeStaticDepNames := make([]string, 0, len(wholeStaticDeps))
+ for _, dep := range wholeStaticDeps {
+ wholeStaticDepNames = append(wholeStaticDepNames, dep.Name())
+ }
+
+ wholeStaticDepPaths := make([]string, 0, len(deps.WholeStaticLibs))
+ for _, dep := range deps.WholeStaticLibs {
+ wholeStaticDepPaths = append(wholeStaticDepPaths, dep.String())
+ }
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.WHOLE_STATIC_DEPS, android.FirstUniqueStrings(wholeStaticDepNames))
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.WHOLE_STATIC_DEP_FILES, android.FirstUniqueStrings(wholeStaticDepPaths))
+}
+
func (c *Module) maybeUnhideFromMake() {
// If a lib is directly included in any of the APEXes or is not available to the
// platform (which is often the case when the stub is provided as a prebuilt),
@@ -2340,7 +2286,6 @@ func (c *Module) deps(ctx DepsContext) Deps {
deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
- deps.Rlibs = android.LastUniqueStrings(deps.Rlibs)
deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
@@ -2621,7 +2566,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if c.ImageVariation().Variation == android.CoreVariation && c.Device() &&
c.Target().NativeBridge == android.NativeBridgeDisabled {
actx.AddVariationDependencies(
- []blueprint.Variation{{Mutator: "image", Variation: VendorVariation}},
+ []blueprint.Variation{{Mutator: "image", Variation: android.VendorVariation}},
llndkHeaderLibTag,
deps.LlndkHeaderLibs...)
}
@@ -2635,28 +2580,20 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
for _, lib := range deps.StaticLibs {
+ // Some dependencies listed in static_libs might actually be rust_ffi rlib variants.
depTag := libraryDependencyTag{Kind: staticLibraryDependency}
+
if inList(lib, deps.ReexportStaticLibHeaders) {
depTag.reexportFlags = true
}
if inList(lib, deps.ExcludeLibsForApex) {
depTag.excludeInApex = true
}
-
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, lib)
}
- for _, lib := range deps.Rlibs {
- depTag := libraryDependencyTag{Kind: rlibLibraryDependency}
- actx.AddVariationDependencies([]blueprint.Variation{
- {Mutator: "link", Variation: ""},
- {Mutator: "rust_libraries", Variation: "rlib"},
- {Mutator: "rust_stdlinkage", Variation: "rlib-std"},
- }, depTag, lib)
- }
-
// staticUnwinderDep is treated as staticDep for Q apexes
// so that native libraries/binaries are linked with static unwinder
// because Q libc doesn't have unwinder APIs
@@ -2785,15 +2722,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
{Mutator: "link", Variation: "shared"},
}, ndkLateStubDepTag, apiLateNdkLibs...)
- if vndkdep := c.vndkdep; vndkdep != nil {
- if vndkdep.isVndkExt() {
- actx.AddVariationDependencies([]blueprint.Variation{
- c.ImageVariation(),
- {Mutator: "link", Variation: "shared"},
- }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
- }
- }
-
if len(deps.AidlLibs) > 0 {
actx.AddDependency(
c,
@@ -2831,20 +2759,6 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
return
}
- // VNDK is cc.Module supported only for now.
- if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
- // Though allowed dependency is limited by the image mutator,
- // each vendor and product module needs to check link-type
- // for VNDK.
- if ccTo, ok := to.(*Module); ok {
- if ccFrom.vndkdep != nil {
- ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
- }
- } else if _, ok := to.(LinkableInterface); !ok {
- ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
- }
- return
- }
// TODO(b/244244438) : Remove this once all variants are implemented
if ccFrom, ok := from.(*Module); ok && ccFrom.isImportedApiLibrary() {
return
@@ -2999,7 +2913,7 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
return true
}
- if to.IsVndkSp() || to.IsLlndk() {
+ if to.IsLlndk() {
return false
}
@@ -3267,78 +3181,86 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
}
- case libDepTag.rlib():
- rlibDep := RustRlibDep{LibPath: linkFile.Path(), CrateName: ccDep.CrateName(), LinkDirs: ccDep.ExportedCrateLinkDirs()}
- depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, rlibDep)
- depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, rlibDep)
- depPaths.IncludeDirs = append(depPaths.IncludeDirs, depExporterInfo.IncludeDirs...)
- depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, depExporterInfo.IncludeDirs...)
-
case libDepTag.static():
- staticLibraryInfo, isStaticLib := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
- if !isStaticLib {
- if !ctx.Config().AllowMissingDependencies() {
- ctx.ModuleErrorf("module %q is not a static library", depName)
- } else {
- ctx.AddMissingDependencies([]string{depName})
+ if ccDep.RustLibraryInterface() {
+ rlibDep := RustRlibDep{LibPath: linkFile.Path(), CrateName: ccDep.CrateName(), LinkDirs: ccDep.ExportedCrateLinkDirs()}
+ depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, rlibDep)
+ depPaths.IncludeDirs = append(depPaths.IncludeDirs, depExporterInfo.IncludeDirs...)
+ if libDepTag.wholeStatic {
+ depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, depExporterInfo.IncludeDirs...)
+ depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, rlibDep)
+
+ // If whole_static, track this as we want to make sure that in a final linkage for a shared library,
+ // exported functions from the rust generated staticlib still exported.
+ if c.CcLibrary() && c.Shared() {
+ c.WholeRustStaticlib = true
+ }
}
- return
- }
- // Stubs lib doesn't link to the static lib dependencies. Don't set
- // linkFile, depFile, and ptr.
- if c.IsStubs() {
- break
- }
+ } else {
+ staticLibraryInfo, isStaticLib := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
+ if !isStaticLib {
+ if !ctx.Config().AllowMissingDependencies() {
+ ctx.ModuleErrorf("module %q is not a static library", depName)
+ } else {
+ ctx.AddMissingDependencies([]string{depName})
+ }
+ return
+ }
- linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
- if libDepTag.wholeStatic {
- ptr = &depPaths.WholeStaticLibs
- if len(staticLibraryInfo.Objects.objFiles) > 0 {
- depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLibraryInfo.Objects)
- } else {
- // This case normally catches prebuilt static
- // libraries, but it can also occur when
- // AllowMissingDependencies is on and the
- // dependencies has no sources of its own
- // but has a whole_static_libs dependency
- // on a missing library. We want to depend
- // on the .a file so that there is something
- // in the dependency tree that contains the
- // error rule for the missing transitive
- // dependency.
- depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path())
+ // Stubs lib doesn't link to the static lib dependencies. Don't set
+ // linkFile, depFile, and ptr.
+ if c.IsStubs() {
+ break
}
- depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts,
- staticLibraryInfo.WholeStaticLibsFromPrebuilts...)
- } else {
- switch libDepTag.Order {
- case earlyLibraryDependency:
- panic(fmt.Errorf("early static libs not suppported"))
- case normalLibraryDependency:
- // static dependencies will be handled separately so they can be ordered
- // using transitive dependencies.
- ptr = nil
- directStaticDeps = append(directStaticDeps, staticLibraryInfo)
- case lateLibraryDependency:
- ptr = &depPaths.LateStaticLibs
- default:
- panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
+
+ linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
+ if libDepTag.wholeStatic {
+ ptr = &depPaths.WholeStaticLibs
+ if len(staticLibraryInfo.Objects.objFiles) > 0 {
+ depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLibraryInfo.Objects)
+ } else {
+ // This case normally catches prebuilt static
+ // libraries, but it can also occur when
+ // AllowMissingDependencies is on and the
+ // dependencies has no sources of its own
+ // but has a whole_static_libs dependency
+ // on a missing library. We want to depend
+ // on the .a file so that there is something
+ // in the dependency tree that contains the
+ // error rule for the missing transitive
+ // dependency.
+ depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path())
+ }
+ depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts,
+ staticLibraryInfo.WholeStaticLibsFromPrebuilts...)
+ } else {
+ switch libDepTag.Order {
+ case earlyLibraryDependency:
+ panic(fmt.Errorf("early static libs not supported"))
+ case normalLibraryDependency:
+ // static dependencies will be handled separately so they can be ordered
+ // using transitive dependencies.
+ ptr = nil
+ directStaticDeps = append(directStaticDeps, staticLibraryInfo)
+ case lateLibraryDependency:
+ ptr = &depPaths.LateStaticLibs
+ default:
+ panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
+ }
}
- }
- // We re-export the Rust static_rlibs so rlib dependencies don't need to be redeclared by cc_library_static dependents.
- // E.g. libfoo (cc_library_static) depends on libfoo.ffi (a rust_ffi rlib), libbar depending on libfoo shouldn't have to also add libfoo.ffi to static_rlibs.
- depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, depExporterInfo.RustRlibDeps...)
- depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, depExporterInfo.RustRlibDeps...)
+ // Collect any exported Rust rlib deps from static libraries which have been included as whole_static_libs
+ depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, depExporterInfo.RustRlibDeps...)
- if libDepTag.unexportedSymbols {
- depPaths.LdFlags = append(depPaths.LdFlags,
- "-Wl,--exclude-libs="+staticLibraryInfo.StaticLibrary.Base())
+ if libDepTag.unexportedSymbols {
+ depPaths.LdFlags = append(depPaths.LdFlags,
+ "-Wl,--exclude-libs="+staticLibraryInfo.StaticLibrary.Base())
+ }
}
}
- if libDepTag.static() && !libDepTag.wholeStatic {
+ if libDepTag.static() && !libDepTag.wholeStatic && !ccDep.RustLibraryInterface() {
if !ccDep.CcLibraryInterface() || !ccDep.Static() {
ctx.ModuleErrorf("module %q not a static library", depName)
return
@@ -3425,12 +3347,14 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
c.Properties.AndroidMkSharedLibs = append(
c.Properties.AndroidMkSharedLibs, makeLibName)
case libDepTag.static():
- if libDepTag.wholeStatic {
- c.Properties.AndroidMkWholeStaticLibs = append(
- c.Properties.AndroidMkWholeStaticLibs, makeLibName)
- } else {
- c.Properties.AndroidMkStaticLibs = append(
- c.Properties.AndroidMkStaticLibs, makeLibName)
+ if !ccDep.RustLibraryInterface() {
+ if libDepTag.wholeStatic {
+ c.Properties.AndroidMkWholeStaticLibs = append(
+ c.Properties.AndroidMkWholeStaticLibs, makeLibName)
+ } else {
+ c.Properties.AndroidMkStaticLibs = append(
+ c.Properties.AndroidMkStaticLibs, makeLibName)
+ }
}
}
} else if !c.IsStubs() {
@@ -3711,28 +3635,6 @@ func (c *Module) IntermPathForModuleOut() android.OptionalPath {
return c.outputFile
}
-func (c *Module) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
- case "":
- if c.outputFile.Valid() {
- return android.Paths{c.outputFile.Path()}, nil
- }
- return android.Paths{}, nil
- case "unstripped":
- if c.linker != nil {
- return android.PathsIfNonNil(c.linker.unstrippedOutputFilePath()), nil
- }
- return nil, nil
- case "stripped_all":
- if c.linker != nil {
- return android.PathsIfNonNil(c.linker.strippedAllOutputFilePath()), nil
- }
- return nil, nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (c *Module) static() bool {
if static, ok := c.linker.(interface {
static() bool
@@ -3833,15 +3735,6 @@ func (m *Module) Rlib() bool {
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
if c.InVendorOrProduct() {
if c.IsLlndk() {
- if !c.IsLlndkPublic() {
- return "native:vndk_private"
- }
- return "native:vndk"
- }
- if c.IsVndk() && !c.IsVndkExt() {
- if c.IsVndkPrivate() {
- return "native:vndk_private"
- }
return "native:vndk"
}
if c.InProduct() {
@@ -4043,15 +3936,6 @@ func (c *Module) AlwaysRequiresPlatformApexVariant() bool {
return c.IsStubs() || c.Target().NativeBridge == android.NativeBridgeEnabled
}
-// Overrides android.ApexModuleBase.UniqueApexVariations
-func (c *Module) UniqueApexVariations() bool {
- // When a vendor APEX needs a VNDK lib in it (use_vndk_as_stable: false), it should be a unique
- // APEX variation. Otherwise, another vendor APEX with use_vndk_as_stable:true may use a wrong
- // variation of the VNDK lib because APEX variations are merged/grouped.
- // TODO(b/274401041) Find a way to merge APEX variations for vendor apexes.
- return c.UseVndk() && c.IsVndk()
-}
-
func (c *Module) overriddenModules() []string {
if o, ok := c.linker.(overridable); ok {
return o.overriddenModules()
@@ -4159,7 +4043,6 @@ func DefaultsFactory(props ...interface{}) android.Module {
&TidyProperties{},
&CoverageProperties{},
&SAbiProperties{},
- &VndkProperties{},
&LTOProperties{},
&AfdoProperties{},
&OrderfileProperties{},