bazel apex: Add mixed builds support for <module>_using.txt file.

Test: presubmits
Change-Id: I7203fcccb09f6c93e702550ffa47a4029c3351dd
This commit is contained in:
Jingwen Chen 2022-11-04 09:40:47 +00:00
parent 1214001184
commit 0c9a276ded
4 changed files with 32 additions and 25 deletions

View file

@ -1903,16 +1903,14 @@ func (a *apexBundle) ProcessBazelQueryResponse(ctx android.ModuleContext) {
apexType := a.properties.ApexType
switch apexType {
case imageApex:
// TODO(asmundak): Bazel does not create these files yet.
// b/190817312
// TODO(b/190817312): Generate the notice file from the apex rule.
a.htmlGzNotice = android.PathForBazelOut(ctx, "NOTICE.html.gz")
// b/239081457
// TODO(b/239081457): Generate the bazel bundle module file from the apex rule.
a.bundleModuleFile = android.PathForBazelOut(ctx, a.Name()+apexType.suffix()+"-base.zip")
// b/239081455
a.nativeApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, a.Name()+"_using.txt"))
// b/239081456
a.nativeApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.SymbolsUsedByApex))
// TODO(b/239081456): Generate the backing.txt file from Bazel.
a.nativeApisBackedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, a.Name()+"_backing.txt"))
// b/239084755
// TODO(b/239084755): Generate the java api using.xml file from Bazel.
a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, a.Name()+"_using.xml"))
installSuffix := imageApexSuffix
if a.isCompressed {

View file

@ -9768,10 +9768,11 @@ apex {
OutputBaseDir: outputBaseDir,
LabelToApexInfo: map[string]cquery.ApexInfo{
"//:foo": cquery.ApexInfo{
SignedOutput: "signed_out.apex",
UnsignedOutput: "unsigned_out.apex",
BundleKeyInfo: []string{"public_key", "private_key"},
ContainerKeyInfo: []string{"container_cert", "container_private"},
SignedOutput: "signed_out.apex",
UnsignedOutput: "unsigned_out.apex",
BundleKeyInfo: []string{"public_key", "private_key"},
ContainerKeyInfo: []string{"container_cert", "container_private"},
SymbolsUsedByApex: "foo_using.txt",
// unused
PackageName: "pkg_name",
@ -9808,4 +9809,8 @@ apex {
if w, g := "out/bazel/execroot/__main__/signed_out.apex", ab.outputFile.String(); w != g {
t.Errorf("Expected output file %q, got %q", w, g)
}
if w, g := "out/bazel/execroot/__main__/foo_using.txt", ab.nativeApisUsedByModuleFile.String(); w != g {
t.Errorf("Expected output file %q, got %q", w, g)
}
}

View file

@ -218,17 +218,19 @@ return json_encode({
"bundle_key_info": [bundle_key_info.public_key.path, bundle_key_info.private_key.path],
"container_key_info": [container_key_info.pem.path, container_key_info.pk8.path, container_key_info.key_name],
"package_name": info.package_name,
"symbols_used_by_apex": info.symbols_used_by_apex.path,
})`
}
type ApexInfo struct {
SignedOutput string `json:"signed_output"`
UnsignedOutput string `json:"unsigned_output"`
ProvidesLibs []string `json:"provides_native_libs"`
RequiresLibs []string `json:"requires_native_libs"`
BundleKeyInfo []string `json:"bundle_key_info"`
ContainerKeyInfo []string `json:"container_key_info"`
PackageName string `json:"package_name"`
SignedOutput string `json:"signed_output"`
UnsignedOutput string `json:"unsigned_output"`
ProvidesLibs []string `json:"provides_native_libs"`
RequiresLibs []string `json:"requires_native_libs"`
BundleKeyInfo []string `json:"bundle_key_info"`
ContainerKeyInfo []string `json:"container_key_info"`
PackageName string `json:"package_name"`
SymbolsUsedByApex string `json:"symbols_used_by_apex"`
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.

View file

@ -148,15 +148,17 @@ func TestGetApexInfoParseResults(t *testing.T) {
`"bundle_key_info":["foo.pem", "foo.privkey"],` +
`"container_key_info":["foo.x509.pem", "foo.pk8", "foo"],` +
`"package_name":"package.name",` +
`"symbols_used_by_apex": "path/to/my.apex_using.txt",` +
`"provides_native_libs":[]}`,
expectedOutput: ApexInfo{
SignedOutput: "my.apex",
UnsignedOutput: "my.apex.unsigned",
RequiresLibs: []string{"//bionic/libc:libc", "//bionic/libdl:libdl"},
ProvidesLibs: []string{},
BundleKeyInfo: []string{"foo.pem", "foo.privkey"},
ContainerKeyInfo: []string{"foo.x509.pem", "foo.pk8", "foo"},
PackageName: "package.name",
SignedOutput: "my.apex",
UnsignedOutput: "my.apex.unsigned",
RequiresLibs: []string{"//bionic/libc:libc", "//bionic/libdl:libdl"},
ProvidesLibs: []string{},
BundleKeyInfo: []string{"foo.pem", "foo.privkey"},
ContainerKeyInfo: []string{"foo.x509.pem", "foo.pk8", "foo"},
PackageName: "package.name",
SymbolsUsedByApex: "path/to/my.apex_using.txt",
},
},
}