Merge "target.apex.exclude_[shared|static]_libs to cc_* modules" am: 35989ae98b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1515154 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I596352345cc480a9f95809999edf2052183d85d3
This commit is contained in:
13
apex/apex.go
13
apex/apex.go
@@ -1689,6 +1689,19 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// Don't track further
|
// Don't track further
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the dep is not considered to be in the same
|
||||||
|
// apex, don't add it to filesInfo so that it is not
|
||||||
|
// included in this APEX.
|
||||||
|
// TODO(jiyong): move this to at the top of the
|
||||||
|
// else-if clause for the indirect dependencies.
|
||||||
|
// Currently, that's impossible because we would
|
||||||
|
// like to record requiredNativeLibs even when
|
||||||
|
// DepIsInSameAPex is false.
|
||||||
|
if !am.DepIsInSameApex(ctx, am) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
filesInfo = append(filesInfo, af)
|
filesInfo = append(filesInfo, af)
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
}
|
}
|
||||||
|
@@ -6306,6 +6306,55 @@ func TestPreferredPrebuiltSharedLibDep(t *testing.T) {
|
|||||||
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherlib\n")
|
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherlib\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExcludeDependency(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
apex_available: ["myapex"],
|
||||||
|
shared_libs: ["mylib2"],
|
||||||
|
target: {
|
||||||
|
apex: {
|
||||||
|
exclude_shared_libs: ["mylib2"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib2",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
// Check if mylib is linked to mylib2 for the non-apex target
|
||||||
|
ldFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared").Rule("ld").Args["libFlags"]
|
||||||
|
ensureContains(t, ldFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
|
||||||
|
|
||||||
|
// Make sure that the link doesn't occur for the apex target
|
||||||
|
ldFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000").Rule("ld").Args["libFlags"]
|
||||||
|
ensureNotContains(t, ldFlags, "mylib2/android_arm64_armv8-a_shared_apex10000/mylib2.so")
|
||||||
|
|
||||||
|
// It shouldn't appear in the copy cmd as well.
|
||||||
|
copyCmds := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule").Args["copy_commands"]
|
||||||
|
ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
|
||||||
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
run := func() int {
|
run := func() int {
|
||||||
setUp()
|
setUp()
|
||||||
|
21
cc/cc.go
21
cc/cc.go
@@ -129,6 +129,9 @@ type Deps struct {
|
|||||||
// Used for host bionic
|
// Used for host bionic
|
||||||
LinkerFlagsFile string
|
LinkerFlagsFile string
|
||||||
DynamicLinker string
|
DynamicLinker string
|
||||||
|
|
||||||
|
// List of libs that need to be excluded for APEX variant
|
||||||
|
ExcludeLibsForApex []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathDeps is a struct containing file paths to dependencies of a module.
|
// PathDeps is a struct containing file paths to dependencies of a module.
|
||||||
@@ -577,6 +580,9 @@ type libraryDependencyTag struct {
|
|||||||
staticUnwinder bool
|
staticUnwinder bool
|
||||||
|
|
||||||
makeSuffix string
|
makeSuffix string
|
||||||
|
|
||||||
|
// Whether or not this dependency has to be followed for the apex variants
|
||||||
|
excludeInApex bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// header returns true if the libraryDependencyTag is tagging a header lib dependency.
|
// header returns true if the libraryDependencyTag is tagging a header lib dependency.
|
||||||
@@ -1955,6 +1961,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
if inList(lib, deps.ReexportStaticLibHeaders) {
|
if inList(lib, deps.ReexportStaticLibHeaders) {
|
||||||
depTag.reexportFlags = true
|
depTag.reexportFlags = true
|
||||||
}
|
}
|
||||||
|
if inList(lib, deps.ExcludeLibsForApex) {
|
||||||
|
depTag.excludeInApex = true
|
||||||
|
}
|
||||||
|
|
||||||
if impl, ok := syspropImplLibraries[lib]; ok {
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
||||||
lib = impl
|
lib = impl
|
||||||
@@ -1992,6 +2001,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
if inList(lib, deps.ReexportSharedLibHeaders) {
|
if inList(lib, deps.ReexportSharedLibHeaders) {
|
||||||
depTag.reexportFlags = true
|
depTag.reexportFlags = true
|
||||||
}
|
}
|
||||||
|
if inList(lib, deps.ExcludeLibsForApex) {
|
||||||
|
depTag.excludeInApex = true
|
||||||
|
}
|
||||||
|
|
||||||
if impl, ok := syspropImplLibraries[lib]; ok {
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
||||||
lib = impl
|
lib = impl
|
||||||
@@ -2421,6 +2433,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !apexInfo.IsForPlatform() && libDepTag.excludeInApex {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||||
|
|
||||||
var ptr *android.Paths
|
var ptr *android.Paths
|
||||||
@@ -2440,6 +2456,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
|
sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
|
||||||
sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo)
|
sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo)
|
||||||
|
|
||||||
@@ -3014,6 +3031,10 @@ func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
|||||||
// linked; the dependency is used only during the compilation phase.
|
// linked; the dependency is used only during the compilation phase.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isLibDepTag && libDepTag.excludeInApex {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if depTag == stubImplDepTag || depTag == llndkImplDep {
|
if depTag == stubImplDepTag || depTag == llndkImplDep {
|
||||||
// We don't track beyond LLNDK or from an implementation library to its stubs.
|
// We don't track beyond LLNDK or from an implementation library to its stubs.
|
||||||
|
19
cc/linker.go
19
cc/linker.go
@@ -174,6 +174,15 @@ type BaseLinkerProperties struct {
|
|||||||
// variants.
|
// variants.
|
||||||
Shared_libs []string
|
Shared_libs []string
|
||||||
}
|
}
|
||||||
|
Apex struct {
|
||||||
|
// list of shared libs that should not be used to build the apex variant of
|
||||||
|
// the C/C++ module.
|
||||||
|
Exclude_shared_libs []string
|
||||||
|
|
||||||
|
// list of static libs that should not be used to build the apex ramdisk
|
||||||
|
// variant of the C/C++ module.
|
||||||
|
Exclude_static_libs []string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make android::build:GetBuildNumber() available containing the build ID.
|
// make android::build:GetBuildNumber() available containing the build ID.
|
||||||
@@ -240,6 +249,16 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Exclude_static_libs)
|
deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Exclude_static_libs)
|
||||||
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Exclude_static_libs)
|
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Exclude_static_libs)
|
||||||
|
|
||||||
|
// Record the libraries that need to be excluded when building for APEX. Unlike other
|
||||||
|
// target.*.exclude_* properties, SharedLibs and StaticLibs are not modified here because
|
||||||
|
// this module hasn't yet passed the apexMutator. Therefore, we can't tell whether this is
|
||||||
|
// an apex variant of not. Record the exclude list in the deps struct for now. The info is
|
||||||
|
// used to mark the dependency tag when adding dependencies to the deps. Then inside
|
||||||
|
// GenerateAndroidBuildActions, the marked dependencies are ignored (i.e. not used) for APEX
|
||||||
|
// variants.
|
||||||
|
deps.ExcludeLibsForApex = append(deps.ExcludeLibsForApex, linker.Properties.Target.Apex.Exclude_shared_libs...)
|
||||||
|
deps.ExcludeLibsForApex = append(deps.ExcludeLibsForApex, linker.Properties.Target.Apex.Exclude_static_libs...)
|
||||||
|
|
||||||
if Bool(linker.Properties.Use_version_lib) {
|
if Bool(linker.Properties.Use_version_lib) {
|
||||||
deps.WholeStaticLibs = append(deps.WholeStaticLibs, "libbuildversion")
|
deps.WholeStaticLibs = append(deps.WholeStaticLibs, "libbuildversion")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user