Merge "Add comments about sysprop_library"
This commit is contained in:
5
cc/cc.go
5
cc/cc.go
@@ -1857,6 +1857,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
return
|
||||
}
|
||||
|
||||
// sysprop_library has to support both C++ and Java. So sysprop_library internally creates one
|
||||
// C++ implementation library and one Java implementation library. When a module links against
|
||||
// sysprop_library, the C++ implementation library has to be linked. syspropImplLibraries is a
|
||||
// map from sysprop_library to implementation library; it will be used in whole_static_libs,
|
||||
// static_libs, and shared_libs.
|
||||
syspropImplLibraries := syspropImplLibraries(actx.Config())
|
||||
vendorSnapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
|
||||
|
||||
|
@@ -1202,15 +1202,21 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
||||
}
|
||||
}
|
||||
|
||||
// If the library is sysprop_library, expose either public or internal header selectively.
|
||||
if library.baseCompiler.hasSrcExt(".sysprop") {
|
||||
dir := android.PathForModuleGen(ctx, "sysprop", "include")
|
||||
if library.Properties.Sysprop.Platform != nil {
|
||||
isProduct := ctx.ProductSpecific() && !ctx.useVndk()
|
||||
isVendor := ctx.useVndk()
|
||||
isClientProduct := ctx.ProductSpecific() && !ctx.useVndk()
|
||||
isClientVendor := ctx.useVndk()
|
||||
isOwnerPlatform := Bool(library.Properties.Sysprop.Platform)
|
||||
|
||||
// If the owner is different from the user, expose public header. That is,
|
||||
// 1) if the user is product (as owner can only be platform / vendor)
|
||||
// 2) if one is platform and the other is vendor
|
||||
// Exceptions are ramdisk and recovery. They are not enforced at all. So
|
||||
// they always use internal header.
|
||||
if !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() &&
|
||||
(isProduct || (isOwnerPlatform == isVendor)) {
|
||||
(isClientProduct || (isOwnerPlatform == isClientVendor)) {
|
||||
dir = android.PathForModuleGen(ctx, "sysprop/public", "include")
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,25 @@
|
||||
|
||||
package cc
|
||||
|
||||
// This file contains a map to redirect dependencies towards sysprop_library.
|
||||
// As sysprop_library has to support both Java and C++, sysprop_library internally
|
||||
// generates cc_library and java_library. For example, the following sysprop_library
|
||||
//
|
||||
// sysprop_library {
|
||||
// name: "foo",
|
||||
// }
|
||||
//
|
||||
// will internally generate with prefix "lib"
|
||||
//
|
||||
// cc_library {
|
||||
// name: "libfoo",
|
||||
// }
|
||||
//
|
||||
// When a cc module links against "foo", build system will redirect the
|
||||
// dependency to "libfoo". To do that, SyspropMutator gathers all sysprop_library,
|
||||
// records their cc implementation library names to a map. The map will be used in
|
||||
// cc.Module.DepsMutator.
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
@@ -22,7 +41,7 @@ import (
|
||||
|
||||
type syspropLibraryInterface interface {
|
||||
BaseModuleName() string
|
||||
CcModuleName() string
|
||||
CcImplementationModuleName() string
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -43,6 +62,8 @@ func SyspropMutator(mctx android.BottomUpMutatorContext) {
|
||||
syspropImplLibrariesLock.Lock()
|
||||
defer syspropImplLibrariesLock.Unlock()
|
||||
|
||||
syspropImplLibraries[m.BaseModuleName()] = m.CcModuleName()
|
||||
// BaseModuleName is the name of sysprop_library
|
||||
// CcImplementationModuleName is the name of cc_library generated by sysprop_library
|
||||
syspropImplLibraries[m.BaseModuleName()] = m.CcImplementationModuleName()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user