Merge "Revert "Some clarifications in preparation to automatically order linker dependencies""

This commit is contained in:
Jeff Gaston 2017-10-04 21:09:29 +00:00 committed by Gerrit Code Review
commit 60e38b613f
12 changed files with 189 additions and 197 deletions

View file

@ -99,11 +99,7 @@ type ModuleContext interface {
type Module interface {
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)
DepsMutator(BottomUpMutatorContext)
base() *ModuleBase

View file

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

View file

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

View file

@ -219,7 +219,7 @@ type builderFlags struct {
arFlags string
asFlags string
cFlags string
toolingCFlags string // A separate set of Cflags for clang LibTooling tools
toolingCFlags string // Seperate set of Cflags for clang LibTooling tools
conlyFlags string
cppFlags 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,
// and shared libraries, to a shared library (.so) or dynamic executable
// and shared libraires, to a shared library (.so) or dynamic executable
func TransformObjToDynamicBinary(ctx android.ModuleContext,
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
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)
}
// Generate a rule for extracting a table of contents from a shared library (.so)
func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Path,
// Generate a rule for extract a table of contents from a shared library (.so)
func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.WritablePath,
outputFile android.WritablePath, flags builderFlags) {
crossCompile := gccCmd(flags.toolchain, "")

327
cc/cc.go
View file

@ -194,7 +194,7 @@ type ModuleContextIntf interface {
noDefaultCompilerFlags() bool
sdk() bool
sdkVersion() string
useVndk() bool
vndk() bool
isVndk() bool
isVndkSp() bool
createVndkSourceAbiDump() bool
@ -377,7 +377,7 @@ func (c *Module) isDependencyRoot() bool {
return false
}
func (c *Module) useVndk() bool {
func (c *Module) vndk() bool {
return c.Properties.UseVndk
}
@ -403,8 +403,10 @@ type moduleContext struct {
moduleContextImpl
}
func (ctx *moduleContext) InstallOnVendorPartition() bool {
return ctx.ModuleContext.Vendor() || (ctx.mod.useVndk() && !ctx.mod.isVndk())
// Vendor returns true for vendor modules excluding VNDK libraries so that
// they get installed onto the correct partition
func (ctx *moduleContext) Vendor() bool {
return ctx.ModuleContext.Vendor() || (ctx.mod.vndk() && !ctx.mod.isVndk())
}
type moduleContextImpl struct {
@ -443,7 +445,7 @@ func (ctx *moduleContextImpl) noDefaultCompilerFlags() bool {
}
func (ctx *moduleContextImpl) sdk() bool {
if ctx.ctx.Device() && !ctx.useVndk() {
if ctx.ctx.Device() && !ctx.vndk() {
return ctx.mod.Properties.Sdk_version != ""
}
return false
@ -451,7 +453,7 @@ func (ctx *moduleContextImpl) sdk() bool {
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
if ctx.useVndk() {
if ctx.vndk() {
return "current"
} else {
return ctx.mod.Properties.Sdk_version
@ -460,12 +462,13 @@ func (ctx *moduleContextImpl) sdkVersion() string {
return ""
}
func (ctx *moduleContextImpl) vndk() bool {
return ctx.mod.vndk()
}
func (ctx *moduleContextImpl) isVndk() bool {
return ctx.mod.isVndk()
}
func (ctx *moduleContextImpl) useVndk() bool {
return ctx.mod.useVndk()
}
func (ctx *moduleContextImpl) isVndkSp() bool {
if vndk := ctx.mod.vndkdep; vndk != nil {
@ -476,7 +479,7 @@ func (ctx *moduleContextImpl) isVndkSp() bool {
// Create source abi dumps if the module belongs to the list of VndkLibraries.
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
return ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
return ctx.ctx.Device() && ((ctx.vndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
}
func (ctx *moduleContextImpl) selectedStl() string {
@ -530,7 +533,6 @@ func (c *Module) Name() string {
}
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx := &moduleContext{
ModuleContext: actx,
moduleContextImpl: moduleContextImpl{
@ -762,23 +764,19 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if ctx.Os() == android.Android {
version := ctx.sdkVersion()
// rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
// of names:
// Rewrites the names of shared libraries into the names of the NDK
// libraries where appropriate. This returns two slices.
//
// 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.
// 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 first is a list of non-variant shared libraries (either rewritten
// NDK libraries to the modules in prebuilts/ndk, or not rewritten
// because they are not NDK libraries).
//
// The caller can then know to add the variantLibs dependencies differently from the
// nonvariantLibs
rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
variantLibs = []string{}
nonvariantLibs = []string{}
// The second is a list of ndk_library modules. These need to be
// separated because they are a variation dependency and must be added
// in a different manner.
rewriteNdkLibs := func(list []string) ([]string, []string) {
variantLibs := []string{}
nonvariantLibs := []string{}
for _, entry := range list {
if ctx.sdk() && inList(entry, ndkPrebuiltSharedLibraries) {
if !inList(entry, ndkMigratedLibs) {
@ -786,7 +784,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
} else {
variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
}
} else if ctx.useVndk() && inList(entry, llndkLibraries) {
} else if ctx.vndk() && inList(entry, llndkLibraries) {
nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
} else {
nonvariantLibs = append(nonvariantLibs, entry)
@ -888,118 +886,117 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
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
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
var depPaths PathDeps
ctx.VisitDirectDeps(func(dep blueprint.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
// Whether a module can link to another module, taking into
// account NDK linking.
checkLinkType := func(from, 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 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))
}
aDep, _ := dep.(android.Module)
if aDep == nil {
ctx.ModuleErrorf("module %q not an android module", depName)
// All 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)
}
}
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
}
ccDep, _ := dep.(*Module)
if ccDep == nil {
// handling for a few module types that aren't cc Module but that are also supported
switch depTag {
cc, _ := m.(*Module)
if cc == nil {
switch tag {
case android.DefaultsDepTag, android.SourceDepTag:
// Nothing to do
case genSourceDepTag:
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
genRule.GeneratedSourceFiles()...)
} else {
ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
ctx.ModuleErrorf("module %q is not a gensrcs or genrule", name)
}
// Support exported headers from a generated_sources dependency
fallthrough
case genHeaderDepTag, genHeaderExportDepTag:
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedSourceFiles()...)
flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
depPaths.Flags = append(depPaths.Flags, flags)
if depTag == genHeaderExportDepTag {
if tag == genHeaderExportDepTag {
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
genRule.GeneratedSourceFiles()...)
@ -1008,46 +1005,46 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
} else {
ctx.ModuleErrorf("module %q is not a genrule", depName)
ctx.ModuleErrorf("module %q is not a genrule", name)
}
case linkerScriptDepTag:
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
files := genRule.GeneratedSourceFiles()
if len(files) == 1 {
depPaths.LinkerScript = android.OptionalPathForPath(files[0])
} else if len(files) > 1 {
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", depName)
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", name)
}
} else {
ctx.ModuleErrorf("module %q is not a genrule", depName)
ctx.ModuleErrorf("module %q is not a genrule", name)
}
default:
ctx.ModuleErrorf("depends on non-cc module %q", depName)
ctx.ModuleErrorf("depends on non-cc module %q", name)
}
return
}
// some validation
if !aDep.Enabled() {
if !a.Enabled() {
if ctx.AConfig().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{depName})
ctx.AddMissingDependencies([]string{name})
} else {
ctx.ModuleErrorf("depends on disabled module %q", depName)
ctx.ModuleErrorf("depends on disabled module %q", name)
}
return
}
if aDep.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
if aDep.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
if a.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), name)
return
}
// re-exporting flags
if depTag == reuseObjTag {
if l, ok := ccDep.compiler.(libraryInterface); ok {
if a.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), name)
return
}
if tag == reuseObjTag {
if l, ok := cc.compiler.(libraryInterface); ok {
objs, flags, deps := l.reuseObjs()
depPaths.Objs = depPaths.Objs.Append(objs)
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
@ -1055,8 +1052,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
}
if t, ok := depTag.(dependencyTag); ok && t.library {
if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
if t, ok := tag.(dependencyTag); ok && t.library {
if i, ok := cc.linker.(exportedFlagsProducer); ok {
flags := i.exportedFlags()
deps := i.exportedFlagsDeps()
depPaths.Flags = append(depPaths.Flags, flags...)
@ -1072,38 +1070,38 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
}
checkLinkType(ctx, c, ccDep)
checkLinkType(c, cc)
}
var ptr *android.Paths
var depPtr *android.Paths
linkFile := ccDep.outputFile
linkFile := cc.outputFile
depFile := android.OptionalPath{}
switch depTag {
switch tag {
case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
ptr = &depPaths.SharedLibs
depPtr = &depPaths.SharedLibsDeps
depFile = ccDep.linker.(libraryInterface).toc()
depFile = cc.linker.(libraryInterface).toc()
case lateSharedDepTag, ndkLateStubDepTag:
ptr = &depPaths.LateSharedLibs
depPtr = &depPaths.LateSharedLibsDeps
depFile = ccDep.linker.(libraryInterface).toc()
depFile = cc.linker.(libraryInterface).toc()
case staticDepTag, staticExportDepTag:
ptr = &depPaths.StaticLibs
case lateStaticDepTag:
ptr = &depPaths.LateStaticLibs
case wholeStaticDepTag:
ptr = &depPaths.WholeStaticLibs
staticLib, ok := ccDep.linker.(libraryInterface)
staticLib, ok := cc.linker.(libraryInterface)
if !ok || !staticLib.static() {
ctx.ModuleErrorf("module %q not a static library", depName)
ctx.ModuleErrorf("module %q not a static library", name)
return
}
if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
postfix := " (required by " + ctx.OtherModuleName(m) + ")"
for i := range missingDeps {
missingDeps[i] += postfix
}
@ -1120,11 +1118,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.CrtEnd = linkFile
}
switch depTag {
switch tag {
case staticDepTag, staticExportDepTag, lateStaticDepTag:
staticLib, ok := ccDep.linker.(libraryInterface)
staticLib, ok := cc.linker.(libraryInterface)
if !ok || !staticLib.static() {
ctx.ModuleErrorf("module %q not a static library", depName)
ctx.ModuleErrorf("module %q not a static library", name)
return
}
@ -1135,12 +1133,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
staticLib.objs().coverageFiles...)
depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
staticLib.objs().sAbiDumpFiles...)
}
if ptr != nil {
if !linkFile.Valid() {
ctx.ModuleErrorf("module %q missing output file", depName)
ctx.ModuleErrorf("module %q missing output file", name)
return
}
*ptr = append(*ptr, linkFile.Path())
@ -1154,24 +1151,24 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
*depPtr = append(*depPtr, dep.Path())
}
// Export the shared libs to Make.
switch depTag {
// Export the shared libs to the make world. In doing so, .vendor suffix
// is added if the lib has both core and vendor variants and this module
// is building against vndk. This is because the vendor variant will be
// 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:
libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
libName := strings.TrimSuffix(name, llndkLibrarySuffix)
libName = strings.TrimPrefix(libName, "prebuilt_")
isLLndk := inList(libName, llndkLibraries)
var makeLibName string
bothVendorAndCoreVariantsExist := Bool(ccDep.VendorProperties.Vendor_available) || 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
if c.vndk() && (Bool(cc.VendorProperties.Vendor_available) || isLLndk) {
libName += vendorSuffix
}
// Note: the order of libs in this list is not important because
// they merely serve as Make dependencies and do not affect this lib itself.
c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, makeLibName)
// they merely serve as dependencies in the make world and do not
// affect this lib itself.
c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, libName)
}
})
@ -1368,8 +1365,8 @@ outer:
return list[:k]
}
// lastUniqueElements returns all unique elements of a slice, keeping the last copy of each.
// It modifies the slice contents in place, and returns a subslice of the original slice
// 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
func lastUniqueElements(list []string) []string {
totalSkip := 0
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.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
if !(ctx.sdk() || ctx.useVndk()) || ctx.Host() {
if !(ctx.sdk() || ctx.vndk()) || ctx.Host() {
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}",
tc.IncludeFlags(),
@ -272,7 +272,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, "-isystem "+legacyIncludes)
}
if ctx.useVndk() {
if ctx.vndk() {
flags.GlobalFlags = append(flags.GlobalFlags,
"-D__ANDROID_API__=__ANDROID_API_FUTURE__", "-D__ANDROID_VNDK__")
}
@ -405,7 +405,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...)
}
if ctx.useVndk() {
if ctx.vndk() {
flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
}
@ -490,7 +490,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
pathDeps := deps.GeneratedHeaders
pathDeps = append(pathDeps, ndkPathDeps(ctx)...)
if ctx.useVndk() {
if ctx.vndk() {
compiler.Properties.Srcs = append(compiler.Properties.Srcs,
compiler.Properties.Target.Vendor.Srcs...)

View file

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

View file

@ -155,7 +155,7 @@ type flagExporter struct {
}
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
if ctx.useVndk() && f.Properties.Target.Vendor.Export_include_dirs != nil {
if ctx.vndk() && f.Properties.Target.Vendor.Export_include_dirs != nil {
return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs)
} else {
return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
@ -697,7 +697,7 @@ func (library *libraryDecorator) toc() android.OptionalPath {
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() {
if ctx.Device() {
if ctx.useVndk() {
if ctx.vndk() {
if ctx.isVndkSp() {
library.baseInstaller.subDir = "vndk-sp"
} 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.ReexportGeneratedHeaders = append(deps.ReexportGeneratedHeaders, linker.Properties.Export_generated_headers...)
if ctx.useVndk() {
if ctx.vndk() {
deps.SharedLibs = removeListFromList(deps.SharedLibs, 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...)
} else if ctx.sdk() || ctx.useVndk() {
} else if ctx.sdk() || ctx.vndk() {
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
}
}

View file

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

View file

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

View file

@ -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
sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary
if ctx.useVndk() {
if ctx.vndk() {
sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix
}
}