diff options
Diffstat (limited to 'cc/cc.go')
-rw-r--r-- | cc/cc.go | 124 |
1 files changed, 93 insertions, 31 deletions
@@ -36,9 +36,9 @@ func init() { android.RegisterModuleType("cc_defaults", defaultsFactory) android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { + ctx.BottomUp("vndk", VndkMutator).Parallel() ctx.BottomUp("image", ImageMutator).Parallel() ctx.BottomUp("link", LinkageMutator).Parallel() - ctx.BottomUp("vndk", VndkMutator).Parallel() ctx.BottomUp("ndk_api", ndkApiMutator).Parallel() ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel() ctx.BottomUp("version", VersionMutator).Parallel() @@ -200,7 +200,8 @@ type BaseProperties struct { PreventInstall bool `blueprint:"mutated"` ApexesProvidingSharedLibs []string `blueprint:"mutated"` - UseVndk bool `blueprint:"mutated"` + VndkVersion string `blueprint:"mutated"` + SubName string `blueprint:"mutated"` // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags // file @@ -400,6 +401,14 @@ func StaticDepTag() dependencyTag { return staticDepTag } +func CrtBeginDepTag() dependencyTag { + return crtBeginDepTag +} + +func CrtEndDepTag() dependencyTag { + return crtEndDepTag +} + // 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 interface @@ -407,6 +416,7 @@ type Module struct { android.ModuleBase android.DefaultableModuleBase android.ApexModuleBase + android.SdkBase Properties BaseProperties VendorProperties VendorProperties @@ -542,10 +552,9 @@ func (c *Module) Init() android.Module { } }) android.InitAndroidArchModule(c, c.hod, c.multilib) - - android.InitDefaultableModule(c) - android.InitApexModule(c) + android.InitDefaultableModule(c) + android.InitSdkAwareModule(c) return c } @@ -562,7 +571,7 @@ func (c *Module) isDependencyRoot() bool { } func (c *Module) useVndk() bool { - return c.Properties.UseVndk + return c.Properties.VndkVersion != "" } func (c *Module) isCoverageVariant() bool { @@ -596,10 +605,7 @@ func (c *Module) isVndk() bool { } func (c *Module) vndkVersion() string { - if vndkdep := c.vndkdep; vndkdep != nil { - return vndkdep.Properties.Vndk.Version - } - return "" + return c.Properties.VndkVersion } func (c *Module) isPgoCompile() bool { @@ -1009,6 +1015,31 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { c.makeLinkType = c.getMakeLinkType(actx) + c.Properties.SubName = "" + + if c.Target().NativeBridge == android.NativeBridgeEnabled { + c.Properties.SubName += nativeBridgeSuffix + } + + if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok { + // .vendor suffix is added for backward compatibility with VNDK snapshot whose names with + // such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp. + c.Properties.SubName += vendorSuffix + } else if _, ok := c.linker.(*llndkStubDecorator); ok || (c.useVndk() && c.hasVendorVariant()) { + // .vendor.{version} suffix is added only when we will have two variants: core and vendor. + // The suffix is not added for vendor-only module. + c.Properties.SubName += vendorSuffix + vendorVersion := actx.DeviceConfig().VndkVersion() + if vendorVersion == "current" { + vendorVersion = actx.DeviceConfig().PlatformVndkVersion() + } + if c.Properties.VndkVersion != vendorVersion { + c.Properties.SubName += "." + c.Properties.VndkVersion + } + } else if c.inRecovery() && !c.onlyInRecovery() { + c.Properties.SubName += recoverySuffix + } + ctx := &moduleContext{ ModuleContext: actx, moduleContextImpl: moduleContextImpl{ @@ -1496,9 +1527,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { if vndkdep := c.vndkdep; vndkdep != nil { if vndkdep.isVndkExt() { - baseModuleMode := vendorMode + var baseModuleMode string if actx.DeviceConfig().VndkVersion() == "" { baseModuleMode = coreMode + } else { + baseModuleMode = c.imageVariation() } actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "image", Variation: baseModuleMode}, @@ -1521,7 +1554,7 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag depe // Host code is not restricted return } - if from.Properties.UseVndk { + if from.useVndk() { // Though vendor code is limited by the vendor mutator, // each vendor-available module needs to check // link-type for VNDK. @@ -1928,7 +1961,15 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } else if c.useVndk() && bothVendorAndCoreVariantsExist { // The vendor module in Make will have been renamed to not conflict with the core // module, so update the dependency name here accordingly. - return libName + vendorSuffix + ret := libName + vendorSuffix + vendorVersion := ctx.DeviceConfig().VndkVersion() + if vendorVersion == "current" { + vendorVersion = ctx.DeviceConfig().PlatformVndkVersion() + } + if c.Properties.VndkVersion != vendorVersion { + ret += "." + c.Properties.VndkVersion + } + return ret } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib { return libName + vendorPublicLibrarySuffix } else if ccDep.inRecovery() && !ccDep.onlyInRecovery() { @@ -2114,13 +2155,12 @@ func (c *Module) installable() bool { } func (c *Module) imageVariation() string { - variation := "core" if c.useVndk() { - variation = "vendor" + return vendorMode + "." + c.Properties.VndkVersion } else if c.inRecovery() { - variation = "recovery" + return recoveryMode } - return variation + return coreMode } func (c *Module) IDEInfo(dpInfo *android.IdeInfo) { @@ -2168,10 +2208,13 @@ func DefaultsFactory(props ...interface{}) android.Module { &BaseLinkerProperties{}, &ObjectLinkerProperties{}, &LibraryProperties{}, + &StaticProperties{}, + &SharedProperties{}, &FlagExporterProperties{}, &BinaryLinkerProperties{}, &TestProperties{}, &TestBinaryProperties{}, + &FuzzProperties{}, &StlProperties{}, &SanitizeProperties{}, &StripProperties{}, @@ -2186,8 +2229,8 @@ func DefaultsFactory(props ...interface{}) android.Module { &android.ProtoProperties{}, ) - android.InitDefaultsModule(module) android.InitApexModule(module) + android.InitDefaultsModule(module) return module } @@ -2197,7 +2240,7 @@ const ( // SDK libraries. (which framework-private libraries can use) coreMode = "core" - // vendorMode is the variant used for /vendor code that compiles + // vendorMode is the variant prefix used for /vendor code that compiles // against the VNDK. vendorMode = "vendor" @@ -2261,7 +2304,10 @@ func ImageMutator(mctx android.BottomUpMutatorContext) { variants = append(variants, coreMode) } if vendorVariantNeeded { - variants = append(variants, vendorMode) + variants = append(variants, vendorMode+"."+mctx.DeviceConfig().PlatformVndkVersion()) + if vndkVersion := mctx.DeviceConfig().VndkVersion(); vndkVersion != "current" { + variants = append(variants, vendorMode+"."+vndkVersion) + } } if recoveryVariantNeeded { variants = append(variants, recoveryMode) @@ -2333,9 +2379,16 @@ func ImageMutator(mctx android.BottomUpMutatorContext) { } var coreVariantNeeded bool = false - var vendorVariantNeeded bool = false var recoveryVariantNeeded bool = false + var vendorVariants []string + + platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion() + deviceVndkVersion := mctx.DeviceConfig().VndkVersion() + if deviceVndkVersion == "current" { + deviceVndkVersion = platformVndkVersion + } + if mctx.DeviceConfig().VndkVersion() == "" { // If the device isn't compiling against the VNDK, we always // use the core mode. @@ -2346,22 +2399,31 @@ func ImageMutator(mctx android.BottomUpMutatorContext) { } else if _, ok := m.linker.(*llndkStubDecorator); ok { // LL-NDK stubs only exist in the vendor variant, since the // real libraries will be used in the core variant. - vendorVariantNeeded = true + vendorVariants = append(vendorVariants, + platformVndkVersion, + deviceVndkVersion, + ) } else if _, ok := m.linker.(*llndkHeadersDecorator); ok { // ... and LL-NDK headers as well - vendorVariantNeeded = true - } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok { + vendorVariants = append(vendorVariants, + platformVndkVersion, + deviceVndkVersion, + ) + } else if lib, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok { // Make vendor variants only for the versions in BOARD_VNDK_VERSION and // PRODUCT_EXTRA_VNDK_VERSIONS. - vendorVariantNeeded = true + vendorVariants = append(vendorVariants, lib.version()) } else if m.hasVendorVariant() && !vendorSpecific { // This will be available in both /system and /vendor // or a /system directory that is available to vendor. coreVariantNeeded = true - vendorVariantNeeded = true + vendorVariants = append(vendorVariants, platformVndkVersion) + if m.isVndk() { + vendorVariants = append(vendorVariants, deviceVndkVersion) + } } else if vendorSpecific && String(m.Properties.Sdk_version) == "" { // This will be available in /vendor (or /odm) only - vendorVariantNeeded = true + vendorVariants = append(vendorVariants, deviceVndkVersion) } else { // This is either in /system (or similar: /data), or is a // modules built with the NDK. Modules built with the NDK @@ -2390,17 +2452,17 @@ func ImageMutator(mctx android.BottomUpMutatorContext) { if coreVariantNeeded { variants = append(variants, coreMode) } - if vendorVariantNeeded { - variants = append(variants, vendorMode) + for _, variant := range android.FirstUniqueStrings(vendorVariants) { + variants = append(variants, vendorMode+"."+variant) } if recoveryVariantNeeded { variants = append(variants, recoveryMode) } mod := mctx.CreateVariations(variants...) for i, v := range variants { - if v == vendorMode { + if strings.HasPrefix(v, vendorMode+".") { m := mod[i].(*Module) - m.Properties.UseVndk = true + m.Properties.VndkVersion = strings.TrimPrefix(v, vendorMode+".") squashVendorSrcs(m) } else if v == recoveryMode { m := mod[i].(*Module) |