diff options
author | 2025-02-12 06:37:16 -0800 | |
---|---|---|
committer | 2025-02-12 06:37:16 -0800 | |
commit | 1a49813031ed2829f70d0de92454ff53f4c3da84 (patch) | |
tree | a2fcd3d9f9aa5bc0fb5b489f199395bc86a17932 /apex | |
parent | 719a8807c9d47b192d9f15e0eaa7a4a248d4e17a (diff) | |
parent | 11ad4e940b342fb0bdf700276f9a7b513c3656b0 (diff) |
Merge "Install VINTF fragment modules in the APEX" into main
Diffstat (limited to 'apex')
-rw-r--r-- | apex/apex.go | 12 | ||||
-rw-r--r-- | apex/apex_test.go | 32 | ||||
-rw-r--r-- | apex/builder.go | 7 |
3 files changed, 48 insertions, 3 deletions
diff --git a/apex/apex.go b/apex/apex.go index 33538fb13..04816580d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1475,6 +1475,12 @@ func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.Platform return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) } +func apexFileForVintfFragment(ctx android.BaseModuleContext, vintfFragment *android.VintfFragmentModule) apexFile { + dirInApex := filepath.Join("etc", "vintf") + + return newApexFile(ctx, vintfFragment.OutputFile(), vintfFragment.BaseModuleName(), dirInApex, etc, vintfFragment) +} + // javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same // way. type javaModule interface { @@ -2160,7 +2166,13 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, // nothing } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName) + } else if android.IsVintfDepTag(depTag) { + if vf, ok := child.(*android.VintfFragmentModule); ok { + apexFile := apexFileForVintfFragment(ctx, vf) + vctx.filesInfo = append(vctx.filesInfo, apexFile) + } } + return false } diff --git a/apex/apex_test.go b/apex/apex_test.go index f88c09ebd..6c1a2d66b 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -12184,3 +12184,35 @@ func TestFilesystemWithApexDeps(t *testing.T) { fileList := android.ContentFromFileRuleForTests(t, result, partition.Output("fileList")) android.AssertDeepEquals(t, "filesystem with apex", "apex/myapex.apex\n", fileList) } + +func TestVintfFragmentInApex(t *testing.T) { + t.Parallel() + ctx := testApex(t, apex_default_bp+` + apex { + name: "myapex", + manifest: ":myapex.manifest", + androidManifest: ":myapex.androidmanifest", + key: "myapex.key", + binaries: [ "mybin" ], + updatable: false, + } + + cc_binary { + name: "mybin", + srcs: ["mybin.cpp"], + vintf_fragment_modules: ["my_vintf_fragment.xml"], + apex_available: [ "myapex" ], + } + + vintf_fragment { + name: "my_vintf_fragment.xml", + src: "my_vintf_fragment.xml", + } + `) + + generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") + cmd := generateFsRule.RuleParams.Command + + // Ensure that vintf fragment file is being installed + ensureContains(t, cmd, "/etc/vintf/my_vintf_fragment.xml ") +} diff --git a/apex/builder.go b/apex/builder.go index b34dc84a6..03a0bb902 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -528,9 +528,10 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android }) } -func isVintfFragment(fi apexFile) bool { +func shouldApplyAssembleVintf(fi apexFile) bool { isVintfFragment, _ := path.Match("etc/vintf/*", fi.path()) - return isVintfFragment + _, fromVintfFragmentModule := fi.module.(*android.VintfFragmentModule) + return isVintfFragment && !fromVintfFragmentModule } func runAssembleVintf(ctx android.ModuleContext, vintfFragment android.Path) android.Path { @@ -639,7 +640,7 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { copyCommands = append(copyCommands, "ln -sfn "+pathOnDevice+" "+destPath) } else { // Copy the file into APEX - if !a.testApex && isVintfFragment(fi) { + if !a.testApex && shouldApplyAssembleVintf(fi) { // copy the output of assemble_vintf instead of the original vintfFragment := runAssembleVintf(ctx, fi.builtFile) copyCommands = append(copyCommands, "cp -f "+vintfFragment.String()+" "+destPath) |