Some clarifications in preparation to automatically order linker dependencies

Test: Browse the code and determine whether it's easier to understand
Bug: 66260943
Change-Id: I88c24a8a31ef68f428919087d206433659265684
This commit is contained in:
Jeff Gaston
2017-09-27 17:01:44 -07:00
committed by Colin Cross
parent 16b9ce4dff
commit af3cc2d23c
19 changed files with 219 additions and 211 deletions

View File

@@ -61,7 +61,7 @@ type androidBaseContext interface {
Windows() bool Windows() bool
Debug() bool Debug() bool
PrimaryArch() bool PrimaryArch() bool
Vendor() bool InstallOnVendorPartition() bool
AConfig() Config AConfig() Config
DeviceConfig() DeviceConfig DeviceConfig() DeviceConfig
} }
@@ -99,7 +99,11 @@ type ModuleContext interface {
type Module interface { type Module interface {
blueprint.Module blueprint.Module
// GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
// but GenerateAndroidBuildActions also has access to Android-specific information.
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
GenerateAndroidBuildActions(ModuleContext) GenerateAndroidBuildActions(ModuleContext)
DepsMutator(BottomUpMutatorContext) DepsMutator(BottomUpMutatorContext)
base() *ModuleBase base() *ModuleBase
@@ -690,7 +694,7 @@ func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
return DeviceConfig{a.config.deviceConfig} return DeviceConfig{a.config.deviceConfig}
} }
func (a *androidBaseContextImpl) Vendor() bool { func (a *androidBaseContextImpl) InstallOnVendorPartition() bool {
return a.vendor return a.vendor
} }

View File

@@ -18,12 +18,13 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
) )
// Mutator phases: // Phases:
// Pre-arch // run Pre-arch mutators
// Arch // run archMutator
// Pre-deps // run Pre-deps mutators
// Deps // run depsMutator
// PostDeps // run PostDeps mutators
// continue on to GenerateAndroidBuildActions
func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) { func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) {
for _, t := range mutators { for _, t := range mutators {

View File

@@ -739,7 +739,7 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
var partition string var partition string
if ctx.InstallInData() { if ctx.InstallInData() {
partition = "data" partition = "data"
} else if ctx.Vendor() { } else if ctx.InstallOnVendorPartition() {
partition = ctx.DeviceConfig().VendorPath() partition = ctx.DeviceConfig().VendorPath()
} else { } else {
partition = "system" partition = "system"

View File

@@ -30,7 +30,7 @@ var (
type AndroidMkContext interface { type AndroidMkContext interface {
Target() android.Target Target() android.Target
subAndroidMk(*android.AndroidMkData, interface{}) subAndroidMk(*android.AndroidMkData, interface{})
vndk() bool useVndk() bool
} }
type subAndroidMkProvider interface { type subAndroidMkProvider interface {
@@ -64,14 +64,14 @@ func (c *Module) AndroidMk() android.AndroidMkData {
if len(c.Properties.AndroidMkSharedLibs) > 0 { if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
} }
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" && !c.vndk() { if c.Target().Os == android.Android && c.Properties.Sdk_version != "" && !c.useVndk() {
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version) fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none") fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
} else { } else {
// These are already included in LOCAL_SHARED_LIBRARIES // These are already included in LOCAL_SHARED_LIBRARIES
fmt.Fprintln(w, "LOCAL_CXX_STL := none") fmt.Fprintln(w, "LOCAL_CXX_STL := none")
} }
if c.vndk() { if c.useVndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
} }
}, },
@@ -89,7 +89,7 @@ func (c *Module) AndroidMk() android.AndroidMkData {
} }
c.subAndroidMk(&ret, c.installer) c.subAndroidMk(&ret, c.installer)
if c.vndk() && c.hasVendorVariant() { if c.useVndk() && c.hasVendorVariant() {
// .vendor suffix is added only when we will have two variants: core and vendor. // .vendor suffix is added only when we will have two variants: core and vendor.
// The suffix is not added for vendor-only module. // The suffix is not added for vendor-only module.
ret.SubName += vendorSuffix ret.SubName += vendorSuffix
@@ -161,7 +161,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
} }
fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs) fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
} else if ctx.vndk() { } else if ctx.useVndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
} }

View File

@@ -108,7 +108,7 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = binary.baseLinker.linkerDeps(ctx, deps) deps = binary.baseLinker.linkerDeps(ctx, deps)
if ctx.toolchain().Bionic() { if ctx.toolchain().Bionic() {
if !Bool(binary.baseLinker.Properties.Nocrt) { if !Bool(binary.baseLinker.Properties.Nocrt) {
if !ctx.sdk() { if !ctx.useSdk() {
if binary.static() { if binary.static() {
deps.CrtBegin = "crtbegin_static" deps.CrtBegin = "crtbegin_static"
} else { } else {

View File

@@ -219,7 +219,7 @@ type builderFlags struct {
arFlags string arFlags string
asFlags string asFlags string
cFlags string cFlags string
toolingCFlags string // Seperate set of Cflags for clang LibTooling tools toolingCFlags string // A separate set of Cflags for clang LibTooling tools
conlyFlags string conlyFlags string
cppFlags string cppFlags string
ldFlags string ldFlags string
@@ -584,7 +584,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
} }
// Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries, // Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries,
// and shared libraires, to a shared library (.so) or dynamic executable // and shared libraries, to a shared library (.so) or dynamic executable
func TransformObjToDynamicBinary(ctx android.ModuleContext, func TransformObjToDynamicBinary(ctx android.ModuleContext,
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths, objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) { crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) {
@@ -714,8 +714,8 @@ func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceD
return android.OptionalPathForPath(outputFile) return android.OptionalPathForPath(outputFile)
} }
// Generate a rule for extract a table of contents from a shared library (.so) // Generate a rule for extracting a table of contents from a shared library (.so)
func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.WritablePath, func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Path,
outputFile android.WritablePath, flags builderFlags) { outputFile android.WritablePath, flags builderFlags) {
crossCompile := gccCmd(flags.toolchain, "") crossCompile := gccCmd(flags.toolchain, "")

341
cc/cc.go
View File

@@ -197,9 +197,9 @@ type ModuleContextIntf interface {
clang() bool clang() bool
toolchain() config.Toolchain toolchain() config.Toolchain
noDefaultCompilerFlags() bool noDefaultCompilerFlags() bool
sdk() bool useSdk() bool
sdkVersion() string sdkVersion() string
vndk() bool useVndk() bool
isVndk() bool isVndk() bool
isVndkSp() bool isVndkSp() bool
createVndkSourceAbiDump() bool createVndkSourceAbiDump() bool
@@ -382,7 +382,7 @@ func (c *Module) isDependencyRoot() bool {
return false return false
} }
func (c *Module) vndk() bool { func (c *Module) useVndk() bool {
return c.Properties.UseVndk return c.Properties.UseVndk
} }
@@ -414,10 +414,8 @@ type moduleContext struct {
moduleContextImpl moduleContextImpl
} }
// Vendor returns true for vendor modules excluding VNDK libraries so that func (ctx *moduleContext) InstallOnVendorPartition() bool {
// they get installed onto the correct partition return ctx.ModuleContext.InstallOnVendorPartition() || (ctx.mod.useVndk() && !ctx.mod.isVndk())
func (ctx *moduleContext) Vendor() bool {
return ctx.ModuleContext.Vendor() || (ctx.mod.vndk() && !ctx.mod.isVndk())
} }
type moduleContextImpl struct { type moduleContextImpl struct {
@@ -455,8 +453,8 @@ func (ctx *moduleContextImpl) noDefaultCompilerFlags() bool {
return Bool(ctx.mod.Properties.No_default_compiler_flags) return Bool(ctx.mod.Properties.No_default_compiler_flags)
} }
func (ctx *moduleContextImpl) sdk() bool { func (ctx *moduleContextImpl) useSdk() bool {
if ctx.ctx.Device() && !ctx.vndk() { if ctx.ctx.Device() && !ctx.useVndk() {
return ctx.mod.Properties.Sdk_version != "" return ctx.mod.Properties.Sdk_version != ""
} }
return false return false
@@ -464,7 +462,7 @@ func (ctx *moduleContextImpl) sdk() bool {
func (ctx *moduleContextImpl) sdkVersion() string { func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() { if ctx.ctx.Device() {
if ctx.vndk() { if ctx.useVndk() {
return "current" return "current"
} else { } else {
return ctx.mod.Properties.Sdk_version return ctx.mod.Properties.Sdk_version
@@ -473,13 +471,12 @@ func (ctx *moduleContextImpl) sdkVersion() string {
return "" return ""
} }
func (ctx *moduleContextImpl) vndk() bool {
return ctx.mod.vndk()
}
func (ctx *moduleContextImpl) isVndk() bool { func (ctx *moduleContextImpl) isVndk() bool {
return ctx.mod.isVndk() return ctx.mod.isVndk()
} }
func (ctx *moduleContextImpl) useVndk() bool {
return ctx.mod.useVndk()
}
func (ctx *moduleContextImpl) isVndkSp() bool { func (ctx *moduleContextImpl) isVndkSp() bool {
if vndk := ctx.mod.vndkdep; vndk != nil { if vndk := ctx.mod.vndkdep; vndk != nil {
@@ -490,7 +487,7 @@ func (ctx *moduleContextImpl) isVndkSp() bool {
// Create source abi dumps if the module belongs to the list of VndkLibraries. // Create source abi dumps if the module belongs to the list of VndkLibraries.
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool { func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
return ctx.ctx.Device() && ((ctx.vndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries)) return ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
} }
func (ctx *moduleContextImpl) selectedStl() string { func (ctx *moduleContextImpl) selectedStl() string {
@@ -544,6 +541,7 @@ func (c *Module) Name() string {
} }
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx := &moduleContext{ ctx := &moduleContext{
ModuleContext: actx, ModuleContext: actx,
moduleContextImpl: moduleContextImpl{ moduleContextImpl: moduleContextImpl{
@@ -669,7 +667,7 @@ func (c *Module) begin(ctx BaseModuleContext) {
for _, feature := range c.features { for _, feature := range c.features {
feature.begin(ctx) feature.begin(ctx)
} }
if ctx.sdk() { if ctx.useSdk() {
version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch()) version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
if err != nil { if err != nil {
ctx.PropertyErrorf("sdk_version", err.Error()) ctx.PropertyErrorf("sdk_version", err.Error())
@@ -781,27 +779,31 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if ctx.Os() == android.Android { if ctx.Os() == android.Android {
version := ctx.sdkVersion() version := ctx.sdkVersion()
// Rewrites the names of shared libraries into the names of the NDK // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
// libraries where appropriate. This returns two slices. // of names:
// //
// The first is a list of non-variant shared libraries (either rewritten // 1. Name of an NDK library that refers to a prebuilt module.
// NDK libraries to the modules in prebuilts/ndk, or not rewritten // For each of these, it adds the name of the prebuilt module (which will be in
// because they are not NDK libraries). // prebuilts/ndk) to the list of nonvariant libs.
// 2. 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).
// It adds these to the nonvariantLibs list.
// //
// The second is a list of ndk_library modules. These need to be // The caller can then know to add the variantLibs dependencies differently from the
// separated because they are a variation dependency and must be added // nonvariantLibs
// in a different manner. rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
rewriteNdkLibs := func(list []string) ([]string, []string) { variantLibs = []string{}
variantLibs := []string{} nonvariantLibs = []string{}
nonvariantLibs := []string{}
for _, entry := range list { for _, entry := range list {
if ctx.sdk() && inList(entry, ndkPrebuiltSharedLibraries) { if ctx.useSdk() && inList(entry, ndkPrebuiltSharedLibraries) {
if !inList(entry, ndkMigratedLibs) { if !inList(entry, ndkMigratedLibs) {
nonvariantLibs = append(nonvariantLibs, entry+".ndk."+version) nonvariantLibs = append(nonvariantLibs, entry+".ndk."+version)
} else { } else {
variantLibs = append(variantLibs, entry+ndkLibrarySuffix) variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
} }
} else if ctx.vndk() && inList(entry, llndkLibraries) { } else if ctx.useVndk() && inList(entry, llndkLibraries) {
nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix) nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
} else { } else {
nonvariantLibs = append(nonvariantLibs, entry) nonvariantLibs = append(nonvariantLibs, entry)
@@ -903,117 +905,118 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
return clang return clang
} }
// Whether a module can link to another module, taking into
// account NDK linking.
func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
if from.Target().Os != android.Android {
// Host code is not restricted
return
}
if from.Properties.UseVndk {
// Though vendor code is limited by the vendor mutator,
// each vendor-available module needs to check
// link-type for VNDK.
if from.vndkdep != nil {
from.vndkdep.vndkCheckLinkType(ctx, to)
}
return
}
if from.Properties.Sdk_version == "" {
// Platform code can link to anything
return
}
if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
// These are always allowed
return
}
if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
// These are allowed, but they don't set sdk_version
return
}
if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
// These are allowed, but they don't set sdk_version
return
}
if _, ok := to.linker.(*stubDecorator); ok {
// These aren't real libraries, but are the stub shared libraries that are included in
// the NDK.
return
}
if to.Properties.Sdk_version == "" {
// NDK code linking to platform code is never okay.
ctx.ModuleErrorf("depends on non-NDK-built library %q",
ctx.OtherModuleName(to))
}
// At this point we know we have two NDK libraries, but we need to
// check that we're not linking against anything built against a higher
// API level, as it is only valid to link against older or equivalent
// APIs.
if from.Properties.Sdk_version == "current" {
// Current can link against anything.
return
} else if to.Properties.Sdk_version == "current" {
// Current can't be linked against by anything else.
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), "current")
}
fromApi, err := strconv.Atoi(from.Properties.Sdk_version)
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
from.Properties.Sdk_version)
}
toApi, err := strconv.Atoi(to.Properties.Sdk_version)
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
to.Properties.Sdk_version)
}
if toApi > fromApi {
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), to.Properties.Sdk_version)
}
}
// Convert dependencies to paths. Returns a PathDeps containing paths // Convert dependencies to paths. Returns a PathDeps containing paths
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
var depPaths PathDeps var depPaths PathDeps
// Whether a module can link to another module, taking into ctx.VisitDirectDeps(func(dep blueprint.Module) {
// account NDK linking. depName := ctx.OtherModuleName(dep)
checkLinkType := func(from, to *Module) { depTag := ctx.OtherModuleDependencyTag(dep)
if from.Target().Os != android.Android {
// Host code is not restricted
return
}
if from.Properties.UseVndk {
// Though vendor code is limited by the vendor mutator,
// each vendor-available module needs to check
// link-type for VNDK.
if from.vndkdep != nil {
from.vndkdep.vndkCheckLinkType(ctx, to)
}
return
}
if from.Properties.Sdk_version == "" {
// Platform code can link to anything
return
}
if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
// These are always allowed
return
}
if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
// These are allowed, but don't set sdk_version
return
}
if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
// These are allowed, but don't set sdk_version
return
}
if _, ok := to.linker.(*stubDecorator); ok {
// These aren't real libraries, but are the stub shared libraries that are included in
// the NDK.
return
}
if to.Properties.Sdk_version == "" {
// NDK code linking to platform code is never okay.
ctx.ModuleErrorf("depends on non-NDK-built library %q",
ctx.OtherModuleName(to))
}
// All this point we know we have two NDK libraries, but we need to aDep, _ := dep.(android.Module)
// check that we're not linking against anything built against a higher if aDep == nil {
// API level, as it is only valid to link against older or equivalent ctx.ModuleErrorf("module %q not an android module", depName)
// APIs.
if from.Properties.Sdk_version == "current" {
// Current can link against anything.
return
} else if to.Properties.Sdk_version == "current" {
// Current can't be linked against by anything else.
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), "current")
}
fromApi, err := strconv.Atoi(from.Properties.Sdk_version)
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
from.Properties.Sdk_version)
}
toApi, err := strconv.Atoi(to.Properties.Sdk_version)
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
to.Properties.Sdk_version)
}
if toApi > fromApi {
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), to.Properties.Sdk_version)
}
}
ctx.VisitDirectDeps(func(m blueprint.Module) {
name := ctx.OtherModuleName(m)
tag := ctx.OtherModuleDependencyTag(m)
a, _ := m.(android.Module)
if a == nil {
ctx.ModuleErrorf("module %q not an android module", name)
return return
} }
cc, _ := m.(*Module) ccDep, _ := dep.(*Module)
if cc == nil { if ccDep == nil {
switch tag { // handling for a few module types that aren't cc Module but that are also supported
switch depTag {
case android.DefaultsDepTag, android.SourceDepTag: case android.DefaultsDepTag, android.SourceDepTag:
// Nothing to do // Nothing to do
case genSourceDepTag: case genSourceDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok { if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedSources = append(depPaths.GeneratedSources, depPaths.GeneratedSources = append(depPaths.GeneratedSources,
genRule.GeneratedSourceFiles()...) genRule.GeneratedSourceFiles()...)
} else { } else {
ctx.ModuleErrorf("module %q is not a gensrcs or genrule", name) ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
} }
// Support exported headers from a generated_sources dependency // Support exported headers from a generated_sources dependency
fallthrough fallthrough
case genHeaderDepTag, genHeaderExportDepTag: case genHeaderDepTag, genHeaderExportDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok { if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedSourceFiles()...) genRule.GeneratedSourceFiles()...)
flags := includeDirsToFlags(genRule.GeneratedHeaderDirs()) flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
depPaths.Flags = append(depPaths.Flags, flags) depPaths.Flags = append(depPaths.Flags, flags)
if tag == genHeaderExportDepTag { if depTag == genHeaderExportDepTag {
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags) depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
genRule.GeneratedSourceFiles()...) genRule.GeneratedSourceFiles()...)
@@ -1022,46 +1025,46 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
} }
} else { } else {
ctx.ModuleErrorf("module %q is not a genrule", name) ctx.ModuleErrorf("module %q is not a genrule", depName)
} }
case linkerScriptDepTag: case linkerScriptDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok { if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
files := genRule.GeneratedSourceFiles() files := genRule.GeneratedSourceFiles()
if len(files) == 1 { if len(files) == 1 {
depPaths.LinkerScript = android.OptionalPathForPath(files[0]) depPaths.LinkerScript = android.OptionalPathForPath(files[0])
} else if len(files) > 1 { } else if len(files) > 1 {
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", name) ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", depName)
} }
} else { } else {
ctx.ModuleErrorf("module %q is not a genrule", name) ctx.ModuleErrorf("module %q is not a genrule", depName)
} }
default: default:
ctx.ModuleErrorf("depends on non-cc module %q", name) ctx.ModuleErrorf("depends on non-cc module %q", depName)
} }
return return
} }
if !a.Enabled() { // some validation
if !aDep.Enabled() {
if ctx.AConfig().AllowMissingDependencies() { if ctx.AConfig().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{name}) ctx.AddMissingDependencies([]string{depName})
} else { } else {
ctx.ModuleErrorf("depends on disabled module %q", name) ctx.ModuleErrorf("depends on disabled module %q", depName)
} }
return return
} }
if aDep.Target().Os != ctx.Os() {
if a.Target().Os != ctx.Os() { ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), name) return
}
if aDep.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
return return
} }
if a.Target().Arch.ArchType != ctx.Arch().ArchType { // re-exporting flags
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), name) if depTag == reuseObjTag {
return if l, ok := ccDep.compiler.(libraryInterface); ok {
}
if tag == reuseObjTag {
if l, ok := cc.compiler.(libraryInterface); ok {
objs, flags, deps := l.reuseObjs() objs, flags, deps := l.reuseObjs()
depPaths.Objs = depPaths.Objs.Append(objs) depPaths.Objs = depPaths.Objs.Append(objs)
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...) depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
@@ -1069,9 +1072,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return return
} }
} }
if t, ok := depTag.(dependencyTag); ok && t.library {
if t, ok := tag.(dependencyTag); ok && t.library { if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
if i, ok := cc.linker.(exportedFlagsProducer); ok {
flags := i.exportedFlags() flags := i.exportedFlags()
deps := i.exportedFlagsDeps() deps := i.exportedFlagsDeps()
depPaths.Flags = append(depPaths.Flags, flags...) depPaths.Flags = append(depPaths.Flags, flags...)
@@ -1087,38 +1089,38 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
} }
} }
checkLinkType(c, cc) checkLinkType(ctx, c, ccDep)
} }
var ptr *android.Paths var ptr *android.Paths
var depPtr *android.Paths var depPtr *android.Paths
linkFile := cc.outputFile linkFile := ccDep.outputFile
depFile := android.OptionalPath{} depFile := android.OptionalPath{}
switch tag { switch depTag {
case ndkStubDepTag, sharedDepTag, sharedExportDepTag: case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
ptr = &depPaths.SharedLibs ptr = &depPaths.SharedLibs
depPtr = &depPaths.SharedLibsDeps depPtr = &depPaths.SharedLibsDeps
depFile = cc.linker.(libraryInterface).toc() depFile = ccDep.linker.(libraryInterface).toc()
case lateSharedDepTag, ndkLateStubDepTag: case lateSharedDepTag, ndkLateStubDepTag:
ptr = &depPaths.LateSharedLibs ptr = &depPaths.LateSharedLibs
depPtr = &depPaths.LateSharedLibsDeps depPtr = &depPaths.LateSharedLibsDeps
depFile = cc.linker.(libraryInterface).toc() depFile = ccDep.linker.(libraryInterface).toc()
case staticDepTag, staticExportDepTag: case staticDepTag, staticExportDepTag:
ptr = &depPaths.StaticLibs ptr = &depPaths.StaticLibs
case lateStaticDepTag: case lateStaticDepTag:
ptr = &depPaths.LateStaticLibs ptr = &depPaths.LateStaticLibs
case wholeStaticDepTag: case wholeStaticDepTag:
ptr = &depPaths.WholeStaticLibs ptr = &depPaths.WholeStaticLibs
staticLib, ok := cc.linker.(libraryInterface) staticLib, ok := ccDep.linker.(libraryInterface)
if !ok || !staticLib.static() { if !ok || !staticLib.static() {
ctx.ModuleErrorf("module %q not a static library", name) ctx.ModuleErrorf("module %q not a static library", depName)
return return
} }
if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil { if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
postfix := " (required by " + ctx.OtherModuleName(m) + ")" postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
for i := range missingDeps { for i := range missingDeps {
missingDeps[i] += postfix missingDeps[i] += postfix
} }
@@ -1135,11 +1137,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.CrtEnd = linkFile depPaths.CrtEnd = linkFile
} }
switch tag { switch depTag {
case staticDepTag, staticExportDepTag, lateStaticDepTag: case staticDepTag, staticExportDepTag, lateStaticDepTag:
staticLib, ok := cc.linker.(libraryInterface) staticLib, ok := ccDep.linker.(libraryInterface)
if !ok || !staticLib.static() { if !ok || !staticLib.static() {
ctx.ModuleErrorf("module %q not a static library", name) ctx.ModuleErrorf("module %q not a static library", depName)
return return
} }
@@ -1150,11 +1152,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
staticLib.objs().coverageFiles...) staticLib.objs().coverageFiles...)
depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles, depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
staticLib.objs().sAbiDumpFiles...) staticLib.objs().sAbiDumpFiles...)
} }
if ptr != nil { if ptr != nil {
if !linkFile.Valid() { if !linkFile.Valid() {
ctx.ModuleErrorf("module %q missing output file", name) ctx.ModuleErrorf("module %q missing output file", depName)
return return
} }
*ptr = append(*ptr, linkFile.Path()) *ptr = append(*ptr, linkFile.Path())
@@ -1168,24 +1171,24 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
*depPtr = append(*depPtr, dep.Path()) *depPtr = append(*depPtr, dep.Path())
} }
// Export the shared libs to the make world. In doing so, .vendor suffix // Export the shared libs to Make.
// is added if the lib has both core and vendor variants and this module switch depTag {
// is building against vndk. This is because the vendor variant will
// have .vendor suffix in its name in the make world. However, if the
// lib is a vendor-only lib or this lib is not building against vndk,
// then the suffix is not added.
switch tag {
case sharedDepTag, sharedExportDepTag, lateSharedDepTag: case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
libName := strings.TrimSuffix(name, llndkLibrarySuffix) libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
libName = strings.TrimPrefix(libName, "prebuilt_") libName = strings.TrimPrefix(libName, "prebuilt_")
isLLndk := inList(libName, llndkLibraries) isLLndk := inList(libName, llndkLibraries)
if c.vndk() && (cc.hasVendorVariant() || isLLndk) { var makeLibName string
libName += vendorSuffix bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
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.
makeLibName = libName + vendorSuffix
} else {
makeLibName = libName
} }
// Note: the order of libs in this list is not important because // Note: the order of libs in this list is not important because
// they merely serve as dependencies in the make world and do not // they merely serve as Make dependencies and do not affect this lib itself.
// affect this lib itself. c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, makeLibName)
c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, libName)
} }
}) })
@@ -1318,7 +1321,7 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
mctx.CreateVariations(coreMode) mctx.CreateVariations(coreMode)
} else if Bool(props.Vendor_available) { } else if Bool(props.Vendor_available) {
mctx.CreateVariations(coreMode, vendorMode) mctx.CreateVariations(coreMode, vendorMode)
} else if mctx.Vendor() { } else if mctx.InstallOnVendorPartition() {
mctx.CreateVariations(vendorMode) mctx.CreateVariations(vendorMode)
} else { } else {
mctx.CreateVariations(coreMode) mctx.CreateVariations(coreMode)
@@ -1332,7 +1335,7 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
} }
// Sanity check // Sanity check
if m.VendorProperties.Vendor_available != nil && mctx.Vendor() { if m.VendorProperties.Vendor_available != nil && mctx.InstallOnVendorPartition() {
mctx.PropertyErrorf("vendor_available", mctx.PropertyErrorf("vendor_available",
"doesn't make sense at the same time as `vendor: true` or `proprietary: true`") "doesn't make sense at the same time as `vendor: true` or `proprietary: true`")
return return
@@ -1365,7 +1368,7 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
vendor := mod[1].(*Module) vendor := mod[1].(*Module)
vendor.Properties.UseVndk = true vendor.Properties.UseVndk = true
squashVendorSrcs(vendor) squashVendorSrcs(vendor)
} else if mctx.Vendor() && m.Properties.Sdk_version == "" { } else if mctx.InstallOnVendorPartition() && m.Properties.Sdk_version == "" {
// This will be available in /vendor only // This will be available in /vendor only
mod := mctx.CreateVariations(vendorMode) mod := mctx.CreateVariations(vendorMode)
vendor := mod[0].(*Module) vendor := mod[0].(*Module)
@@ -1396,8 +1399,8 @@ outer:
return list[:k] return list[:k]
} }
// lastUniqueElements returns all unique elements of a slice, keeping the last copy of each // lastUniqueElements returns all unique elements of a slice, keeping the last copy of each.
// modifies the slice contents in place, and returns a subslice of the original slice // It modifies the slice contents in place, and returns a subslice of the original slice
func lastUniqueElements(list []string) []string { func lastUniqueElements(list []string) []string {
totalSkip := 0 totalSkip := 0
for i := len(list) - 1; i >= totalSkip; i-- { for i := len(list) - 1; i >= totalSkip; i-- {

View File

@@ -236,7 +236,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String()) flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String()) flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
if !(ctx.sdk() || ctx.vndk()) || ctx.Host() { if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}", "${config.CommonGlobalIncludes}",
tc.IncludeFlags(), tc.IncludeFlags(),
@@ -244,7 +244,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
} }
} }
if ctx.sdk() { if ctx.useSdk() {
// The NDK headers are installed to a common sysroot. While a more // The NDK headers are installed to a common sysroot. While a more
// typical Soong approach would be to only make the headers for the // typical Soong approach would be to only make the headers for the
// library you're using available, we're trying to emulate the NDK // library you're using available, we're trying to emulate the NDK
@@ -272,7 +272,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, "-isystem "+legacyIncludes) flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, "-isystem "+legacyIncludes)
} }
if ctx.vndk() { if ctx.useVndk() {
flags.GlobalFlags = append(flags.GlobalFlags, flags.GlobalFlags = append(flags.GlobalFlags,
"-D__ANDROID_API__=__ANDROID_API_FUTURE__", "-D__ANDROID_VNDK__") "-D__ANDROID_API__=__ANDROID_API_FUTURE__", "-D__ANDROID_VNDK__")
} }
@@ -366,7 +366,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainCflags()) flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainCflags())
} }
if !ctx.sdk() { if !ctx.useSdk() {
cStd := config.CStdVersion cStd := config.CStdVersion
if compiler.Properties.C_std == "experimental" { if compiler.Properties.C_std == "experimental" {
cStd = config.ExperimentalCStdVersion cStd = config.ExperimentalCStdVersion
@@ -405,7 +405,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...) flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...)
} }
if ctx.vndk() { if ctx.useVndk() {
flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...) flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
} }
@@ -478,7 +478,7 @@ func (compiler *baseCompiler) hasSrcExt(ext string) bool {
var gnuToCReplacer = strings.NewReplacer("gnu", "c") var gnuToCReplacer = strings.NewReplacer("gnu", "c")
func ndkPathDeps(ctx ModuleContext) android.Paths { func ndkPathDeps(ctx ModuleContext) android.Paths {
if ctx.sdk() { if ctx.useSdk() {
// The NDK sysroot timestamp file depends on all the NDK sysroot files // The NDK sysroot timestamp file depends on all the NDK sysroot files
// (headers and libraries). // (headers and libraries).
return android.Paths{getNdkSysrootTimestampFile(ctx)} return android.Paths{getNdkSysrootTimestampFile(ctx)}

View File

@@ -69,7 +69,7 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath
if !ctx.Host() && !ctx.Arch().Native { if !ctx.Host() && !ctx.Arch().Native {
dir = filepath.Join(dir, ctx.Arch().ArchType.String()) dir = filepath.Join(dir, ctx.Arch().ArchType.String())
} }
if installer.location == InstallInData && ctx.vndk() { if installer.location == InstallInData && ctx.useVndk() {
dir = filepath.Join(dir, "vendor") dir = filepath.Join(dir, "vendor")
} }
return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative) return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative)

View File

@@ -156,7 +156,7 @@ type flagExporter struct {
} }
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
if ctx.vndk() && f.Properties.Target.Vendor.Export_include_dirs != nil { if ctx.useVndk() && f.Properties.Target.Vendor.Export_include_dirs != nil {
return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs) return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs)
} else { } else {
return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs) return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
@@ -435,7 +435,7 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...) deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
} else if library.shared() { } else if library.shared() {
if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) { if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
if !ctx.sdk() { if !ctx.useSdk() {
deps.CrtBegin = "crtbegin_so" deps.CrtBegin = "crtbegin_so"
deps.CrtEnd = "crtend_so" deps.CrtEnd = "crtend_so"
} else { } else {
@@ -698,7 +698,7 @@ func (library *libraryDecorator) toc() android.OptionalPath {
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() { if library.shared() {
if ctx.Device() { if ctx.Device() {
if ctx.vndk() { if ctx.useVndk() {
if ctx.isVndkSp() { if ctx.isVndkSp() {
library.baseInstaller.subDir = "vndk-sp" library.baseInstaller.subDir = "vndk-sp"
} else if ctx.isVndk() { } else if ctx.isVndk() {

View File

@@ -132,7 +132,7 @@ func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, linker.Properties.Export_shared_lib_headers...) deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, linker.Properties.Export_shared_lib_headers...)
deps.ReexportGeneratedHeaders = append(deps.ReexportGeneratedHeaders, linker.Properties.Export_generated_headers...) deps.ReexportGeneratedHeaders = append(deps.ReexportGeneratedHeaders, linker.Properties.Export_generated_headers...)
if ctx.vndk() { if ctx.useVndk() {
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs)
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs)
} }
@@ -174,7 +174,7 @@ func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
} }
deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...) deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...)
} else if ctx.sdk() || ctx.vndk() { } else if ctx.useSdk() || ctx.useVndk() {
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl") deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
} }
} }
@@ -242,7 +242,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
} }
} }
if ctx.sdk() && (ctx.Arch().ArchType != android.Mips && ctx.Arch().ArchType != android.Mips64) { if ctx.useSdk() && (ctx.Arch().ArchType != android.Mips && ctx.Arch().ArchType != android.Mips64) {
// The bionic linker now has support gnu style hashes (which are much faster!), but shipping // The bionic linker now has support gnu style hashes (which are much faster!), but shipping
// to older devices requires the old style hash. Fortunately, we can build with both and // to older devices requires the old style hash. Fortunately, we can build with both and
// it'll work anywhere. // it'll work anywhere.

View File

@@ -43,7 +43,7 @@ func objectFactory() android.Module {
} }
func (object *objectLinker) appendLdflags(flags []string) { func (object *objectLinker) appendLdflags(flags []string) {
panic(fmt.Errorf("appendLdflags on object Linker not supported")) panic(fmt.Errorf("appendLdflags on objectLinker not supported"))
} }
func (object *objectLinker) linkerProps() []interface{} { func (object *objectLinker) linkerProps() []interface{} {

View File

@@ -60,14 +60,14 @@ func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, sta
switch proptools.String(p.Proto.Type) { switch proptools.String(p.Proto.Type) {
case "full": case "full":
if ctx.sdk() { if ctx.useSdk() {
lib = "libprotobuf-cpp-full-ndk" lib = "libprotobuf-cpp-full-ndk"
static = true static = true
} else { } else {
lib = "libprotobuf-cpp-full" lib = "libprotobuf-cpp-full"
} }
case "lite", "": case "lite", "":
if ctx.sdk() { if ctx.useSdk() {
lib = "libprotobuf-cpp-lite-ndk" lib = "libprotobuf-cpp-lite-ndk"
static = true static = true
} else { } else {

View File

@@ -56,7 +56,7 @@ func (p *relocationPacker) packingInit(ctx BaseModuleContext) {
if ctx.AConfig().Getenv("DISABLE_RELOCATION_PACKER") == "true" { if ctx.AConfig().Getenv("DISABLE_RELOCATION_PACKER") == "true" {
enabled = false enabled = false
} }
if ctx.sdk() { if ctx.useSdk() {
enabled = false enabled = false
} }
if p.Properties.Pack_relocations != nil && if p.Properties.Pack_relocations != nil &&

View File

@@ -82,7 +82,7 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str
func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) Flags { func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) Flags {
targetApi := proptools.String(properties.Renderscript.Target_api) targetApi := proptools.String(properties.Renderscript.Target_api)
if targetApi == "" && ctx.sdk() { if targetApi == "" && ctx.useSdk() {
switch ctx.sdkVersion() { switch ctx.sdkVersion() {
case "current", "system_current", "test_current": case "current", "system_current", "test_current":
// Nothing // Nothing

View File

@@ -79,7 +79,7 @@ func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
func sabiDepsMutator(mctx android.TopDownMutatorContext) { func sabiDepsMutator(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && if c, ok := mctx.Module().(*Module); ok &&
((c.isVndk() && c.vndk()) || inList(c.Name(), llndkLibraries) || ((c.isVndk() && c.useVndk()) || inList(c.Name(), llndkLibraries) ||
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) { (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
mctx.VisitDirectDeps(func(m blueprint.Module) { mctx.VisitDirectDeps(func(m blueprint.Module) {
tag := mctx.OtherModuleDependencyTag(m) tag := mctx.OtherModuleDependencyTag(m)

View File

@@ -128,7 +128,7 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s := &sanitize.Properties.Sanitize s := &sanitize.Properties.Sanitize
// Don't apply sanitizers to NDK code. // Don't apply sanitizers to NDK code.
if ctx.sdk() { if ctx.useSdk() {
s.Never = true s.Never = true
} }
@@ -421,7 +421,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
// When linking against VNDK, use the vendor variant of the runtime lib // When linking against VNDK, use the vendor variant of the runtime lib
sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary
if ctx.vndk() { if ctx.useVndk() {
sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix
} }
} }

View File

@@ -42,7 +42,7 @@ func (stl *stl) begin(ctx BaseModuleContext) {
if stl.Properties.Stl != nil { if stl.Properties.Stl != nil {
s = *stl.Properties.Stl s = *stl.Properties.Stl
} }
if ctx.sdk() && ctx.Device() { if ctx.useSdk() && ctx.Device() {
switch s { switch s {
case "": case "":
return "ndk_system" return "ndk_system"

View File

@@ -157,7 +157,7 @@ func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
if test.gtest() { if test.gtest() {
if ctx.sdk() && ctx.Device() { if ctx.useSdk() && ctx.Device() {
switch ctx.selectedStl() { switch ctx.selectedStl() {
case "ndk_libc++_shared", "ndk_libc++_static": case "ndk_libc++_shared", "ndk_libc++_static":
deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_libcxx", "libgtest_ndk_libcxx") deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_libcxx", "libgtest_ndk_libcxx")