Loading apex/apex.go +4 −3 Original line number Diff line number Diff line Loading @@ -1612,8 +1612,8 @@ func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.R return af } func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile { dirInApex := filepath.Join("etc", "bpf") func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, apex_sub_dir string, bpfProgram bpf.BpfModule) apexFile { dirInApex := filepath.Join("etc", "bpf", apex_sub_dir) return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) } Loading Loading @@ -1831,8 +1831,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { case bpfTag: if bpfProgram, ok := child.(bpf.BpfModule); ok { filesToCopy, _ := bpfProgram.OutputFiles("") apex_sub_dir := bpfProgram.SubDir() for _, bpfFile := range filesToCopy { filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, apex_sub_dir, bpfProgram)) } } else { ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) Loading apex/apex_test.go +8 −1 Original line number Diff line number Diff line Loading @@ -623,7 +623,7 @@ func TestDefaults(t *testing.T) { java_libs: ["myjar"], apps: ["AppFoo"], rros: ["rro"], bpfs: ["bpf"], bpfs: ["bpf", "netd_test"], updatable: false, } Loading Loading @@ -676,6 +676,12 @@ func TestDefaults(t *testing.T) { srcs: ["bpf.c", "bpf2.c"], } bpf { name: "netd_test", srcs: ["netd_test.c"], sub_dir: "netd", } `) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ "etc/myetc", Loading @@ -685,6 +691,7 @@ func TestDefaults(t *testing.T) { "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", "etc/bpf/netd/netd_test.o", }) } Loading bpf/bpf.go +13 −1 Original line number Diff line number Diff line Loading @@ -54,12 +54,16 @@ type BpfModule interface { android.Module OutputFiles(tag string) (android.Paths, error) // Returns the sub install directory if the bpf module is included by apex. SubDir() string } type BpfProperties struct { Srcs []string `android:"path"` Cflags []string Include_dirs []string Sub_dir string } type bpf struct { Loading Loading @@ -121,6 +125,10 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w) fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w) localModulePath := "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf" if len(bpf.properties.Sub_dir) > 0 { localModulePath += "/" + bpf.properties.Sub_dir } for _, obj := range bpf.objs { objName := name + "_" + obj.Base() names = append(names, objName) Loading @@ -130,7 +138,7 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", obj.String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", obj.Base()) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf") fmt.Fprintln(w, localModulePath) fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w) } Loading @@ -154,6 +162,10 @@ func (bpf *bpf) OutputFiles(tag string) (android.Paths, error) { } } func (bpf *bpf) SubDir() string { return bpf.properties.Sub_dir } var _ android.OutputFileProducer = (*bpf)(nil) func BpfFactory() android.Module { Loading Loading
apex/apex.go +4 −3 Original line number Diff line number Diff line Loading @@ -1612,8 +1612,8 @@ func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.R return af } func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile { dirInApex := filepath.Join("etc", "bpf") func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, apex_sub_dir string, bpfProgram bpf.BpfModule) apexFile { dirInApex := filepath.Join("etc", "bpf", apex_sub_dir) return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) } Loading Loading @@ -1831,8 +1831,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { case bpfTag: if bpfProgram, ok := child.(bpf.BpfModule); ok { filesToCopy, _ := bpfProgram.OutputFiles("") apex_sub_dir := bpfProgram.SubDir() for _, bpfFile := range filesToCopy { filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, apex_sub_dir, bpfProgram)) } } else { ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) Loading
apex/apex_test.go +8 −1 Original line number Diff line number Diff line Loading @@ -623,7 +623,7 @@ func TestDefaults(t *testing.T) { java_libs: ["myjar"], apps: ["AppFoo"], rros: ["rro"], bpfs: ["bpf"], bpfs: ["bpf", "netd_test"], updatable: false, } Loading Loading @@ -676,6 +676,12 @@ func TestDefaults(t *testing.T) { srcs: ["bpf.c", "bpf2.c"], } bpf { name: "netd_test", srcs: ["netd_test.c"], sub_dir: "netd", } `) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ "etc/myetc", Loading @@ -685,6 +691,7 @@ func TestDefaults(t *testing.T) { "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", "etc/bpf/netd/netd_test.o", }) } Loading
bpf/bpf.go +13 −1 Original line number Diff line number Diff line Loading @@ -54,12 +54,16 @@ type BpfModule interface { android.Module OutputFiles(tag string) (android.Paths, error) // Returns the sub install directory if the bpf module is included by apex. SubDir() string } type BpfProperties struct { Srcs []string `android:"path"` Cflags []string Include_dirs []string Sub_dir string } type bpf struct { Loading Loading @@ -121,6 +125,10 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w) fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w) localModulePath := "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf" if len(bpf.properties.Sub_dir) > 0 { localModulePath += "/" + bpf.properties.Sub_dir } for _, obj := range bpf.objs { objName := name + "_" + obj.Base() names = append(names, objName) Loading @@ -130,7 +138,7 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", obj.String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", obj.Base()) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf") fmt.Fprintln(w, localModulePath) fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w) } Loading @@ -154,6 +162,10 @@ func (bpf *bpf) OutputFiles(tag string) (android.Paths, error) { } } func (bpf *bpf) SubDir() string { return bpf.properties.Sub_dir } var _ android.OutputFileProducer = (*bpf)(nil) func BpfFactory() android.Module { Loading