Export app certificates to Make for apkcerts list am: e1731a5803 am: 461aba31c6

am: 0c77c7c46d

Change-Id: I5b31a7359839e10c66f3dbdc4c2c1aeb80916012
This commit is contained in:
Colin Cross 2017-12-14 22:34:39 +00:00 committed by android-build-merger
commit 2be8e07ad3
4 changed files with 34 additions and 14 deletions

View file

@ -511,12 +511,13 @@ func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
}
}
func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath {
func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
defaultCert := String(c.ProductVariables.DefaultAppCertificate)
if defaultCert != "" {
return PathForSource(ctx, defaultCert)
return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8")
} else {
return c.DefaultAppCertificateDir(ctx).Join(ctx, "testkey")
defaultDir := c.DefaultAppCertificateDir(ctx)
return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
}
}

View file

@ -180,6 +180,8 @@ func (app *AndroidApp) AndroidMk() android.AndroidMkData {
if Bool(app.appProperties.Privileged) {
fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
}
fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.pem.String())
},
},
}

View file

@ -77,6 +77,11 @@ type AndroidApp struct {
exportPackage android.Path
rroDirs android.Paths
manifestPath android.Path
certificate certificate
}
type certificate struct {
pem, key android.Path
}
func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
@ -132,18 +137,30 @@ func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.Module.compile(ctx, a.aaptSrcJar)
}
certificate := String(a.appProperties.Certificate)
if certificate == "" {
certificate = ctx.Config().DefaultAppCertificate(ctx).String()
} else if dir, _ := filepath.Split(certificate); dir == "" {
certificate = filepath.Join(ctx.Config().DefaultAppCertificateDir(ctx).String(), certificate)
} else {
certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
c := String(a.appProperties.Certificate)
switch {
case c == "":
pem, key := ctx.Config().DefaultAppCertificate(ctx)
a.certificate = certificate{pem, key}
case strings.ContainsRune(c, '/'):
a.certificate = certificate{
android.PathForSource(ctx, c+".x509.pem"),
android.PathForSource(ctx, c+".pk8"),
}
default:
defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
a.certificate = certificate{
defaultDir.Join(ctx, c+".x509.pem"),
defaultDir.Join(ctx, c+".pk8"),
}
}
certificates := []string{certificate}
certificates := []certificate{a.certificate}
for _, c := range a.appProperties.Additional_certificates {
certificates = append(certificates, filepath.Join(android.PathForSource(ctx).String(), c))
certificates = append(certificates, certificate{
android.PathForSource(ctx, c+".x509.pem"),
android.PathForSource(ctx, c+".pk8"),
})
}
packageFile := android.PathForModuleOut(ctx, "package.apk")

View file

@ -61,7 +61,7 @@ var combineApk = pctx.AndroidStaticRule("combineApk",
})
func CreateAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
resJarFile, dexJarFile android.Path, certificates []string) {
resJarFile, dexJarFile android.Path, certificates []certificate) {
// TODO(ccross): JNI libs
@ -80,7 +80,7 @@ func CreateAppPackage(ctx android.ModuleContext, outputFile android.WritablePath
var certificateArgs []string
for _, c := range certificates {
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
certificateArgs = append(certificateArgs, c.pem.String(), c.key.String())
}
// TODO(ccross): sometimes uncompress dex