Loading apex/apex.go +18 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 } Loading Loading @@ -2403,6 +2414,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { vctx := visitorContext{ 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) Loading apex/apex_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
apex/apex.go +18 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 } Loading Loading @@ -2403,6 +2414,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { vctx := visitorContext{ 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) Loading
apex/apex_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -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