diff options
author | 2024-02-16 15:35:03 +0900 | |
---|---|---|
committer | 2024-02-16 15:35:03 +0900 | |
commit | 06c4cdcf87818cc48b723d5c47f617ca1c6e032a (patch) | |
tree | 2ad266b35c84830f49555292281d0efa9802b532 | |
parent | f617e18741a070ed1ff2bed2074ff98ccd30cb94 (diff) |
bpf modules can be included in filesystem modules
Bug: 322246536
Test: go test ./...
Change-Id: I5f29258e45475b30cdb26014c2db147182ec52fa
-rw-r--r-- | bpf/bpf.go | 9 | ||||
-rw-r--r-- | filesystem/Android.bp | 1 | ||||
-rw-r--r-- | filesystem/filesystem_test.go | 20 |
3 files changed, 30 insertions, 0 deletions
diff --git a/bpf/bpf.go b/bpf/bpf.go index e1b512f20..38fbd8804 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -203,6 +203,15 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { } } + + installDir := android.PathForModuleInstall(ctx, "etc", "bpf") + if len(bpf.properties.Sub_dir) > 0 { + installDir = installDir.Join(ctx, bpf.properties.Sub_dir) + } + for _, obj := range bpf.objs { + ctx.PackageFile(installDir, obj.Base(), obj) + } + android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()}) } diff --git a/filesystem/Android.bp b/filesystem/Android.bp index 07d57c915..cdf668238 100644 --- a/filesystem/Android.bp +++ b/filesystem/Android.bp @@ -9,6 +9,7 @@ bootstrap_go_package { "blueprint", "soong", "soong-android", + "soong-bpf", // for testing "soong-linkerconfig", ], srcs: [ diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index aef475650..7547ff819 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -19,6 +19,7 @@ import ( "testing" "android/soong/android" + "android/soong/bpf" "android/soong/cc" "android/soong/etc" @@ -31,6 +32,7 @@ func TestMain(m *testing.M) { var fixture = android.GroupFixturePreparers( android.PrepareForIntegrationTestWithAndroid, + bpf.PrepareForTestWithBpf, etc.PrepareForTestWithPrebuiltEtc, cc.PrepareForIntegrationTestWithCc, PrepareForTestWithFilesystemBuildComponents, @@ -40,11 +42,29 @@ func TestFileSystemDeps(t *testing.T) { result := fixture.RunTestWithBp(t, ` android_filesystem { name: "myfilesystem", + multilib: { + common: { + deps: [ + "bpf.o", + ], + }, + }, + } + + bpf { + name: "bpf.o", + srcs: ["bpf.c"], } `) // produces "myfilesystem.img" result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img") + + fs := result.ModuleForTests("myfilesystem", "android_common").Module().(*filesystem) + expected := []string{"etc/bpf/bpf.o"} + for _, e := range expected { + android.AssertStringListContains(t, "missing entry", fs.entries, e) + } } func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) { |