Switch BootJars/UpdatableBootJars to ConfiguredJarList am: 69d1fb1e39 am: 769b1eab84 am: 3e29458b28

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1471779

Change-Id: I105cce84a3f8bd3eb3500d5bc1e4ffcd3524c030
This commit is contained in:
Paul Duffin
2020-10-27 17:20:24 +00:00
committed by Automerger Merge Worker
4 changed files with 27 additions and 8 deletions

View File

@@ -1415,6 +1415,26 @@ func (l *ConfiguredJarList) BuildPaths(ctx PathContext, dir OutputPath) Writable
return paths
}
// Called when loading configuration from JSON into a configuration structure.
func (l *ConfiguredJarList) UnmarshalJSON(b []byte) error {
// Try and unmarshal into a []string each item of which contains a pair
// <apex>:<jar>.
var list []string
err := json.Unmarshal(b, &list)
if err != nil {
// Did not work so return
return err
}
apexes, jars, err := splitListOfPairsIntoPairOfLists(list)
if err != nil {
return err
}
l.apexes = apexes
l.jars = jars
return nil
}
func ModuleStem(module string) string {
// b/139391334: the stem of framework-minus-apex is framework. This is hard coded here until we
// find a good way to query the stem of a module before any other mutators are run.
@@ -1494,9 +1514,8 @@ var earlyBootJarsKey = NewOnceKey("earlyBootJars")
func (c *config) BootJars() []string {
return c.Once(earlyBootJarsKey, func() interface{} {
ctx := NullPathContext{Config{c}}
list := CreateConfiguredJarList(ctx,
append(CopyOf(c.productVariables.BootJars), c.productVariables.UpdatableBootJars...))
return list.CopyOfJars()
list := c.productVariables.BootJars.CopyOfJars()
list = append(list, c.productVariables.UpdatableBootJars.CopyOfJars()...)
return list
}).([]string)
}

View File

@@ -249,8 +249,8 @@ type productVariables struct {
UncompressPrivAppDex *bool `json:",omitempty"`
ModulesLoadedByPrivilegedModules []string `json:",omitempty"`
BootJars []string `json:",omitempty"`
UpdatableBootJars []string `json:",omitempty"`
BootJars ConfiguredJarList `json:",omitempty"`
UpdatableBootJars ConfiguredJarList `json:",omitempty"`
IntegerOverflowExcludePaths []string `json:",omitempty"`

View File

@@ -5905,7 +5905,7 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar
for _, apexBootJar := range apexBootJars {
updatableBootJars = append(updatableBootJars, "myapex:"+apexBootJar)
}
config.TestProductVariables.UpdatableBootJars = updatableBootJars
config.TestProductVariables.UpdatableBootJars = android.CreateConfiguredJarList(nil, updatableBootJars)
ctx.Register(config)

View File

@@ -25,7 +25,7 @@ import (
func testConfigWithBootJars(bp string, bootJars []string) android.Config {
config := testConfig(nil, bp, nil)
config.TestProductVariables.BootJars = bootJars
config.TestProductVariables.BootJars = android.CreateConfiguredJarList(nil, bootJars)
return config
}