aboutsummaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-04-24 03:46:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-24 03:46:16 +0000
commita25a2779c64f310609fae84adc990ce126ab0e8b (patch)
treec5210fc28aa4dea30815e7a94255978c2f42b8a9 /apex
parent687fd94d441912cc756f00027b5e2a1901d3caf0 (diff)
parenta41f12a6fa05a030b426fe68dc0f5d6203a73c79 (diff)
downloadbuild_soong-a25a2779c64f310609fae84adc990ce126ab0e8b.tar.gz
build_soong-a25a2779c64f310609fae84adc990ce126ab0e8b.tar.bz2
build_soong-a25a2779c64f310609fae84adc990ce126ab0e8b.zip
Merge "Prebuilt APEXes are recoreded in apexkeys.txt" into qt-dev
Diffstat (limited to 'apex')
-rw-r--r--apex/apex.go6
-rw-r--r--apex/key.go34
2 files changed, 35 insertions, 5 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 509e0f2e..fa4cb48c 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1373,11 +1373,15 @@ func (p *Prebuilt) Srcs() android.Paths {
return android.Paths{p.outputApex}
}
+func (p *Prebuilt) InstallFilename() string {
+ return proptools.StringDefault(p.properties.Filename, p.BaseModuleName()+imageApexSuffix)
+}
+
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// TODO(jungjw): Check the key validity.
p.inputApex = p.Prebuilt().SingleSourcePath(ctx)
p.installDir = android.PathForModuleInstall(ctx, "apex")
- p.installFilename = proptools.StringDefault(p.properties.Filename, ctx.ModuleName()+imageApexSuffix)
+ p.installFilename = p.InstallFilename()
if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
ctx.ModuleErrorf("filename should end in %s for prebuilt_apex", imageApexSuffix)
}
diff --git a/apex/key.go b/apex/key.go
index a627e4bc..6ee3dca3 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -16,6 +16,7 @@ package apex
import (
"fmt"
+ "sort"
"strings"
"android/soong/android"
@@ -106,12 +107,31 @@ type apexKeysText struct {
func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
s.output = android.PathForOutput(ctx, "apexkeys.txt")
- var filecontent strings.Builder
+ apexModulesMap := make(map[string]android.Module)
ctx.VisitAllModules(func(module android.Module) {
- if m, ok := module.(android.Module); ok && !m.Enabled() {
- return
+ if m, ok := module.(*apexBundle); ok && m.Enabled() && m.installable() {
+ apexModulesMap[m.Name()] = m
}
+ })
+
+ // Find prebuilts and let them override apexBundle if they are preferred
+ ctx.VisitAllModules(func(module android.Module) {
+ if m, ok := module.(*Prebuilt); ok && m.Enabled() && m.installable() &&
+ m.Prebuilt().UsePrebuilt() {
+ apexModulesMap[m.BaseModuleName()] = m
+ }
+ })
+
+ // iterating over map does not give consistent ordering in golang
+ var moduleNames []string
+ for key, _ := range apexModulesMap {
+ moduleNames = append(moduleNames, key)
+ }
+ sort.Strings(moduleNames)
+ var filecontent strings.Builder
+ for _, key := range moduleNames {
+ module := apexModulesMap[key]
if m, ok := module.(*apexBundle); ok {
fmt.Fprintf(&filecontent,
"name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
@@ -120,8 +140,14 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
m.private_key_file.String(),
m.container_certificate_file.String(),
m.container_private_key_file.String())
+ } else if m, ok := module.(*Prebuilt); ok {
+ fmt.Fprintf(&filecontent,
+ "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
+ m.InstallFilename(),
+ "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED")
}
- })
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: android.WriteFile,
Description: "apexkeys.txt",