Add ApexInfo.RequiresLibs to mixed build handler for apex

Adding ApexInfo.RequiresLibs from Bazel to apexBundle.requiredDeps which is eventuallyread by apex androidmk writer for LOCAL_REQUIRED_MODULES to ensures the libs are installed as part of a bundle build.

In Soong, apexBundle.requiredDeps is set in
https://cs.android.com/android/platform/build/soong/+/master:apex/apex.go;l=2305-2323;drc=cb7e73bc0130a95f5991c925c349387185abc098

The same logic is replicated in Bazel at
https://cs.android.com/android/platform/build/bazel/+/master:rules/apex/cc.bzl;l=141-163;drc=cb7e73bc0130a95f5991c925c349387185abc098.

This CL is porting the required libs set by Bazel in mixed build.

Test: go test
Test: run build/bazel/ci/mixed_libc.sh
Bug: 215500321
Change-Id: Id7256d279ac09a8fd42db391a7e93ce0021d8345
This commit is contained in:
Vinh Tran
2022-12-14 11:34:54 -05:00
parent ccfe6022d4
commit b6803a5f52
3 changed files with 15 additions and 1 deletions

View File

@@ -458,6 +458,11 @@ func bp2buildModuleLabel(ctx BazelConversionContext, module blueprint.Module) st
return fmt.Sprintf("//%s:%s", moduleDir, moduleName) return fmt.Sprintf("//%s:%s", moduleDir, moduleName)
} }
// ModuleFromBazelLabel reverses the logic in bp2buildModuleLabel
func ModuleFromBazelLabel(label string) string {
return strings.Split(label, ":")[1]
}
// BazelOutPath is a Bazel output path compatible to be used for mixed builds within Soong/Ninja. // BazelOutPath is a Bazel output path compatible to be used for mixed builds within Soong/Ninja.
type BazelOutPath struct { type BazelOutPath struct {
OutputPath OutputPath

View File

@@ -1906,6 +1906,12 @@ func (a *apexBundle) ProcessBazelQueryResponse(ctx android.ModuleContext) {
a.containerCertificateFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[0]) a.containerCertificateFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[0])
a.containerPrivateKeyFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[1]) a.containerPrivateKeyFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[1])
// Ensure ApexInfo.RequiresLibs are installed as part of a bundle build
for _, bazelLabel := range outputs.RequiresLibs {
// convert Bazel label back to Soong module name
a.requiredDeps = append(a.requiredDeps, android.ModuleFromBazelLabel(bazelLabel))
}
apexType := a.properties.ApexType apexType := a.properties.ApexType
switch apexType { switch apexType {
case imageApex: case imageApex:

View File

@@ -9835,11 +9835,11 @@ apex {
JavaSymbolsUsedByApex: "foo_using.xml", JavaSymbolsUsedByApex: "foo_using.xml",
BundleFile: "apex_bundle.zip", BundleFile: "apex_bundle.zip",
InstalledFiles: "installed-files.txt", InstalledFiles: "installed-files.txt",
RequiresLibs: []string{"//path/c:c", "//path/d:d"},
// unused // unused
PackageName: "pkg_name", PackageName: "pkg_name",
ProvidesLibs: []string{"a", "b"}, ProvidesLibs: []string{"a", "b"},
RequiresLibs: []string{"c", "d"},
}, },
}, },
} }
@@ -9895,4 +9895,7 @@ apex {
if w := "$(call dist-for-goals,checkbuild,out/bazel/execroot/__main__/installed-files.txt:foo-installed-files.txt)"; !strings.Contains(data, w) { if w := "$(call dist-for-goals,checkbuild,out/bazel/execroot/__main__/installed-files.txt:foo-installed-files.txt)"; !strings.Contains(data, w) {
t.Errorf("Expected %q in androidmk data, but did not find %q", w, data) t.Errorf("Expected %q in androidmk data, but did not find %q", w, data)
} }
if w := "LOCAL_REQUIRED_MODULES := c d"; !strings.Contains(data, w) {
t.Errorf("Expected %q in androidmk data, but did not find it in %q", w, data)
}
} }