summaryrefslogtreecommitdiff
path: root/cc/cc.go
diff options
context:
space:
mode:
Diffstat (limited to 'cc/cc.go')
-rw-r--r--cc/cc.go1309
1 files changed, 640 insertions, 669 deletions
diff --git a/cc/cc.go b/cc/cc.go
index 0addb60b4..d307be615 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -24,21 +24,23 @@ import (
"strconv"
"strings"
+ "android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
+ "android/soong/aidl_library"
"android/soong/android"
- "android/soong/bazel/cquery"
"android/soong/cc/config"
"android/soong/fuzz"
"android/soong/genrule"
"android/soong/multitree"
- "android/soong/snapshot"
)
func init() {
RegisterCCBuildComponents(android.InitRegistrationContext)
+ pctx.Import("android/soong/android")
pctx.Import("android/soong/cc/config")
}
@@ -47,12 +49,10 @@ 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()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
- ctx.BottomUp("fdo_profile", fdoProfileMutator)
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -65,13 +65,13 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.TopDown("fuzz_deps", fuzzMutatorDeps)
- ctx.BottomUp("coverage", coverageMutator).Parallel()
+ ctx.Transition("coverage", &coverageTransitionMutator{})
+
+ ctx.Transition("afdo", &afdoTransitionMutator{})
- ctx.TopDown("afdo_deps", afdoDepsMutator)
- ctx.BottomUp("afdo", afdoMutator).Parallel()
+ ctx.Transition("orderfile", &orderfileTransitionMutator{})
- ctx.TopDown("lto_deps", ltoDepsMutator)
- ctx.BottomUp("lto", ltoMutator).Parallel()
+ ctx.Transition("lto", &ltoTransitionMutator{})
ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel()
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
@@ -82,7 +82,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.TopDown("sabi_deps", sabiDepsMutator)
})
- ctx.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
+ ctx.RegisterParallelSingletonType("kythe_extract_all", kytheExtractAllFactory)
}
// Deps is a struct containing module names of dependencies, separated by the kind of dependency.
@@ -110,6 +110,9 @@ type Deps struct {
// Used by DepsMutator to pass system_shared_libs information to check_elf_file.py.
SystemSharedLibs []string
+ // Used by DepMutator to pass aidl_library modules to aidl compiler
+ AidlLibs []string
+
// If true, statically link the unwinder into native libraries/binaries.
StaticUnwinderIfLegacy bool
@@ -130,6 +133,25 @@ type Deps struct {
// List of libs that need to be excluded for APEX variant
ExcludeLibsForApex []string
+ // List of libs that need to be excluded for non-APEX variant
+ ExcludeLibsForNonApex []string
+
+ // LLNDK headers for the ABI checker to check LLNDK implementation library.
+ // An LLNDK implementation is the core variant. LLNDK header libs are reexported by the vendor variant.
+ // The core variant cannot depend on the vendor variant because of the order of CreateVariations.
+ // Instead, the LLNDK implementation depends on the LLNDK header libs.
+ LlndkHeaderLibs []string
+}
+
+// A struct which to collect flags for rlib dependencies
+type RustRlibDep struct {
+ LibPath android.Path // path to the rlib
+ LinkDirs []string // flags required for dependency (e.g. -L flags)
+ CrateName string // crateNames associated with rlibDeps
+}
+
+func EqRustRlibDeps(a RustRlibDep, b RustRlibDep) bool {
+ return a.LibPath == b.LibPath
}
// PathDeps is a struct containing file paths to dependencies of a module.
@@ -144,9 +166,11 @@ type PathDeps struct {
SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths
// Paths to .a files
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
+ // Paths and crateNames for RustStaticLib dependencies
+ RustRlibDeps []RustRlibDep
// Transitive static library dependencies of static libraries for use in ordering.
- TranstiveStaticLibrariesForOrdering *android.DepSet
+ TranstiveStaticLibrariesForOrdering *android.DepSet[android.Path]
// Paths to .o files
Objs Objects
@@ -172,6 +196,7 @@ type PathDeps struct {
ReexportedFlags []string
ReexportedGeneratedHeaders android.Paths
ReexportedDeps android.Paths
+ ReexportedRustRlibDeps []RustRlibDep
// Paths to crt*.o files
CrtBegin, CrtEnd android.Paths
@@ -182,6 +207,13 @@ type PathDeps struct {
// For Darwin builds, the path to the second architecture's output that should
// be combined with this architectures's output into a FAT MachO file.
DarwinSecondArchOutput android.OptionalPath
+
+ // Paths to direct srcs and transitive include dirs from direct aidl_library deps
+ AidlLibraryInfos []aidl_library.AidlLibraryInfo
+
+ // LLNDK headers for the ABI checker to check LLNDK implementation library.
+ LlndkIncludeDirs android.Paths
+ LlndkSystemIncludeDirs android.Paths
}
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
@@ -205,7 +237,8 @@ type Flags struct {
// Local flags (which individual modules are responsible for). These may override global flags.
Local LocalOrGlobalFlags
// Global flags (which build system or toolchain is responsible for).
- Global LocalOrGlobalFlags
+ Global LocalOrGlobalFlags
+ NoOverrideFlags []string // Flags applied to the end of list of flags so they are not overridden
aidlFlags []string // Flags that apply to aidl source files
rsFlags []string // Flags that apply to renderscript source files
@@ -224,6 +257,7 @@ type Flags struct {
GcovCoverage bool // True if coverage files should be generated.
SAbiDump bool // True if header abi dumps should be generated.
EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
+ ClangVerify bool // If true, append cflags "-Xclang -verify" and append "&& touch $out" to the clang command line.
// The instruction set required for clang ("arm" or "thumb").
RequiredInstructionSet string
@@ -249,6 +283,11 @@ type BaseProperties struct {
// Deprecated. true is the default, false is invalid.
Clang *bool `android:"arch_variant"`
+ // Aggresively trade performance for smaller binary size.
+ // This should only be used for on-device binaries that are rarely executed and not
+ // performance critical.
+ Optimize_for_size *bool `android:"arch_variant"`
+
// The API level that this module is built against. The APIs of this API level will be
// visible at build time, but use of any APIs newer than min_sdk_version will render the
// module unloadable on older devices. In the future it will be possible to weakly-link new
@@ -277,6 +316,7 @@ type BaseProperties struct {
AndroidMkSharedLibs []string `blueprint:"mutated"`
AndroidMkStaticLibs []string `blueprint:"mutated"`
+ AndroidMkRlibs []string `blueprint:"mutated"`
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
AndroidMkHeaderLibs []string `blueprint:"mutated"`
@@ -287,8 +327,8 @@ type BaseProperties struct {
// Set by DepsMutator.
AndroidMkSystemSharedLibs []string `blueprint:"mutated"`
- // The name of the image this module is built for, suffixed with a '.'
- ImageVariationPrefix string `blueprint:"mutated"`
+ // The name of the image this module is built for
+ ImageVariation string `blueprint:"mutated"`
// The VNDK version this module is built against. If empty, the module is not
// build against the VNDK.
@@ -299,7 +339,7 @@ type BaseProperties struct {
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
// file
- Logtags []string
+ Logtags []string `android:"path"`
// Make this module available when building for ramdisk.
// On device without a dedicated recovery partition, the module is only
@@ -319,6 +359,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"`
@@ -332,14 +374,9 @@ type BaseProperties struct {
// for building binaries that are started before APEXes are activated.
Bootstrap *bool
- // Even if DeviceConfig().VndkUseCoreVariant() is set, this module must use vendor variant.
- // see soong/cc/config/vndk.go
- MustUseVendorVariant bool `blueprint:"mutated"`
-
- // Used by vendor snapshot to record dependencies from snapshot modules.
- SnapshotSharedLibs []string `blueprint:"mutated"`
- SnapshotStaticLibs []string `blueprint:"mutated"`
- SnapshotRuntimeLibs []string `blueprint:"mutated"`
+ // Allows this module to be included in CMake release snapshots to be built outside of Android
+ // build system and source tree.
+ Cmake_snapshot_supported *bool
Installable *bool `android:"arch_variant"`
@@ -353,20 +390,6 @@ type BaseProperties struct {
// variant to have a ".sdk" suffix.
SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"`
- // 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 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
// can depend on libraries that are not exported by the APEXes and use private symbols
// from the exported libraries.
@@ -456,23 +479,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"`
- // IsVNDKUsingCoreVariant is true for VNDK modules if the global VndkUseCoreVariant option is
- // set and the module is not listed in VndkMustUseVendorVariantList.
- IsVNDKUsingCoreVariant 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"`
@@ -499,36 +505,33 @@ 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
inRamdisk() bool
inVendorRamdisk() bool
inRecovery() bool
+ InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
- getVndkExtendsModuleName() string
- isAfdoCompile() bool
- isPgoCompile() bool
+ isAfdoCompile(ctx ModuleContext) bool
+ isOrderfileCompile() bool
isCfi() bool
+ isFuzzer() bool
isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
isForPlatform() bool
apexVariationName() string
apexSdkVersion() android.ApiLevel
bootstrap() bool
- mustUseVendorVariant() bool
nativeCoverage() bool
directlyInAnyApex() bool
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
+ notInPlatform() bool
+ optimizeForSize() bool
}
type SharedFlags struct {
@@ -558,6 +561,24 @@ type feature interface {
props() []interface{}
}
+// Information returned from Generator about the source code it's generating
+type GeneratedSource struct {
+ IncludeDirs android.Paths
+ Sources android.Paths
+ Headers android.Paths
+ ReexportedDirs android.Paths
+}
+
+// generator allows injection of generated code
+type Generator interface {
+ GeneratorProps() []interface{}
+ GeneratorInit(ctx BaseModuleContext)
+ GeneratorDeps(ctx DepsContext, deps Deps) Deps
+ GeneratorFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
+ GeneratorSources(ctx ModuleContext) GeneratedSource
+ GeneratorBuildActions(ctx ModuleContext, flags Flags, deps PathDeps)
+}
+
// compiler is the interface for a compiler helper object. Different module decorators may implement
// this helper differently.
type compiler interface {
@@ -565,6 +586,7 @@ type compiler interface {
compilerDeps(ctx DepsContext, deps Deps) Deps
compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
compilerProps() []interface{}
+ baseCompilerProps() BaseCompilerProperties
appendCflags([]string)
appendAsflags([]string)
@@ -579,17 +601,21 @@ type linker interface {
linkerDeps(ctx DepsContext, deps Deps) Deps
linkerFlags(ctx ModuleContext, flags Flags) Flags
linkerProps() []interface{}
+ baseLinkerProps() BaseLinkerProperties
useClangLld(actx ModuleContext) bool
link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
appendLdflags([]string)
unstrippedOutputFilePath() android.Path
+ strippedAllOutputFilePath() android.Path
nativeCoverage() bool
coverageOutputFilePath() android.OptionalPath
// Get the deps that have been explicitly specified in the properties.
linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps
+
+ moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
}
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
@@ -628,6 +654,7 @@ const (
headerLibraryDependency = iota
sharedLibraryDependency
staticLibraryDependency
+ rlibLibraryDependency
)
func (k libraryDependencyKind) String() string {
@@ -638,6 +665,8 @@ func (k libraryDependencyKind) String() string {
return "sharedLibraryDependency"
case staticLibraryDependency:
return "staticLibraryDependency"
+ case rlibLibraryDependency:
+ return "rlibLibraryDependency"
default:
panic(fmt.Errorf("unknown libraryDependencyKind %d", k))
}
@@ -693,6 +722,8 @@ type libraryDependencyTag struct {
// Whether or not this dependency has to be followed for the apex variants
excludeInApex bool
+ // Whether or not this dependency has to be followed for the non-apex variants
+ excludeInNonApex bool
// If true, don't automatically export symbols from the static library into a shared library.
unexportedSymbols bool
@@ -730,6 +761,12 @@ func (d libraryDependencyTag) InstallDepNeeded() bool {
var _ android.InstallNeededDependencyTag = libraryDependencyTag{}
+func (d libraryDependencyTag) PropagateAconfigValidation() bool {
+ return d.static()
+}
+
+var _ android.PropagateAconfigValidationDependencyTag = libraryDependencyTag{}
+
// dependencyTag is used for tagging miscellaneous dependency types that don't fit into
// libraryDependencyTag. Each tag object is created globally and reused for multiple
// dependencies (although since the object contains no references, assigning a tag to a
@@ -761,10 +798,11 @@ var (
dataLibDepTag = dependencyTag{name: "data lib"}
dataBinDepTag = dependencyTag{name: "data bin"}
runtimeDepTag = installDependencyTag{name: "runtime lib"}
- testPerSrcDepTag = dependencyTag{name: "test_per_src"}
stubImplDepTag = dependencyTag{name: "stub_impl"}
JniFuzzLibTag = dependencyTag{name: "jni_fuzz_lib_tag"}
FdoProfileTag = dependencyTag{name: "fdo_profile"}
+ aidlLibraryTag = dependencyTag{name: "aidl_library"}
+ llndkHeaderLibTag = dependencyTag{name: "llndk_header_lib"}
)
func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
@@ -786,24 +824,6 @@ func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
return depTag == runtimeDepTag
}
-func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
- ccDepTag, ok := depTag.(dependencyTag)
- return ok && ccDepTag == testPerSrcDepTag
-}
-
-// bazelHandler is the interface for a helper object related to deferring to Bazel for
-// processing a cc module (during Bazel mixed builds). Individual module types should define
-// their own bazel handler if they support being handled by Bazel.
-type BazelHandler interface {
- // QueueBazelCall invokes request-queueing functions on the BazelContext
- //so that these requests are handled when Bazel's cquery is invoked.
- QueueBazelCall(ctx android.BaseModuleContext, label string)
-
- // ProcessBazelQueryResponse uses information retrieved from Bazel to set properties
- // on the current module with given label.
- ProcessBazelQueryResponse(ctx android.ModuleContext, label string)
-}
-
// Module contains the properties and members used by all C/C++ module types, and implements
// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
// to construct the output file. Behavior can be customized with a Customizer, or "decorator",
@@ -821,15 +841,14 @@ type BazelHandler interface {
type Module struct {
fuzz.FuzzModule
- android.BazelModuleBase
-
VendorProperties VendorProperties
Properties BaseProperties
+ sourceProperties android.SourceProperties
// initialize before calling Init
- hod android.HostOrDeviceSupported
- multilib android.Multilib
- bazelable bool
+ hod android.HostOrDeviceSupported
+ multilib android.Multilib
+ testModule bool
// Allowable SdkMemberTypes of this module type.
sdkMemberTypes []android.SdkMemberType
@@ -839,21 +858,20 @@ type Module struct {
// type-specific logic. These members may reference different objects or the same object.
// Functions of these decorators will be invoked to initialize and register type-specific
// build statements.
- compiler compiler
- linker linker
- installer installer
- bazelHandler BazelHandler
-
- features []feature
- stl *stl
- sanitize *sanitize
- coverage *coverage
- fuzzer *fuzzer
- sabi *sabi
- vndkdep *vndkdep
- lto *lto
- afdo *afdo
- pgo *pgo
+ generators []Generator
+ compiler compiler
+ linker linker
+ installer installer
+
+ features []feature
+ stl *stl
+ sanitize *sanitize
+ coverage *coverage
+ fuzzer *fuzzer
+ sabi *sabi
+ lto *lto
+ afdo *afdo
+ orderfile *orderfile
library libraryInterface
@@ -884,6 +902,10 @@ type Module struct {
apexSdkVersion android.ApiLevel
hideApexVariantFromMake bool
+
+ logtagsPaths android.Paths
+
+ WholeRustStaticlib bool
}
func (c *Module) AddJSONData(d *map[string]interface{}) {
@@ -922,14 +944,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(),
- "IsSnapshotLibrary": c.IsSnapshotLibrary(),
- "IsSnapshotPrebuilt": c.IsSnapshotPrebuilt(),
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
"ApexSdkVersion": c.apexSdkVersion,
"TestFor": c.TestFor(),
@@ -941,6 +956,7 @@ func (c *Module) AddJSONData(d *map[string]interface{}) {
"WinMsgSrcs": hasWinMsg,
"YaccSrsc": hasYacc,
"OnlyCSrcs": !(hasAidl || hasLex || hasProto || hasRenderscript || hasSysprop || hasWinMsg || hasYacc),
+ "OptimizeForSize": c.OptimizeForSize(),
}
}
@@ -956,8 +972,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)
@@ -1026,6 +1042,10 @@ func (c *Module) StubDecorator() bool {
return false
}
+func (c *Module) OptimizeForSize() bool {
+ return Bool(c.Properties.Optimize_for_size)
+}
+
func (c *Module) SdkVersion() string {
return String(c.Properties.Sdk_version)
}
@@ -1068,6 +1088,32 @@ func (c *Module) CcLibraryInterface() bool {
return false
}
+func (c *Module) IsNdkPrebuiltStl() bool {
+ if c.linker == nil {
+ return false
+ }
+ if _, ok := c.linker.(*ndkPrebuiltStlLinker); ok {
+ return true
+ }
+ return false
+}
+
+func (c *Module) RlibStd() bool {
+ panic(fmt.Errorf("RlibStd called on non-Rust module: %q", c.BaseModuleName()))
+}
+
+func (c *Module) RustLibraryInterface() bool {
+ return false
+}
+
+func (c *Module) CrateName() string {
+ panic(fmt.Errorf("CrateName called on non-Rust module: %q", c.BaseModuleName()))
+}
+
+func (c *Module) ExportedCrateLinkDirs() []string {
+ panic(fmt.Errorf("ExportedCrateLinkDirs called on non-Rust module: %q", c.BaseModuleName()))
+}
+
func (c *Module) IsFuzzModule() bool {
if _, ok := c.compiler.(*fuzzBinary); ok {
return true
@@ -1086,7 +1132,7 @@ func (c *Module) FuzzPackagedModule() fuzz.FuzzPackagedModule {
panic(fmt.Errorf("FuzzPackagedModule called on non-fuzz module: %q", c.BaseModuleName()))
}
-func (c *Module) FuzzSharedLibraries() android.Paths {
+func (c *Module) FuzzSharedLibraries() android.RuleBuilderInstalls {
if fuzzer, ok := c.compiler.(*fuzzBinary); ok {
return fuzzer.sharedLibraries
}
@@ -1135,6 +1181,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
}
@@ -1181,6 +1237,9 @@ func (c *Module) VndkVersion() string {
func (c *Module) Init() android.Module {
c.AddProperties(&c.Properties, &c.VendorProperties)
+ for _, generator := range c.generators {
+ c.AddProperties(generator.GeneratorProps()...)
+ }
if c.compiler != nil {
c.AddProperties(c.compiler.compilerProps()...)
}
@@ -1205,26 +1264,24 @@ 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()...)
}
if c.afdo != nil {
c.AddProperties(c.afdo.props()...)
}
- if c.pgo != nil {
- c.AddProperties(c.pgo.props()...)
+ if c.orderfile != nil {
+ c.AddProperties(c.orderfile.props()...)
}
for _, feature := range c.features {
c.AddProperties(feature.props()...)
}
+ // Allow test-only on libraries that are not cc_test_library
+ if c.library != nil && !c.testLibrary() {
+ c.AddProperties(&c.sourceProperties)
+ }
android.InitAndroidArchModule(c, c.hod, c.multilib)
- if c.bazelable {
- android.InitBazelModule(c)
- }
android.InitApexModule(c)
android.InitDefaultableModule(c)
@@ -1239,7 +1296,7 @@ func (c *Module) UseVndk() bool {
func (c *Module) canUseSdk() bool {
return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled &&
- !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
+ !c.InVendorOrProduct() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
}
func (c *Module) UseSdk() bool {
@@ -1261,10 +1318,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())
@@ -1311,50 +1364,26 @@ 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() bool {
+func (c *Module) isAfdoCompile(ctx ModuleContext) bool {
if afdo := c.afdo; afdo != nil {
- return afdo.Properties.FdoProfilePath != nil
+ return afdo.isAfdoCompile(ctx)
}
return false
}
-func (c *Module) isPgoCompile() bool {
- if pgo := c.pgo; pgo != nil {
- return pgo.Properties.PgoCompile
+func (c *Module) isOrderfileCompile() bool {
+ if orderfile := c.orderfile; orderfile != nil {
+ return orderfile.Properties.OrderfileLoad
}
return false
}
func (c *Module) isCfi() bool {
- if sanitize := c.sanitize; sanitize != nil {
- return Bool(sanitize.Properties.Sanitize.Cfi)
- }
- return false
+ return c.sanitize.isSanitizerEnabled(cfi)
+}
+
+func (c *Module) isFuzzer() bool {
+ return c.sanitize.isSanitizerEnabled(Fuzzer)
}
func (c *Module) isNDKStubLibrary() bool {
@@ -1364,35 +1393,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) MustUseVendorVariant() bool {
- return c.IsVndkSp() || c.Properties.MustUseVendorVariant
-}
-
-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()
@@ -1456,14 +1460,6 @@ func (c *Module) IsSnapshotPrebuilt() bool {
return false
}
-func (c *Module) ExcludeFromVendorSnapshot() bool {
- return Bool(c.Properties.Exclude_from_vendor_snapshot)
-}
-
-func (c *Module) ExcludeFromRecoverySnapshot() bool {
- return Bool(c.Properties.Exclude_from_recovery_snapshot)
-}
-
func isBionic(name string) bool {
switch name {
case "libc", "libm", "libdl", "libdl_android", "linker":
@@ -1473,8 +1469,6 @@ func isBionic(name string) bool {
}
func InstallToBootstrap(name string, config android.Config) bool {
- // NOTE: also update //build/bazel/rules/apex/cc.bzl#_installed_to_bootstrap
- // if this list is updated.
if name == "libclang_rt.hwasan" || name == "libc_hwasan" {
return true
}
@@ -1546,6 +1540,10 @@ func (ctx *moduleContextImpl) object() bool {
return ctx.mod.Object()
}
+func (ctx *moduleContextImpl) optimizeForSize() bool {
+ return ctx.mod.OptimizeForSize()
+}
+
func (ctx *moduleContextImpl) canUseSdk() bool {
return ctx.mod.canUseSdk()
}
@@ -1556,13 +1554,6 @@ func (ctx *moduleContextImpl) useSdk() bool {
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
- if ctx.useVndk() {
- vndkVer := ctx.mod.VndkVersion()
- if inList(vndkVer, ctx.ctx.Config().PlatformVersionActiveCodenames()) {
- return "current"
- }
- return vndkVer
- }
return String(ctx.mod.Properties.Sdk_version)
}
return ""
@@ -1576,6 +1567,17 @@ func (ctx *moduleContextImpl) minSdkVersion() string {
if ver == "apex_inherit" || ver == "" {
ver = ctx.sdkVersion()
}
+
+ if ctx.ctx.Device() {
+ config := ctx.ctx.Config()
+ 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()
+ }
+ }
+ }
+
// For crt objects, the meaning of min_sdk_version is very different from other types of
// module. For them, min_sdk_version defines the oldest version that the build system will
// create versioned variants for. For example, if min_sdk_version is 16, then sdk variant of
@@ -1616,6 +1618,10 @@ func (ctx *moduleContextImpl) useVndk() bool {
return ctx.mod.UseVndk()
}
+func (ctx *moduleContextImpl) InVendorOrProduct() bool {
+ return ctx.mod.InVendorOrProduct()
+}
+
func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
return ctx.mod.IsNdk(config)
}
@@ -1624,54 +1630,34 @@ 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) isAfdoCompile(mctx ModuleContext) bool {
+ return ctx.mod.isAfdoCompile(mctx)
}
-func (ctx *moduleContextImpl) isVndk() bool {
- return ctx.mod.IsVndk()
-}
-
-func (ctx *moduleContextImpl) isAfdoCompile() bool {
- return ctx.mod.isAfdoCompile()
-}
-
-func (ctx *moduleContextImpl) isPgoCompile() bool {
- return ctx.mod.isPgoCompile()
+func (ctx *moduleContextImpl) isOrderfileCompile() bool {
+ return ctx.mod.isOrderfileCompile()
}
func (ctx *moduleContextImpl) isCfi() bool {
return ctx.mod.isCfi()
}
-func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
- return ctx.mod.isNDKStubLibrary()
-}
-
-func (ctx *moduleContextImpl) isVndkSp() bool {
- return ctx.mod.IsVndkSp()
+func (ctx *moduleContextImpl) isFuzzer() bool {
+ return ctx.mod.isFuzzer()
}
-func (ctx *moduleContextImpl) IsVndkExt() bool {
- return ctx.mod.IsVndkExt()
+func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
+ return ctx.mod.isNDKStubLibrary()
}
func (ctx *moduleContextImpl) IsVendorPublicLibrary() bool {
return ctx.mod.IsVendorPublicLibrary()
}
-func (ctx *moduleContextImpl) mustUseVendorVariant() bool {
- return ctx.mod.MustUseVendorVariant()
-}
-
func (ctx *moduleContextImpl) selectedStl() string {
if stl := ctx.mod.stl; stl != nil {
return stl.Properties.SelectedStl
@@ -1684,19 +1670,17 @@ func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool {
}
func (ctx *moduleContextImpl) baseModuleName() string {
- return ctx.mod.ModuleBase.BaseModuleName()
-}
-
-func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
- return ctx.mod.getVndkExtendsModuleName()
+ return ctx.mod.BaseModuleName()
}
func (ctx *moduleContextImpl) isForPlatform() bool {
- return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+ apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
+ return apexInfo.IsForPlatform()
}
func (ctx *moduleContextImpl) apexVariationName() string {
- return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
+ apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
+ return apexInfo.ApexVariationName
}
func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel {
@@ -1732,6 +1716,10 @@ func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool {
return ctx.mod.isCfiAssemblySupportEnabled()
}
+func (ctx *moduleContextImpl) notInPlatform() bool {
+ return ctx.mod.NotInPlatform()
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
@@ -1749,10 +1737,9 @@ 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.pgo = &pgo{}
+ module.orderfile = &orderfile{}
return module
}
@@ -1786,11 +1773,6 @@ func (c *Module) Symlinks() []string {
return nil
}
-func (c *Module) IsTestPerSrcAllTestsVariation() bool {
- test, ok := c.linker.(testPerSrc)
- return ok && test.isAllTestsVariation()
-}
-
func (c *Module) DataPaths() []android.DataPath {
if p, ok := c.installer.(interface {
dataPaths() []android.DataPath
@@ -1803,7 +1785,6 @@ func (c *Module) DataPaths() []android.DataPath {
func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface) string {
// Returns the name suffix for product and vendor variants. If the VNDK version is not
// "current", it will append the VNDK version to the name suffix.
- var vndkVersion string
var nameSuffix string
if c.InProduct() {
if c.ProductSpecific() {
@@ -1811,16 +1792,11 @@ func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface
// do not add a name suffix because it is a base module.
return ""
}
- vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
- nameSuffix = ProductSuffix
+ return ProductSuffix
} else {
- vndkVersion = ctx.DeviceConfig().VndkVersion()
nameSuffix = VendorSuffix
}
- if vndkVersion == "current" {
- vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
- }
- if c.VndkVersion() != vndkVersion && c.VndkVersion() != "" {
+ if c.VndkVersion() != "" {
// add version suffix only if the module is using different vndk version than the
// version in product or vendor partition.
nameSuffix += "." + c.VndkVersion()
@@ -1836,7 +1812,7 @@ func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string
}
llndk := c.IsLlndk()
- if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
+ if llndk || (c.InVendorOrProduct() && c.HasNonSystemVariants()) {
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
@@ -1867,140 +1843,126 @@ func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string
return subName
}
-var _ android.MixedBuildBuildable = (*Module)(nil)
-
-func (c *Module) getBazelModuleLabel(ctx android.BaseModuleContext) string {
- var bazelModuleLabel string
- if c.typ() == fullLibrary && c.static() {
- // cc_library is a special case in bp2build; two targets are generated -- one for each
- // of the shared and static variants. The shared variant keeps the module name, but the
- // static variant uses a different suffixed name.
- bazelModuleLabel = bazelLabelForStaticModule(ctx, c)
- } else {
- bazelModuleLabel = c.GetBazelLabel(ctx, c)
- }
- labelNoPrebuilt := bazelModuleLabel
- if c.IsPrebuilt() {
- labelNoPrebuilt = android.RemoveOptionalPrebuiltPrefixFromBazelLabel(bazelModuleLabel)
+func moduleContextFromAndroidModuleContext(actx android.ModuleContext, c *Module) ModuleContext {
+ ctx := &moduleContext{
+ ModuleContext: actx,
+ moduleContextImpl: moduleContextImpl{
+ mod: c,
+ },
}
- return labelNoPrebuilt
-}
-
-func (c *Module) QueueBazelCall(ctx android.BaseModuleContext) {
- c.bazelHandler.QueueBazelCall(ctx, c.getBazelModuleLabel(ctx))
+ ctx.ctx = ctx
+ return ctx
}
+// TODO (b/277651159): Remove this allowlist
var (
- mixedBuildSupportedCcTest = []string{
- "adbd_test",
- "adb_crypto_test",
- "adb_pairing_auth_test",
- "adb_pairing_connection_test",
- "adb_tls_connection_test",
+ skipStubLibraryMultipleApexViolation = map[string]bool{
+ "libclang_rt.asan": true,
+ "libclang_rt.hwasan": true,
+ // runtime apex
+ "libc": true,
+ "libc_hwasan": true,
+ "libdl_android": true,
+ "libm": true,
+ "libdl": true,
+ "libz": true,
+ // art apex
+ // TODO(b/234351700): Remove this when com.android.art.debug is gone.
+ "libandroidio": true,
+ "libdexfile": true,
+ "libdexfiled": true, // com.android.art.debug only
+ "libnativebridge": true,
+ "libnativehelper": true,
+ "libnativeloader": true,
+ "libsigchain": true,
}
)
-// IsMixedBuildSupported returns true if the module should be analyzed by Bazel
-// in any of the --bazel-mode(s). This filters at the module level and takes
-// precedence over the allowlists in allowlists/allowlists.go.
-func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
- _, isForTesting := ctx.Config().BazelContext.(android.MockBazelContext)
- if c.testBinary() && !android.InList(c.Name(), mixedBuildSupportedCcTest) && !isForTesting {
- // Per-module rollout of mixed-builds for cc_test modules.
+// Returns true if a stub library could be installed in multiple apexes
+func (c *Module) stubLibraryMultipleApexViolation(ctx android.ModuleContext) bool {
+ // If this is not an apex variant, no check necessary
+ if !c.InAnyApex() {
return false
}
-
- // TODO(b/261058727): Remove this (enable mixed builds for modules with UBSan)
- // Currently we can only support ubsan when minimum runtime is used.
- return c.bazelHandler != nil && (!isUbsanEnabled(c) || c.MinimalRuntimeNeeded())
-}
-
-func isUbsanEnabled(c *Module) bool {
- if c.sanitize == nil {
+ // If this is not a stub library, no check necessary
+ if !c.HasStubsVariants() {
return false
}
- sanitizeProps := &c.sanitize.Properties.SanitizeMutated
- return Bool(sanitizeProps.Integer_overflow) || len(sanitizeProps.Misc_undefined) > 0
-}
-
-func GetApexConfigKey(ctx android.BaseModuleContext) *android.ApexConfigKey {
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
- if !apexInfo.IsForPlatform() {
- if !ctx.Config().BazelContext.IsModuleDclaAllowed(ctx.Module().Name()) {
- return nil
- }
- apexKey := android.ApexConfigKey{
- WithinApex: true,
- ApexSdkVersion: findApexSdkVersion(ctx, apexInfo).String(),
- }
- return &apexKey
- }
-
- return nil
-}
-
-func (c *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
- bazelModuleLabel := c.getBazelModuleLabel(ctx)
- c.bazelHandler.ProcessBazelQueryResponse(ctx, bazelModuleLabel)
-
- c.Properties.SubName = GetSubnameProperty(ctx, c)
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
- if !apexInfo.IsForPlatform() {
- c.hideApexVariantFromMake = true
+ // Skip the allowlist
+ // Use BaseModuleName so that this matches prebuilts.
+ if _, exists := skipStubLibraryMultipleApexViolation[c.BaseModuleName()]; exists {
+ return false
}
- c.makeLinkType = GetMakeLinkType(ctx, c)
-
- mctx := &moduleContext{
- ModuleContext: ctx,
- moduleContextImpl: moduleContextImpl{
- mod: c,
- },
+ _, aaWithoutTestApexes, _ := android.ListSetDifference(c.ApexAvailable(), c.TestApexes())
+ // Stub libraries should not have more than one apex_available
+ if len(aaWithoutTestApexes) > 1 {
+ return true
}
- mctx.ctx = mctx
-
- // TODO(b/244432500): Get the tradefed config from the bazel target instead
- // of generating it with Soong.
- c.maybeInstall(mctx, apexInfo)
-}
-
-func moduleContextFromAndroidModuleContext(actx android.ModuleContext, c *Module) ModuleContext {
- ctx := &moduleContext{
- ModuleContext: actx,
- moduleContextImpl: moduleContextImpl{
- mod: c,
- },
+ // Stub libraries should not use the wildcard
+ if aaWithoutTestApexes[0] == android.AvailableToAnyApex {
+ return true
}
- ctx.ctx = ctx
- return ctx
+ // Default: no violation
+ return false
}
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
- // Handle the case of a test module split by `test_per_src` mutator.
- //
- // The `test_per_src` mutator adds an extra variation named "", depending on all the other
- // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this
- // module and return early, as this module does not produce an output file per se.
- if c.IsTestPerSrcAllTestsVariation() {
- c.outputFile = android.OptionalPath{}
- return
+ ctx := moduleContextFromAndroidModuleContext(actx, c)
+
+ c.logtagsPaths = android.PathsForModuleSrc(actx, c.Properties.Logtags)
+ android.SetProvider(ctx, android.LogtagsProviderKey, &android.LogtagsInfo{
+ Logtags: c.logtagsPaths,
+ })
+
+ // If Test_only is set on a module in bp file, respect the setting, otherwise
+ // see if is a known test module type.
+ testOnly := c.testModule || c.testLibrary()
+ if c.sourceProperties.Test_only != nil {
+ testOnly = Bool(c.sourceProperties.Test_only)
}
+ // Keep before any early returns.
+ android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
+ TestOnly: testOnly,
+ TopLevelTarget: c.testModule,
+ })
c.Properties.SubName = GetSubnameProperty(actx, c)
- apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
c.hideApexVariantFromMake = true
}
c.makeLinkType = GetMakeLinkType(actx, c)
- ctx := moduleContextFromAndroidModuleContext(actx, c)
-
deps := c.depsToPaths(ctx)
if ctx.Failed() {
return
}
+ for _, generator := range c.generators {
+ gen := generator.GeneratorSources(ctx)
+ deps.IncludeDirs = append(deps.IncludeDirs, gen.IncludeDirs...)
+ deps.ReexportedDirs = append(deps.ReexportedDirs, gen.ReexportedDirs...)
+ deps.GeneratedDeps = append(deps.GeneratedDeps, gen.Headers...)
+ deps.ReexportedGeneratedHeaders = append(deps.ReexportedGeneratedHeaders, gen.Headers...)
+ deps.ReexportedDeps = append(deps.ReexportedDeps, gen.Headers...)
+ if len(deps.Objs.objFiles) == 0 {
+ // If we are reusuing object files (which happens when we're a shared library and we're
+ // reusing our static variant's object files), then skip adding the actual source files,
+ // because we already have the object for it.
+ deps.GeneratedSources = append(deps.GeneratedSources, gen.Sources...)
+ }
+ }
+
+ if ctx.Failed() {
+ return
+ }
+
+ if c.stubLibraryMultipleApexViolation(actx) {
+ actx.PropertyErrorf("apex_available",
+ "Stub libraries should have a single apex_available (test apexes excluded). Got %v", c.ApexAvailable())
+ }
if c.Properties.Clang != nil && *c.Properties.Clang == false {
ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
} else if c.Properties.Clang != nil && !ctx.DeviceConfig().BuildBrokenClangProperty() {
@@ -2011,6 +1973,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Toolchain: c.toolchain(ctx),
EmitXrefs: ctx.Config().EmitXrefRules(),
}
+ for _, generator := range c.generators {
+ flags = generator.GeneratorFlags(ctx, flags, deps)
+ }
if c.compiler != nil {
flags = c.compiler.compilerFlags(ctx, flags, deps)
}
@@ -2035,8 +2000,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if c.afdo != nil {
flags = c.afdo.flags(ctx, flags)
}
- if c.pgo != nil {
- flags = c.pgo.flags(ctx, flags)
+ if c.orderfile != nil {
+ flags = c.orderfile.flags(ctx, flags)
}
for _, feature := range c.features {
flags = feature.flags(ctx, flags)
@@ -2068,6 +2033,10 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.Local.AsFlags)
+ for _, generator := range c.generators {
+ generator.GeneratorBuildActions(ctx, flags, deps)
+ }
+
var objs Objects
if c.compiler != nil {
objs = c.compiler.compile(ctx, flags, deps)
@@ -2087,17 +2056,101 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
c.outputFile = android.OptionalPathForPath(outputFile)
c.maybeUnhideFromMake()
+ }
+ if c.testModule {
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ }
+
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
- // 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)
+ if Bool(c.Properties.Cmake_snapshot_supported) {
+ android.SetProvider(ctx, cmakeSnapshotSourcesProvider, android.GlobFiles(ctx, ctx.ModuleDir()+"/**/*", nil))
+ }
+
+ c.maybeInstall(ctx, apexInfo)
+
+ if c.linker != nil {
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ c.linker.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.SharedLibs = c.Properties.AndroidMkSharedLibs
+ moduleInfoJSON.StaticLibs = c.Properties.AndroidMkStaticLibs
+ moduleInfoJSON.SystemSharedLibs = c.Properties.AndroidMkSystemSharedLibs
+ moduleInfoJSON.RuntimeDependencies = c.Properties.AndroidMkRuntimeLibs
+
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkSharedLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkStaticLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkHeaderLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkWholeStaticLibs...)
+
+ if c.sanitize != nil && len(moduleInfoJSON.Class) > 0 &&
+ (moduleInfoJSON.Class[0] == "STATIC_LIBRARIES" || moduleInfoJSON.Class[0] == "HEADER_LIBRARIES") {
+ if Bool(c.sanitize.Properties.SanitizeMutated.Cfi) {
+ moduleInfoJSON.SubName += ".cfi"
+ }
+ if Bool(c.sanitize.Properties.SanitizeMutated.Hwaddress) {
+ moduleInfoJSON.SubName += ".hwasan"
}
+ if Bool(c.sanitize.Properties.SanitizeMutated.Scs) {
+ moduleInfoJSON.SubName += ".scs"
+ }
+ }
+ moduleInfoJSON.SubName += c.Properties.SubName
+
+ if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
+ moduleInfoJSON.Uninstallable = true
}
}
- c.maybeInstall(ctx, apexInfo)
+ 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() {
@@ -2109,16 +2162,15 @@ func (c *Module) maybeUnhideFromMake() {
// is explicitly referenced via .bootstrap suffix or the module is marked with
// 'bootstrap: true').
if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() &&
- !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
+ !c.InRecovery() && !c.InVendorOrProduct() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() && !c.InVendorRamdisk() {
c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable
}
}
-// maybeInstall is called at the end of both GenerateAndroidBuildActions and
-// ProcessBazelQueryResponse to run the install hooks for installable modules,
-// like binaries and tests.
+// maybeInstall is called at the end of both GenerateAndroidBuildActions to run the
+// install hooks for installable modules, like binaries and tests.
func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) {
if !proptools.BoolDefault(c.Installable(), true) {
// If the module has been specifically configure to not be installed then
@@ -2141,12 +2193,6 @@ func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) {
}
}
-func (c *Module) setAndroidMkVariablesFromCquery(info cquery.CcAndroidMkInfo) {
- c.Properties.AndroidMkSharedLibs = info.LocalSharedLibs
- c.Properties.AndroidMkStaticLibs = info.LocalStaticLibs
- c.Properties.AndroidMkWholeStaticLibs = info.LocalWholeStaticLibs
-}
-
func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
if c.cachedToolchain == nil {
c.cachedToolchain = config.FindToolchainWithContext(ctx)
@@ -2155,6 +2201,9 @@ func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
}
func (c *Module) begin(ctx BaseModuleContext) {
+ for _, generator := range c.generators {
+ generator.GeneratorInit(ctx)
+ }
if c.compiler != nil {
c.compiler.compilerInit(ctx)
}
@@ -2170,11 +2219,14 @@ func (c *Module) begin(ctx BaseModuleContext) {
if c.coverage != nil {
c.coverage.begin(ctx)
}
+ if c.afdo != nil {
+ c.afdo.begin(ctx)
+ }
if c.lto != nil {
c.lto.begin(ctx)
}
- if c.pgo != nil {
- c.pgo.begin(ctx)
+ if c.orderfile != nil {
+ c.orderfile.begin(ctx)
}
if ctx.useSdk() && c.IsSdkVariant() {
version, err := nativeApiLevelFromUser(ctx, ctx.sdkVersion())
@@ -2190,6 +2242,9 @@ func (c *Module) begin(ctx BaseModuleContext) {
func (c *Module) deps(ctx DepsContext) Deps {
deps := Deps{}
+ for _, generator := range c.generators {
+ deps = generator.GeneratorDeps(ctx, deps)
+ }
if c.compiler != nil {
deps = c.compiler.compilerDeps(ctx, deps)
}
@@ -2210,6 +2265,7 @@ func (c *Module) deps(ctx DepsContext) Deps {
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
+ deps.LlndkHeaderLibs = android.LastUniqueStrings(deps.LlndkHeaderLibs)
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
@@ -2247,10 +2303,6 @@ func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
}
ctx.ctx = ctx
- if !actx.Host() || !ctx.static() || ctx.staticBinary() {
- c.afdo.addDep(ctx, actx)
- }
-
c.begin(ctx)
}
@@ -2326,9 +2378,9 @@ func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) mul
if actx.OtherModuleExists("api_imports") {
apiImportModule = actx.AddDependency(c, nil, "api_imports")
if len(apiImportModule) > 0 && apiImportModule[0] != nil {
- apiInfo := actx.OtherModuleProvider(apiImportModule[0], multitree.ApiImportsProvider).(multitree.ApiImportInfo)
+ apiInfo, _ := android.OtherModuleProvider(actx, apiImportModule[0], multitree.ApiImportsProvider)
apiImportInfo = apiInfo
- actx.SetProvider(multitree.ApiImportsProvider, apiInfo)
+ android.SetProvider(actx, multitree.ApiImportsProvider, apiInfo)
}
}
}
@@ -2336,31 +2388,6 @@ func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) mul
return apiImportInfo
}
-func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext) SnapshotInfo {
- // Only device modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of
- // SnapshotInfo, which provides no mappings.
- if *snapshotInfo == nil && c.Device() {
- // Only retrieve the snapshot on demand in order to avoid circular dependencies
- // between the modules in the snapshot and the snapshot itself.
- var snapshotModule []blueprint.Module
- if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() {
- snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
- } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
- snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
- }
- if len(snapshotModule) > 0 && snapshotModule[0] != nil {
- snapshot := actx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo)
- *snapshotInfo = &snapshot
- // republish the snapshot for use in later mutators on this module
- actx.SetProvider(SnapshotInfoProvider, snapshot)
- }
- }
- if *snapshotInfo == nil {
- *snapshotInfo = &SnapshotInfo{}
- }
- return **snapshotInfo
-}
-
func GetReplaceModuleName(lib string, replaceMap map[string]string) string {
if snapshot, ok := replaceMap[lib]; ok {
return snapshot
@@ -2369,44 +2396,35 @@ func GetReplaceModuleName(lib string, replaceMap map[string]string) string {
return lib
}
-// RewriteLibs takes a list of names of shared libraries and scans it for three types
+// FilterNdkLibs takes a list of names of shared libraries and scans it for two types
// of names:
//
-// 1. Name of an NDK library that refers to a prebuilt module.
-//
-// For each of these, it adds the name of the prebuilt module (which will be in
-// prebuilts/ndk) to the list of nonvariant libs.
-//
-// 2. Name of an NDK library that refers to an ndk_library module.
+// 1. Name of an NDK library that refers to an ndk_library module.
//
// For each of these, it adds the name of the ndk_library module to the list of
// variant libs.
//
-// 3. Anything else (so anything that isn't an NDK library).
+// 2. Anything else (so anything that isn't an NDK library).
//
// It adds these to the nonvariantLibs list.
//
// The caller can then know to add the variantLibs dependencies differently from the
// nonvariantLibs
-func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) {
+func FilterNdkLibs(c LinkableInterface, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) {
variantLibs = []string{}
nonvariantLibs = []string{}
for _, entry := range list {
// strip #version suffix out
name, _ := StubsLibNameAndVersion(entry)
- if c.InRecovery() {
- nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
- } else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
+ if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
- } else if c.UseVndk() {
- nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
} else {
- // put name#version back
nonvariantLibs = append(nonvariantLibs, entry)
}
}
return nonvariantLibs, variantLibs
+
}
func rewriteLibsForApiImports(c LinkableInterface, libs []string, replaceList map[string]string, config android.Config) ([]string, []string) {
@@ -2450,7 +2468,7 @@ func (c *Module) shouldUseApiSurface() bool {
}
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
- if !c.Enabled() {
+ if !c.Enabled(actx) {
return
}
@@ -2478,18 +2496,12 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs
- var snapshotInfo *SnapshotInfo
-
variantNdkLibs := []string{}
variantLateNdkLibs := []string{}
if ctx.Os() == android.Android {
- deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs)
- deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs)
- deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders)
-
- for idx, lib := range deps.RuntimeLibs {
- deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).SharedLibs)
- }
+ deps.SharedLibs, variantNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.SharedLibs)
+ deps.LateSharedLibs, variantLateNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.LateSharedLibs)
+ deps.ReexportSharedLibHeaders, _ = FilterNdkLibs(c, ctx.Config(), deps.ReexportSharedLibHeaders)
}
for _, lib := range deps.HeaderLibs {
@@ -2502,7 +2514,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if c.shouldUseApiSurface() {
lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs)
}
- lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).HeaderLibs)
if c.isNDKStubLibrary() {
// ndk_headers do not have any variations
@@ -2525,27 +2536,33 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
), stubImplementation, c.BaseModuleName())
}
+ // If this module is an LLNDK implementation library, let it depend on LlndkHeaderLibs.
+ if c.ImageVariation().Variation == android.CoreVariation && c.Device() &&
+ c.Target().NativeBridge == android.NativeBridgeDisabled {
+ actx.AddVariationDependencies(
+ []blueprint.Variation{{Mutator: "image", Variation: android.VendorVariation}},
+ llndkHeaderLibTag,
+ deps.LlndkHeaderLibs...)
+ }
+
for _, lib := range deps.WholeStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
- lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
-
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, lib)
}
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
}
-
- lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
-
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, lib)
@@ -2558,7 +2575,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, depTag, GetReplaceModuleName(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+ }, depTag, staticUnwinder(actx))
}
// shared lib names without the #version suffix
@@ -2572,6 +2589,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if inList(lib, deps.ExcludeLibsForApex) {
depTag.excludeInApex = true
}
+ if inList(lib, deps.ExcludeLibsForNonApex) {
+ depTag.excludeInNonApex = true
+ }
name, version := StubsLibNameAndVersion(lib)
if apiLibraryName, ok := apiImportInfo.SharedLibs[name]; ok && !ctx.OtherModuleExists(name) {
@@ -2596,14 +2616,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+ }, depTag, lib)
}
for _, lib := range deps.UnexportedStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+ }, depTag, lib)
}
for _, lib := range deps.LateSharedLibs {
@@ -2644,11 +2664,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
for _, crt := range deps.CrtBegin {
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
- GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
+ crt)
}
for _, crt := range deps.CrtEnd {
actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
- GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
+ crt)
}
if deps.DynamicLinker != "" {
actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
@@ -2676,20 +2696,19 @@ 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, GetReplaceModuleName(vndkdep.getVndkExtendsModuleName(), GetSnapshot(c, &snapshotInfo, actx).SharedLibs))
- }
+ if len(deps.AidlLibs) > 0 {
+ actx.AddDependency(
+ c,
+ aidlLibraryTag,
+ deps.AidlLibs...,
+ )
}
updateImportedLibraryDependency(ctx)
}
func BeginMutator(ctx android.BottomUpMutatorContext) {
- if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
+ if c, ok := ctx.Module().(*Module); ok && c.Enabled(ctx) {
c.beginMutator(ctx)
}
}
@@ -2714,20 +2733,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
@@ -2790,20 +2795,20 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to.Module()), "current")
} else {
- fromApi, err := strconv.Atoi(from.SdkVersion())
+ fromApi, err := android.ApiLevelFromUserWithConfig(ctx.Config(), from.SdkVersion())
if err != nil {
ctx.PropertyErrorf("sdk_version",
- "Invalid sdk_version value (must be int or current): %q",
+ "Invalid sdk_version value (must be int, preview or current): %q",
from.SdkVersion())
}
- toApi, err := strconv.Atoi(to.SdkVersion())
+ toApi, err := android.ApiLevelFromUserWithConfig(ctx.Config(), to.SdkVersion())
if err != nil {
ctx.PropertyErrorf("sdk_version",
- "Invalid sdk_version value (must be int or current): %q",
+ "Invalid sdk_version value (must be int, preview or current): %q",
to.SdkVersion())
}
- if toApi > fromApi {
+ if toApi.GreaterThan(fromApi) {
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to.Module()), to.SdkVersion())
}
@@ -2865,6 +2870,9 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
if depTag == stubImplDepTag {
return false
}
+ if depTag == android.RequiredDepTag {
+ return false
+ }
// Even if target lib has no vendor variant, keep checking dependency
// graph in case it depends on vendor_available or product_available
@@ -2879,7 +2887,7 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
return true
}
- if to.IsVndkSp() || to.IsLlndk() {
+ if to.IsLlndk() {
return false
}
@@ -2929,7 +2937,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.GeneratedHeaders...)
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
c.apexSdkVersion = findApexSdkVersion(ctx, apexInfo)
skipModuleList := map[string]bool{}
@@ -2939,7 +2947,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
ctx.VisitDirectDeps(func(dep android.Module) {
if dep.Name() == "api_imports" {
- apiImportInfo = ctx.OtherModuleProvider(dep, multitree.ApiImportsProvider).(multitree.ApiImportInfo)
+ apiImportInfo, _ = android.OtherModuleProvider(ctx, dep, multitree.ApiImportsProvider)
hasApiImportInfo = true
}
})
@@ -2989,6 +2997,15 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
+ if depTag == aidlLibraryTag {
+ if aidlLibraryInfo, ok := android.OtherModuleProvider(ctx, dep, aidl_library.AidlLibraryProvider); ok {
+ depPaths.AidlLibraryInfos = append(
+ depPaths.AidlLibraryInfos,
+ aidlLibraryInfo,
+ )
+ }
+ }
+
ccDep, ok := dep.(LinkableInterface)
if !ok {
@@ -3033,6 +3050,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
+ if depTag == android.RequiredDepTag {
+ return
+ }
+
if dep.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
return
@@ -3049,15 +3070,21 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// version mutator, so the stubs variant is created from the shared variant that
// already has the reuseObjTag dependency on the static variant.
if !c.library.buildStubs() {
- staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
+ staticAnalogue, _ := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
objs := staticAnalogue.ReuseObjects
depPaths.Objs = depPaths.Objs.Append(objs)
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
reexportExporter(depExporterInfo)
}
return
}
+ if depTag == llndkHeaderLibTag {
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
+ depPaths.LlndkIncludeDirs = append(depPaths.LlndkIncludeDirs, depExporterInfo.IncludeDirs...)
+ depPaths.LlndkSystemIncludeDirs = append(depPaths.LlndkSystemIncludeDirs, depExporterInfo.SystemIncludeDirs...)
+ }
+
linkFile := ccDep.OutputFile()
if libDepTag, ok := depTag.(libraryDependencyTag); ok {
@@ -3069,8 +3096,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if !apexInfo.IsForPlatform() && libDepTag.excludeInApex {
return
}
+ if apexInfo.IsForPlatform() && libDepTag.excludeInNonApex {
+ return
+ }
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
var ptr *android.Paths
var depPtr *android.Paths
@@ -3079,7 +3109,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
switch {
case libDepTag.header():
- if !ctx.OtherModuleHasProvider(dep, HeaderLibraryInfoProvider) {
+ if _, isHeaderLib := android.OtherModuleProvider(ctx, dep, HeaderLibraryInfoProvider); !isHeaderLib {
if !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("module %q is not a header library", depName)
} else {
@@ -3088,7 +3118,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
case libDepTag.shared():
- if !ctx.OtherModuleHasProvider(dep, SharedLibraryInfoProvider) {
+ if _, isSharedLib := android.OtherModuleProvider(ctx, dep, SharedLibraryInfoProvider); !isSharedLib {
if !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("module %q is not a shared library", depName)
} else {
@@ -3124,65 +3154,87 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
default:
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
}
+
case libDepTag.static():
- if !ctx.OtherModuleHasProvider(dep, StaticLibraryInfoProvider) {
- 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
+ }
+
+ // Stubs lib doesn't link to the static lib dependencies. Don't set
+ // linkFile, depFile, and ptr.
+ if c.IsStubs() {
+ break
+ }
- staticLibraryInfo := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
- linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
- if libDepTag.wholeStatic {
- ptr = &depPaths.WholeStaticLibs
- if len(staticLibraryInfo.Objects.objFiles) > 0 {
- depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLibraryInfo.Objects)
+ 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 {
- // 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())
+ 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))
+ }
}
- 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))
+
+ // 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
@@ -3228,19 +3280,25 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, depExporterInfo.SystemIncludeDirs...)
depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, depExporterInfo.Deps...)
depPaths.Flags = append(depPaths.Flags, depExporterInfo.Flags...)
+ depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, depExporterInfo.RustRlibDeps...)
+
+ // Only re-export RustRlibDeps for cc static libs
+ if c.static() {
+ depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, depExporterInfo.RustRlibDeps...)
+ }
if libDepTag.reexportFlags {
reexportExporter(depExporterInfo)
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
// Re-exported shared library headers must be included as well since they can help us with type information
// about template instantiations (instantiated from their headers).
- // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version
- // scripts.
c.sabi.Properties.ReexportedIncludes = append(
c.sabi.Properties.ReexportedIncludes, depExporterInfo.IncludeDirs.Strings()...)
+ c.sabi.Properties.ReexportedSystemIncludes = append(
+ c.sabi.Properties.ReexportedSystemIncludes, depExporterInfo.SystemIncludeDirs.Strings()...)
}
- makeLibName := MakeLibName(ctx, c, ccDep, depName) + libDepTag.makeSuffix
+ makeLibName := MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName()) + libDepTag.makeSuffix
switch {
case libDepTag.header():
c.Properties.AndroidMkHeaderLibs = append(
@@ -3250,7 +3308,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if lib.buildStubs() && dep.(android.ApexModule).InAnyApex() {
// Add the dependency to the APEX(es) providing the library so that
// m <module> can trigger building the APEXes as well.
- depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
+ depApexInfo, _ := android.OtherModuleProvider(ctx, dep, android.ApexInfoProvider)
for _, an := range depApexInfo.InApexVariants {
c.Properties.ApexesProvidingSharedLibs = append(
c.Properties.ApexesProvidingSharedLibs, an)
@@ -3262,18 +3320,16 @@ 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)
- // Record BaseLibName for snapshots.
- c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, BaseLibName(depName))
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)
+ }
}
- // Record BaseLibName for snapshots.
- c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName))
}
} else if !c.IsStubs() {
// Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies.
@@ -3281,9 +3337,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
- c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, depName)+libDepTag.makeSuffix)
- // Record BaseLibName for snapshots.
- c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName))
+ c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix)
case objDepTag:
depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
case CrtBeginDepTag:
@@ -3306,14 +3360,18 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs)
depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs)
depPaths.GeneratedDeps = android.FirstUniquePaths(depPaths.GeneratedDeps)
+ depPaths.RustRlibDeps = android.FirstUniqueFunc(depPaths.RustRlibDeps, EqRustRlibDeps)
+
depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs)
depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs)
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)
depPaths.ReexportedGeneratedHeaders = android.FirstUniquePaths(depPaths.ReexportedGeneratedHeaders)
+ depPaths.ReexportedRustRlibDeps = android.FirstUniqueFunc(depPaths.ReexportedRustRlibDeps, EqRustRlibDeps)
if c.sabi != nil {
c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)
+ c.sabi.Properties.ReexportedSystemIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedSystemIncludes)
}
return depPaths
@@ -3326,20 +3384,20 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
}
- useVndk := false
+ inVendorOrProduct := false
bootstrap := false
if linkable, ok := ctx.Module().(LinkableInterface); !ok {
panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
} else {
- useVndk = linkable.UseVndk()
+ inVendorOrProduct = linkable.InVendorOrProduct()
bootstrap = linkable.Bootstrap()
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
useStubs := false
- if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK
+ if lib := moduleLibraryInterface(dep); lib.buildStubs() && inVendorOrProduct { // LLNDK
if !apexInfo.IsForPlatform() {
// For platform libraries, use current version of LLNDK
// If this is for use_vendor apex we will apply the same rules
@@ -3369,7 +3427,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
// Another exception: if this module is a test for an APEX, then
// it is linked with the non-stub variant of a module in the APEX
// as if this is part of the APEX.
- testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo)
+ testFor, _ := android.ModuleProvider(ctx, android.ApexTestForInfoProvider)
for _, apexContents := range testFor.ApexContents {
if apexContents.DirectlyInApex(depName) {
useStubs = false
@@ -3415,9 +3473,9 @@ func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibr
panic(fmt.Errorf("Unexpected dependency tag: %T", depTag))
}
- sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
- sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo)
+ sharedLibraryInfo, _ := android.OtherModuleProvider(ctx, dep, SharedLibraryInfoProvider)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
+ sharedLibraryStubsInfo, _ := android.OtherModuleProvider(ctx, dep, SharedLibraryStubsProvider)
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 {
// when to use (unspecified) stubs, use the latest one.
@@ -3435,8 +3493,8 @@ func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibr
// to match the topological order of the dependency tree, including any static analogues of
// direct shared libraries. It returns the ordered static dependencies, and an android.DepSet
// of the transitive dependencies.
-func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLibraryInfo) (ordered android.Paths, transitive *android.DepSet) {
- transitiveStaticLibsBuilder := android.NewDepSetBuilder(android.TOPOLOGICAL)
+func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLibraryInfo) (ordered android.Paths, transitive *android.DepSet[android.Path]) {
+ transitiveStaticLibsBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL)
var staticPaths android.Paths
for _, staticDep := range staticDeps {
staticPaths = append(staticPaths, staticDep.StaticLibrary)
@@ -3486,12 +3544,7 @@ func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableI
}
}
- if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() &&
- !c.InRamdisk() && !c.InVendorRamdisk() && !c.InRecovery() {
- // The vendor module is a no-vendor-variant VNDK library. Depend on the
- // core module instead.
- return libName
- } else if ccDep.UseVndk() && nonSystemVariantsExist {
+ if ccDep.InVendorOrProduct() && nonSystemVariantsExist {
// The vendor and product modules in Make will have been renamed to not conflict with the
// core module, so update the dependency name here accordingly.
return libName + ccDep.SubName()
@@ -3556,23 +3609,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
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (c *Module) static() bool {
if static, ok := c.linker.(interface {
static() bool
@@ -3662,18 +3698,17 @@ func (c *Module) Object() bool {
return false
}
+func (m *Module) Dylib() bool {
+ return false
+}
+
+func (m *Module) Rlib() bool {
+ return false
+}
+
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
- if c.UseVndk() {
+ 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() {
@@ -3691,22 +3726,18 @@ func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
// TODO(b/114741097): use the correct ndk stl once build errors have been fixed
//family, link := getNdkStlFamilyAndLinkType(c)
//return fmt.Sprintf("native:ndk:%s:%s", family, link)
- } else if actx.DeviceConfig().VndkUseCoreVariant() && !c.MustUseVendorVariant() {
- return "native:platform_vndk"
} else {
return "native:platform"
}
}
// Overrides ApexModule.IsInstallabeToApex()
-// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
+// Only shared/runtime libraries .
func (c *Module) IsInstallableToApex() bool {
if lib := c.library; lib != nil {
// Stub libs and prebuilt libs in a versioned SDK are not
// installable to APEX even though they are shared libs.
return lib.shared() && !lib.buildStubs()
- } else if _, ok := c.linker.(testPerSrc); ok {
- return true
}
return false
}
@@ -3877,15 +3908,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()
@@ -3893,8 +3915,6 @@ func (c *Module) overriddenModules() []string {
return nil
}
-var _ snapshot.RelativeInstallPath = (*Module)(nil)
-
type moduleType int
const (
@@ -3907,6 +3927,7 @@ const (
headerLibrary
testBin // testBinary already declared
ndkLibrary
+ ndkPrebuiltStl
)
func (c *Module) typ() moduleType {
@@ -3923,8 +3944,8 @@ func (c *Module) typ() moduleType {
// TODO(b/244431896) properly convert cc_test_library to its own macro. This
// will let them add implicit compile deps on gtest, for example.
//
- // For now, treat them as regular shared libraries.
- return sharedLibrary
+ // For now, treat them as regular libraries.
+ return fullLibrary
} else if c.CcLibrary() {
static := false
shared := false
@@ -3945,73 +3966,12 @@ func (c *Module) typ() moduleType {
return sharedLibrary
} else if c.isNDKStubLibrary() {
return ndkLibrary
+ } else if c.IsNdkPrebuiltStl() {
+ return ndkPrebuiltStl
}
return unknownType
}
-// ConvertWithBp2build converts Module to Bazel for bp2build.
-func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
- prebuilt := c.IsPrebuilt()
- switch c.typ() {
- case binary:
- if prebuilt {
- prebuiltBinaryBp2Build(ctx, c)
- } else {
- binaryBp2build(ctx, c)
- }
- case testBin:
- if !prebuilt {
- testBinaryBp2build(ctx, c)
- }
- case object:
- if prebuilt {
- prebuiltObjectBp2Build(ctx, c)
- } else {
- objectBp2Build(ctx, c)
- }
- case fullLibrary:
- if !prebuilt {
- libraryBp2Build(ctx, c)
- } else {
- prebuiltLibraryBp2Build(ctx, c)
- }
- case headerLibrary:
- libraryHeadersBp2Build(ctx, c)
- case staticLibrary:
- if prebuilt {
- prebuiltLibraryStaticBp2Build(ctx, c, false)
- } else {
- sharedOrStaticLibraryBp2Build(ctx, c, true)
- }
- case sharedLibrary:
- if prebuilt {
- prebuiltLibrarySharedBp2Build(ctx, c)
- } else {
- sharedOrStaticLibraryBp2Build(ctx, c, false)
- }
- }
-}
-
-var _ android.ApiProvider = (*Module)(nil)
-
-func (c *Module) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
- if c.IsPrebuilt() {
- return
- }
- switch c.typ() {
- case fullLibrary:
- apiContributionBp2Build(ctx, c)
- case sharedLibrary:
- apiContributionBp2Build(ctx, c)
- case headerLibrary:
- // Aggressively generate api targets for all header modules
- // This is necessary since the header module does not know if it is a dep of API surface stub library
- apiLibraryHeadersBp2Build(ctx, c)
- case ndkLibrary:
- ndkLibraryBp2build(ctx, c)
- }
-}
-
// Defaults
type Defaults struct {
android.ModuleBase
@@ -4055,10 +4015,9 @@ func DefaultsFactory(props ...interface{}) android.Module {
&TidyProperties{},
&CoverageProperties{},
&SAbiProperties{},
- &VndkProperties{},
&LTOProperties{},
&AfdoProperties{},
- &PgoProperties{},
+ &OrderfileProperties{},
&android.ProtoProperties{},
// RustBindgenProperties is included here so that cc_defaults can be used for rust_bindgen modules.
&RustBindgenClangProperties{},
@@ -4108,6 +4067,18 @@ func (c *Module) Partition() string {
return ""
}
+type sourceModuleName interface {
+ sourceModuleName() string
+}
+
+func (c *Module) BaseModuleName() string {
+ if smn, ok := c.linker.(sourceModuleName); ok && smn.sourceModuleName() != "" {
+ // if the prebuilt module sets a source_module_name in Android.bp, use that
+ return smn.sourceModuleName()
+ }
+ return c.ModuleBase.BaseModuleName()
+}
+
var Bool = proptools.Bool
var BoolDefault = proptools.BoolDefault
var BoolPtr = proptools.BoolPtr