Merge "Support new attributes added in ApexInfo in mixed build."

This commit is contained in:
Wei Li
2022-10-29 01:16:39 +00:00
committed by Gerrit Code Review
3 changed files with 18 additions and 12 deletions

View File

@@ -1854,10 +1854,10 @@ func (a *apexBundle) ProcessBazelQueryResponse(ctx android.ModuleContext) {
a.outputFile = a.outputApexFile
a.setCompression(ctx)
a.publicKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyPair[0])
a.privateKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyPair[1])
a.containerCertificateFile = android.PathForBazelOut(ctx, outputs.ContainerKeyPair[0])
a.containerPrivateKeyFile = android.PathForBazelOut(ctx, outputs.ContainerKeyPair[1])
a.publicKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyInfo[0])
a.privateKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyInfo[1])
a.containerCertificateFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[0])
a.containerPrivateKeyFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[1])
apexType := a.properties.ApexType
switch apexType {
case imageApex:

View File

@@ -208,13 +208,16 @@ func (g getApexInfoType) Name() string {
// - The function body should not be indented outside of its own scope.
func (g getApexInfoType) StarlarkFunctionBody() string {
return `info = providers(target)["//build/bazel/rules/apex:apex.bzl%ApexInfo"]
bundle_key_info = info.bundle_key_info
container_key_info = info.container_key_info
return json_encode({
"signed_output": info.signed_output.path,
"unsigned_output": info.unsigned_output.path,
"provides_native_libs": [str(lib) for lib in info.provides_native_libs],
"requires_native_libs": [str(lib) for lib in info.requires_native_libs],
"bundle_key_pair": [f.path for f in info.bundle_key_pair],
"container_key_pair": [f.path for f in info.container_key_pair]
"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,
})`
}
@@ -223,8 +226,9 @@ type ApexCqueryInfo struct {
UnsignedOutput string `json:"unsigned_output"`
ProvidesLibs []string `json:"provides_native_libs"`
RequiresLibs []string `json:"requires_native_libs"`
BundleKeyPair []string `json:"bundle_key_pair"`
ContainerKeyPair []string `json:"container_key_pair"`
BundleKeyInfo []string `json:"bundle_key_info"`
ContainerKeyInfo []string `json:"container_key_info"`
PackageName string `json:"package_name"`
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.

View File

@@ -145,16 +145,18 @@ func TestGetApexInfoParseResults(t *testing.T) {
input: `{"signed_output":"my.apex",` +
`"unsigned_output":"my.apex.unsigned",` +
`"requires_native_libs":["//bionic/libc:libc","//bionic/libdl:libdl"],` +
`"bundle_key_pair":["foo.pem","foo.privkey"],` +
`"container_key_pair":["foo.x509.pem", "foo.pk8"],` +
`"bundle_key_info":["foo.pem", "foo.privkey"],` +
`"container_key_info":["foo.x509.pem", "foo.pk8", "foo"],` +
`"package_name":"package.name",` +
`"provides_native_libs":[]}`,
expectedOutput: ApexCqueryInfo{
SignedOutput: "my.apex",
UnsignedOutput: "my.apex.unsigned",
RequiresLibs: []string{"//bionic/libc:libc", "//bionic/libdl:libdl"},
ProvidesLibs: []string{},
BundleKeyPair: []string{"foo.pem", "foo.privkey"},
ContainerKeyPair: []string{"foo.x509.pem", "foo.pk8"},
BundleKeyInfo: []string{"foo.pem", "foo.privkey"},
ContainerKeyInfo: []string{"foo.x509.pem", "foo.pk8", "foo"},
PackageName: "package.name",
},
},
}