Make bpfs properties overridable

To support different variable bpfs file between mainline module and
non-updatable module(e.g. Android GO). Make bpfs properties overridable.

Test: m
Bug: 190523685
Change-Id: I4c63e35f74230de94b21f3ceb2beb90f0f9ddb11
This commit is contained in:
markchien 2021-08-26 22:10:06 +08:00 committed by Mark Chien
parent 35fc86c9cf
commit 7c803b8746
2 changed files with 21 additions and 4 deletions

View file

@ -117,9 +117,6 @@ type apexBundleProperties struct {
// List of platform_compat_config files that are embedded inside this APEX bundle.
Compat_configs []string
// List of BPF programs inside this APEX bundle.
Bpfs []string
// List of filesystem images that are embedded inside this APEX bundle.
Filesystems []string
@ -297,6 +294,9 @@ type overridableProperties struct {
// List of runtime resource overlays (RROs) that are embedded inside this APEX.
Rros []string
// List of BPF programs inside this APEX bundle.
Bpfs []string
// Names of modules to be overridden. Listed modules can only be other binaries (in Make or
// Soong). This does not completely prevent installation of the overridden binaries, but if
// both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will
@ -780,7 +780,6 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
@ -813,6 +812,7 @@ func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...)
ctx.AddFarVariationDependencies(commonVariation, rroTag, a.overridableProperties.Rros...)
// Dependencies for signing

View file

@ -6034,6 +6034,7 @@ func TestOverrideApex(t *testing.T) {
name: "myapex",
key: "myapex.key",
apps: ["app"],
bpfs: ["bpf"],
overrides: ["oldapex"],
updatable: false,
}
@ -6042,6 +6043,7 @@ func TestOverrideApex(t *testing.T) {
name: "override_myapex",
base: "myapex",
apps: ["override_app"],
bpfs: ["override_bpf"],
overrides: ["unknownapex"],
logging_parent: "com.foo.bar",
package_name: "test.overridden.package",
@ -6080,6 +6082,16 @@ func TestOverrideApex(t *testing.T) {
base: "app",
package_name: "bar",
}
bpf {
name: "bpf",
srcs: ["bpf.c"],
}
bpf {
name: "override_bpf",
srcs: ["override_bpf.c"],
}
`, withManifestPackageNameOverrides([]string{"myapex:com.android.myapex"}))
originalVariant := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(android.OverridableModule)
@ -6098,6 +6110,9 @@ func TestOverrideApex(t *testing.T) {
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
ensureContains(t, copyCmds, "image.apex/app/override_app/override_app.apk")
ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o")
ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o")
apexBundle := module.Module().(*apexBundle)
name := apexBundle.Name()
if name != "override_myapex" {
@ -6120,10 +6135,12 @@ func TestOverrideApex(t *testing.T) {
data.Custom(&builder, name, "TARGET_", "", data)
androidMk := builder.String()
ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
ensureContains(t, androidMk, "LOCAL_MODULE := override_bpf.o.override_myapex")
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex")
ensureContains(t, androidMk, "LOCAL_OVERRIDES_MODULES := unknownapex myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := bpf.myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := override_app.myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")