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
diff --git a/apex/apex.go b/apex/apex.go
index e1fca67..6bafcae 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -117,9 +117,6 @@
// 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 @@
// 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 @@
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 @@
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
diff --git a/apex/apex_test.go b/apex/apex_test.go
index f07bf63..67f7722 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -6034,6 +6034,7 @@
name: "myapex",
key: "myapex.key",
apps: ["app"],
+ bpfs: ["bpf"],
overrides: ["oldapex"],
updatable: false,
}
@@ -6042,6 +6043,7 @@
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 @@
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 @@
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 @@
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")