Merge changes from topic "unwanted-transitive-deps" into main am: 26464230a1
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2812759 Change-Id: Ia1314ea27eb5779e51cf96174c1aaa995d8587b4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7e23a55102
2 changed files with 54 additions and 6 deletions
24
apex/apex.go
24
apex/apex.go
|
@ -135,6 +135,11 @@ type apexBundleProperties struct {
|
|||
// List of filesystem images that are embedded inside this APEX bundle.
|
||||
Filesystems []string
|
||||
|
||||
// List of module names which we don't want to add as transitive deps. This can be used as
|
||||
// a workaround when the current implementation collects more than necessary. For example,
|
||||
// Rust binaries with prefer_rlib:true add unnecessary dependencies.
|
||||
Unwanted_transitive_deps []string
|
||||
|
||||
// The minimum SDK version that this APEX must support at minimum. This is usually set to
|
||||
// the SDK version that the APEX was first introduced.
|
||||
Min_sdk_version *string
|
||||
|
@ -2003,11 +2008,21 @@ type visitorContext struct {
|
|||
|
||||
// if true, raise error on duplicate apexFile
|
||||
checkDuplicate bool
|
||||
|
||||
// visitor skips these from this list of module names
|
||||
unwantedTransitiveDeps []string
|
||||
}
|
||||
|
||||
func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) {
|
||||
encountered := make(map[string]apexFile)
|
||||
for _, f := range vctx.filesInfo {
|
||||
// Skips unwanted transitive deps. This happens, for example, with Rust binaries with prefer_rlib:true.
|
||||
// TODO(b/295593640)
|
||||
// Needs additional verification for the resulting APEX to ensure that skipped artifacts don't make problems.
|
||||
// For example, DT_NEEDED modules should be found within the APEX unless they are marked in `requiredNativeLibs`.
|
||||
if f.transitiveDep && f.module != nil && android.InList(mctx.OtherModuleName(f.module), vctx.unwantedTransitiveDeps) {
|
||||
continue
|
||||
}
|
||||
dest := filepath.Join(f.installDir, f.builtFile.Base())
|
||||
if e, ok := encountered[dest]; !ok {
|
||||
encountered[dest] = f
|
||||
|
@ -2371,10 +2386,6 @@ func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool {
|
|||
if a.properties.IsCoverageVariant {
|
||||
return false
|
||||
}
|
||||
// TODO(b/263308515) remove this
|
||||
if a.testApex {
|
||||
return false
|
||||
}
|
||||
if ctx.DeviceConfig().DeviceArch() == "" {
|
||||
return false
|
||||
}
|
||||
|
@ -2401,8 +2412,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
// TODO(jiyong): do this using WalkPayloadDeps
|
||||
// TODO(jiyong): make this clean!!!
|
||||
vctx := visitorContext{
|
||||
handleSpecialLibs: !android.Bool(a.properties.Ignore_system_library_special_case),
|
||||
checkDuplicate: a.shouldCheckDuplicate(ctx),
|
||||
handleSpecialLibs: !android.Bool(a.properties.Ignore_system_library_special_case),
|
||||
checkDuplicate: a.shouldCheckDuplicate(ctx),
|
||||
unwantedTransitiveDeps: a.properties.Unwanted_transitive_deps,
|
||||
}
|
||||
ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { return a.depVisitor(&vctx, ctx, child, parent) })
|
||||
vctx.normalizeFileInfo(ctx)
|
||||
|
|
|
@ -7709,6 +7709,42 @@ func TestNoDupeApexFiles(t *testing.T) {
|
|||
`)
|
||||
}
|
||||
|
||||
func TestApexUnwantedTransitiveDeps(t *testing.T) {
|
||||
bp := `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["libfoo"],
|
||||
updatable: false,
|
||||
unwanted_transitive_deps: ["libbar"],
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libfoo",
|
||||
srcs: ["foo.cpp"],
|
||||
shared_libs: ["libbar"],
|
||||
apex_available: ["myapex"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libbar",
|
||||
srcs: ["bar.cpp"],
|
||||
apex_available: ["myapex"],
|
||||
}`
|
||||
ctx := testApex(t, bp)
|
||||
ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{
|
||||
"*/libc++.so",
|
||||
"*/libfoo.so",
|
||||
// not libbar.so
|
||||
})
|
||||
}
|
||||
|
||||
func TestRejectNonInstallableJavaLibrary(t *testing.T) {
|
||||
testApexError(t, `"myjar" is not configured to be compiled into dex`, `
|
||||
apex {
|
||||
|
|
Loading…
Reference in a new issue