summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/apex.go91
-rw-r--r--android/arch.go11
-rw-r--r--android/config.go48
-rw-r--r--android/module.go14
-rw-r--r--android/neverallow.go13
-rw-r--r--android/util.go4
-rw-r--r--android/util_test.go2
-rw-r--r--android/variable.go6
-rw-r--r--android/vts_config.go6
9 files changed, 108 insertions, 87 deletions
diff --git a/android/apex.go b/android/apex.go
index 9195388bf..43a42df9b 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -19,6 +19,14 @@ import (
"sync"
)
+type ApexInfo struct {
+ // Name of the apex variant that this module is mutated into
+ ApexName string
+
+ // Whether this apex variant needs to target Android 10
+ LegacyAndroid10Support bool
+}
+
// ApexModule is the interface that a module type is expected to implement if
// the module has to be built differently depending on whether the module
// is destined for an apex or not (installed to one of the regular partitions).
@@ -38,9 +46,12 @@ type ApexModule interface {
Module
apexModuleBase() *ApexModuleBase
- // Marks that this module should be built for the APEX of the specified name.
+ // Marks that this module should be built for the specified APEXes.
// Call this before apex.apexMutator is run.
- BuildForApex(apexName string)
+ BuildForApexes(apexes []ApexInfo)
+
+ // Returns the APEXes that this module will be built for
+ ApexVariations() []ApexInfo
// Returns the name of APEX that this module will be built for. Empty string
// is returned when 'IsForPlatform() == true'. Note that a module can be
@@ -66,13 +77,9 @@ type ApexModule interface {
IsInstallableToApex() bool
// Mutate this module into one or more variants each of which is built
- // for an APEX marked via BuildForApex().
+ // for an APEX marked via BuildForApexes().
CreateApexVariations(mctx BottomUpMutatorContext) []Module
- // Sets the name of the apex variant of this module. Called inside
- // CreateApexVariations.
- setApexName(apexName string)
-
// Tests if this module is available for the specified APEX or ":platform"
AvailableFor(what string) bool
@@ -88,12 +95,10 @@ type ApexProperties struct {
//
// "//apex_available:anyapex" is a pseudo APEX name that matches to any APEX.
// "//apex_available:platform" refers to non-APEX partitions like "system.img".
- // Default is ["//apex_available:platform", "//apex_available:anyapex"].
- // TODO(b/128708192) change the default to ["//apex_available:platform"]
+ // Default is ["//apex_available:platform"].
Apex_available []string
- // Name of the apex variant that this module is mutated into
- ApexName string `blueprint:"mutated"`
+ Info ApexInfo `blueprint:"mutated"`
}
// Provides default implementation for the ApexModule interface. APEX-aware
@@ -104,31 +109,37 @@ type ApexModuleBase struct {
canHaveApexVariants bool
apexVariationsLock sync.Mutex // protects apexVariations during parallel apexDepsMutator
- apexVariations []string
+ apexVariations []ApexInfo
}
func (m *ApexModuleBase) apexModuleBase() *ApexModuleBase {
return m
}
-func (m *ApexModuleBase) BuildForApex(apexName string) {
+func (m *ApexModuleBase) BuildForApexes(apexes []ApexInfo) {
m.apexVariationsLock.Lock()
defer m.apexVariationsLock.Unlock()
- if !InList(apexName, m.apexVariations) {
- m.apexVariations = append(m.apexVariations, apexName)
+nextApex:
+ for _, apex := range apexes {
+ for _, v := range m.apexVariations {
+ if v.ApexName == apex.ApexName {
+ continue nextApex
+ }
+ }
+ m.apexVariations = append(m.apexVariations, apex)
}
}
-func (m *ApexModuleBase) ApexName() string {
- return m.ApexProperties.ApexName
+func (m *ApexModuleBase) ApexVariations() []ApexInfo {
+ return m.apexVariations
}
-func (m *ApexModuleBase) IsForPlatform() bool {
- return m.ApexProperties.ApexName == ""
+func (m *ApexModuleBase) ApexName() string {
+ return m.ApexProperties.Info.ApexName
}
-func (m *ApexModuleBase) setApexName(apexName string) {
- m.ApexProperties.ApexName = apexName
+func (m *ApexModuleBase) IsForPlatform() bool {
+ return m.ApexProperties.Info.ApexName == ""
}
func (m *ApexModuleBase) CanHaveApexVariants() bool {
@@ -177,25 +188,35 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
}
}
+type byApexName []ApexInfo
+
+func (a byApexName) Len() int { return len(a) }
+func (a byApexName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a byApexName) Less(i, j int) bool { return a[i].ApexName < a[j].ApexName }
+
func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module {
if len(m.apexVariations) > 0 {
m.checkApexAvailableProperty(mctx)
- sort.Strings(m.apexVariations)
+ sort.Sort(byApexName(m.apexVariations))
variations := []string{}
variations = append(variations, "") // Original variation for platform
- variations = append(variations, m.apexVariations...)
+ for _, apex := range m.apexVariations {
+ variations = append(variations, apex.ApexName)
+ }
defaultVariation := ""
mctx.SetDefaultDependencyVariation(&defaultVariation)
modules := mctx.CreateVariations(variations...)
- for i, m := range modules {
+ for i, mod := range modules {
platformVariation := i == 0
- if platformVariation && !mctx.Host() && !m.(ApexModule).AvailableFor(AvailableToPlatform) {
- m.SkipInstall()
+ if platformVariation && !mctx.Host() && !mod.(ApexModule).AvailableFor(AvailableToPlatform) {
+ mod.SkipInstall()
+ }
+ if !platformVariation {
+ mod.(ApexModule).apexModuleBase().ApexProperties.Info = m.apexVariations[i-1]
}
- m.(ApexModule).setApexName(variations[i])
}
return modules
}
@@ -219,18 +240,20 @@ func apexNamesMap() map[string]map[string]bool {
}
// Update the map to mark that a module named moduleName is directly or indirectly
-// depended on by an APEX named apexName. Directly depending means that a module
+// depended on by the specified APEXes. Directly depending means that a module
// is explicitly listed in the build definition of the APEX via properties like
// native_shared_libs, java_libs, etc.
-func UpdateApexDependency(apexName string, moduleName string, directDep bool) {
+func UpdateApexDependency(apexes []ApexInfo, moduleName string, directDep bool) {
apexNamesMapMutex.Lock()
defer apexNamesMapMutex.Unlock()
- apexNames, ok := apexNamesMap()[moduleName]
- if !ok {
- apexNames = make(map[string]bool)
- apexNamesMap()[moduleName] = apexNames
+ for _, apex := range apexes {
+ apexesForModule, ok := apexNamesMap()[moduleName]
+ if !ok {
+ apexesForModule = make(map[string]bool)
+ apexNamesMap()[moduleName] = apexesForModule
+ }
+ apexesForModule[apex.ApexName] = apexesForModule[apex.ApexName] || directDep
}
- apexNames[apexName] = apexNames[apexName] || directDep
}
// TODO(b/146393795): remove this when b/146393795 is fixed
diff --git a/android/arch.go b/android/arch.go
index 3657e6dd4..73a490d79 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -765,7 +765,7 @@ func osMutator(mctx BottomUpMutatorContext) {
}
if len(moduleOSList) == 0 {
- base.commonProperties.Enabled = boolPtr(false)
+ base.Disable()
return
}
@@ -869,7 +869,7 @@ func archMutator(mctx BottomUpMutatorContext) {
}
if len(targets) == 0 {
- base.commonProperties.Enabled = boolPtr(false)
+ base.Disable()
return
}
@@ -1521,12 +1521,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
// hasArmAbi returns true if arch has at least one arm ABI
func hasArmAbi(arch Arch) bool {
- for _, abi := range arch.Abi {
- if strings.HasPrefix(abi, "arm") {
- return true
- }
- }
- return false
+ return PrefixInList(arch.Abi, "arm")
}
// hasArmArch returns true if targets has at least non-native_bridge arm Android arch
diff --git a/android/config.go b/android/config.go
index d0ac4c35d..1fe6f058b 100644
--- a/android/config.go
+++ b/android/config.go
@@ -790,14 +790,6 @@ func (c *config) DisableScudo() bool {
return Bool(c.productVariables.DisableScudo)
}
-func (c *config) EnableXOM() bool {
- if c.productVariables.EnableXOM == nil {
- return true
- } else {
- return Bool(c.productVariables.EnableXOM)
- }
-}
-
func (c *config) Android64() bool {
for _, t := range c.Targets[Android] {
if t.Arch.ArchType.Multilib == "lib64" {
@@ -898,11 +890,7 @@ func (c *config) EnforceRROForModule(name string) bool {
func (c *config) EnforceRROExcludedOverlay(path string) bool {
excluded := c.productVariables.EnforceRROExcludedOverlays
if excluded != nil {
- for _, exclude := range excluded {
- if strings.HasPrefix(path, exclude) {
- return true
- }
- }
+ return HasAnyPrefix(path, excluded)
}
return false
}
@@ -923,8 +911,23 @@ func (c *config) ModulesLoadedByPrivilegedModules() []string {
return c.productVariables.ModulesLoadedByPrivilegedModules
}
+// Expected format for apexJarValue = <apex name>:<jar name>
+func SplitApexJarPair(apexJarValue string) (string, string) {
+ var apexJarPair []string = strings.SplitN(apexJarValue, ":", 2)
+ if apexJarPair == nil || len(apexJarPair) != 2 {
+ panic(fmt.Errorf("malformed apexJarValue: %q, expected format: <apex>:<jar>",
+ apexJarValue))
+ }
+ return apexJarPair[0], apexJarPair[1]
+}
+
func (c *config) BootJars() []string {
- return c.productVariables.BootJars
+ jars := c.productVariables.BootJars
+ for _, p := range c.productVariables.UpdatableBootJars {
+ _, jar := SplitApexJarPair(p)
+ jars = append(jars, jar)
+ }
+ return jars
}
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {
@@ -1043,12 +1046,12 @@ func (c *deviceConfig) ClangCoverageEnabled() bool {
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
coverage := false
if c.config.productVariables.CoveragePaths != nil {
- if InList("*", c.config.productVariables.CoveragePaths) || PrefixInList(path, c.config.productVariables.CoveragePaths) {
+ if InList("*", c.config.productVariables.CoveragePaths) || HasAnyPrefix(path, c.config.productVariables.CoveragePaths) {
coverage = true
}
}
if coverage && c.config.productVariables.CoverageExcludePaths != nil {
- if PrefixInList(path, c.config.productVariables.CoverageExcludePaths) {
+ if HasAnyPrefix(path, c.config.productVariables.CoverageExcludePaths) {
coverage = false
}
}
@@ -1121,28 +1124,21 @@ func (c *config) IntegerOverflowDisabledForPath(path string) bool {
if c.productVariables.IntegerOverflowExcludePaths == nil {
return false
}
- return PrefixInList(path, c.productVariables.IntegerOverflowExcludePaths)
+ return HasAnyPrefix(path, c.productVariables.IntegerOverflowExcludePaths)
}
func (c *config) CFIDisabledForPath(path string) bool {
if c.productVariables.CFIExcludePaths == nil {
return false
}
- return PrefixInList(path, c.productVariables.CFIExcludePaths)
+ return HasAnyPrefix(path, c.productVariables.CFIExcludePaths)
}
func (c *config) CFIEnabledForPath(path string) bool {
if c.productVariables.CFIIncludePaths == nil {
return false
}
- return PrefixInList(path, c.productVariables.CFIIncludePaths)
-}
-
-func (c *config) XOMDisabledForPath(path string) bool {
- if c.productVariables.XOMExcludePaths == nil {
- return false
- }
- return PrefixInList(path, c.productVariables.XOMExcludePaths)
+ return HasAnyPrefix(path, c.productVariables.CFIIncludePaths)
}
func (c *config) VendorConfig(name string) VendorConfig {
diff --git a/android/module.go b/android/module.go
index 28d83e881..fd3fec333 100644
--- a/android/module.go
+++ b/android/module.go
@@ -204,6 +204,7 @@ type Module interface {
DepsMutator(BottomUpMutatorContext)
base() *ModuleBase
+ Disable()
Enabled() bool
Target() Target
InstallInData() bool
@@ -293,6 +294,12 @@ type nameProperties struct {
type commonProperties struct {
// emit build rules for this module
+ //
+ // Disabling a module should only be done for those modules that cannot be built
+ // in the current environment. Modules that can build in the current environment
+ // but are not usually required (e.g. superceded by a prebuilt) should not be
+ // disabled as that will prevent them from being built by the checkbuild target
+ // and so prevent early detection of changes that have broken those modules.
Enabled *bool `android:"arch_variant"`
// Controls the visibility of this module to other modules. Allowable values are one or more of
@@ -830,6 +837,10 @@ func (m *ModuleBase) Enabled() bool {
return *m.commonProperties.Enabled
}
+func (m *ModuleBase) Disable() {
+ m.commonProperties.Enabled = proptools.BoolPtr(false)
+}
+
func (m *ModuleBase) SkipInstall() {
m.commonProperties.SkipInstall = true
}
@@ -1101,6 +1112,9 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
if !ctx.PrimaryArch() {
suffix = append(suffix, ctx.Arch().ArchType.String())
}
+ if apex, ok := m.module.(ApexModule); ok && !apex.IsForPlatform() {
+ suffix = append(suffix, apex.ApexName())
+ }
ctx.Variable(pctx, "moduleDesc", desc)
diff --git a/android/neverallow.go b/android/neverallow.go
index 48581df71..0cb20296c 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -407,8 +407,8 @@ func (r *rule) String() string {
}
func (r *rule) appliesToPath(dir string) bool {
- includePath := len(r.paths) == 0 || hasAnyPrefix(dir, r.paths)
- excludePath := hasAnyPrefix(dir, r.unlessPaths)
+ includePath := len(r.paths) == 0 || HasAnyPrefix(dir, r.paths)
+ excludePath := HasAnyPrefix(dir, r.unlessPaths)
return includePath && !excludePath
}
@@ -474,15 +474,6 @@ func fieldNamesForProperties(propertyNames string) []string {
return names
}
-func hasAnyPrefix(s string, prefixes []string) bool {
- for _, prefix := range prefixes {
- if strings.HasPrefix(s, prefix) {
- return true
- }
- }
- return false
-}
-
func hasAnyProperty(properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
if hasProperty(properties, v) {
diff --git a/android/util.go b/android/util.go
index e985fc1f5..ade851eff 100644
--- a/android/util.go
+++ b/android/util.go
@@ -122,7 +122,7 @@ func InList(s string, list []string) bool {
}
// Returns true if the given string s is prefixed with any string in the given prefix list.
-func PrefixInList(s string, prefixList []string) bool {
+func HasAnyPrefix(s string, prefixList []string) bool {
for _, prefix := range prefixList {
if strings.HasPrefix(s, prefix) {
return true
@@ -132,7 +132,7 @@ func PrefixInList(s string, prefixList []string) bool {
}
// Returns true if any string in the given list has the given prefix.
-func PrefixedStringInList(list []string, prefix string) bool {
+func PrefixInList(list []string, prefix string) bool {
for _, s := range list {
if strings.HasPrefix(s, prefix) {
return true
diff --git a/android/util_test.go b/android/util_test.go
index 90fefeede..1f9ca361c 100644
--- a/android/util_test.go
+++ b/android/util_test.go
@@ -252,7 +252,7 @@ func TestPrefixInList(t *testing.T) {
for _, testCase := range testcases {
t.Run(testCase.str, func(t *testing.T) {
- out := PrefixInList(testCase.str, prefixes)
+ out := HasAnyPrefix(testCase.str, prefixes)
if out != testCase.expected {
t.Errorf("incorrect output:")
t.Errorf(" str: %#v", testCase.str)
diff --git a/android/variable.go b/android/variable.go
index 58e59404e..9cbe624e4 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -230,7 +230,8 @@ type productVariables struct {
UncompressPrivAppDex *bool `json:",omitempty"`
ModulesLoadedByPrivilegedModules []string `json:",omitempty"`
- BootJars []string `json:",omitempty"`
+ BootJars []string `json:",omitempty"`
+ UpdatableBootJars []string `json:",omitempty"`
IntegerOverflowExcludePaths []string `json:",omitempty"`
@@ -240,9 +241,6 @@ type productVariables struct {
DisableScudo *bool `json:",omitempty"`
- EnableXOM *bool `json:",omitempty"`
- XOMExcludePaths []string `json:",omitempty"`
-
Experimental_mte *bool `json:",omitempty"`
VendorPath *string `json:",omitempty"`
diff --git a/android/vts_config.go b/android/vts_config.go
index 86f6e7281..9a1df7c99 100644
--- a/android/vts_config.go
+++ b/android/vts_config.go
@@ -17,6 +17,7 @@ package android
import (
"fmt"
"io"
+ "strings"
)
func init() {
@@ -26,6 +27,8 @@ func init() {
type vtsConfigProperties struct {
// Override the default (AndroidTest.xml) test manifest file name.
Test_config *string
+ // Additional test suites to add the test to.
+ Test_suites []string `android:"arch_variant"`
}
type VtsConfig struct {
@@ -50,7 +53,8 @@ func (me *VtsConfig) AndroidMk() AndroidMkData {
fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n",
*me.properties.Test_config)
}
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := vts")
+ fmt.Fprintf(w, "LOCAL_COMPATIBILITY_SUITE := vts %s\n",
+ strings.Join(me.properties.Test_suites, " "))
},
}
return androidMkData