Merge "Revert "Implement detecting container violations."" into main
diff --git a/android/androidmk.go b/android/androidmk.go
index 9cad697..68a6415 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -157,6 +157,7 @@
}
type AndroidMkEntriesContext interface {
+ OtherModuleProviderContext
Config() Config
}
@@ -354,14 +355,15 @@
availableTaggedDists = availableTaggedDists.addPathsForTag(DefaultDistTag, a.OutputFile.Path())
}
+ info := OtherModuleProviderOrDefault(a.entryContext, mod, InstallFilesProvider)
// If the distFiles created by GenerateTaggedDistFiles contains paths for the
// DefaultDistTag then that takes priority so delete any existing paths.
- if _, ok := amod.distFiles[DefaultDistTag]; ok {
+ if _, ok := info.DistFiles[DefaultDistTag]; ok {
delete(availableTaggedDists, DefaultDistTag)
}
// Finally, merge the distFiles created by GenerateTaggedDistFiles.
- availableTaggedDists = availableTaggedDists.merge(amod.distFiles)
+ availableTaggedDists = availableTaggedDists.merge(info.DistFiles)
if len(availableTaggedDists) == 0 {
// Nothing dist-able for this module.
@@ -372,7 +374,7 @@
distContributions := &distContributions{}
if !exemptFromRequiredApplicableLicensesProperty(mod.(Module)) {
- distContributions.licenseMetadataFile = amod.licenseMetadataFile
+ distContributions.licenseMetadataFile = info.LicenseMetadataFile
}
// Iterate over this module's dist structs, merged from the dist and dists properties.
@@ -590,10 +592,10 @@
}
if !base.InVendorRamdisk() {
- a.AddPaths("LOCAL_FULL_INIT_RC", base.initRcPaths)
+ a.AddPaths("LOCAL_FULL_INIT_RC", info.InitRcPaths)
}
- if len(base.vintfFragmentsPaths) > 0 {
- a.AddPaths("LOCAL_FULL_VINTF_FRAGMENTS", base.vintfFragmentsPaths)
+ if len(info.VintfFragmentsPaths) > 0 {
+ a.AddPaths("LOCAL_FULL_VINTF_FRAGMENTS", info.VintfFragmentsPaths)
}
a.SetBoolIfTrue("LOCAL_PROPRIETARY_MODULE", Bool(base.commonProperties.Proprietary))
if Bool(base.commonProperties.Vendor) || Bool(base.commonProperties.Soc_specific) {
diff --git a/android/androidmk_test.go b/android/androidmk_test.go
index 72b8654..c37eeab 100644
--- a/android/androidmk_test.go
+++ b/android/androidmk_test.go
@@ -46,7 +46,6 @@
func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) {
- m.base().licenseMetadataFile = PathForOutput(ctx, "meta_lic")
var defaultDistPaths Paths
// If the dist_output_file: true then create an output file that is stored in
@@ -276,7 +275,8 @@
)
}
for idx, line := range androidMkLines {
- expectedLine := strings.ReplaceAll(expectedAndroidMkLines[idx], "meta_lic", module.base().licenseMetadataFile.String())
+ expectedLine := strings.ReplaceAll(expectedAndroidMkLines[idx], "meta_lic",
+ OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider).LicenseMetadataFile.String())
if line != expectedLine {
t.Errorf(
"Expected AndroidMk line to be '%s', got '%s'",
diff --git a/android/apex.go b/android/apex.go
index 028be57..79ee0a8 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -475,13 +475,6 @@
AvailableToAnyApex = "//apex_available:anyapex"
)
-var (
- AvailableToRecognziedWildcards = []string{
- AvailableToPlatform,
- AvailableToAnyApex,
- }
-)
-
// CheckAvailableForApex provides the default algorithm for checking the apex availability. When the
// availability is empty, it defaults to ["//apex_available:platform"] which means "available to the
// platform but not available to any APEX". When the list is not empty, `what` is matched against
diff --git a/android/build_prop.go b/android/build_prop.go
index 13d59f9..ede93ed 100644
--- a/android/build_prop.go
+++ b/android/build_prop.go
@@ -63,6 +63,8 @@
return ctx.Config().SystemExtPropFiles(ctx)
} else if partition == "product" {
return ctx.Config().ProductPropFiles(ctx)
+ } else if partition == "odm" {
+ return ctx.Config().OdmPropFiles(ctx)
}
return nil
}
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index 4c92f71..a7b65e0 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -189,8 +189,8 @@
installed = append(installed, ctx.installFiles...)
installed = append(installed, ctx.katiInstalls.InstallPaths()...)
installed = append(installed, ctx.katiSymlinks.InstallPaths()...)
- installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
- installed = append(installed, m.katiVintfInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiInitRcInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiVintfInstalls.InstallPaths()...)
complianceMetadataInfo.SetListValue(ComplianceMetadataProp.INSTALLED_FILES, FirstUniqueStrings(installed.Strings()))
}
ctx.setProvider(ComplianceMetadataProvider, complianceMetadataInfo)
diff --git a/android/config.go b/android/config.go
index 2f6ade7..bbb08dd 100644
--- a/android/config.go
+++ b/android/config.go
@@ -2057,6 +2057,10 @@
return PathsForSource(ctx, c.productVariables.ProductPropFiles)
}
+func (c *config) OdmPropFiles(ctx PathContext) Paths {
+ return PathsForSource(ctx, c.productVariables.OdmPropFiles)
+}
+
func (c *config) EnableUffdGc() string {
return String(c.productVariables.EnableUffdGc)
}
diff --git a/android/makevars.go b/android/makevars.go
index 810eb38..8305d8e 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -281,8 +281,8 @@
if m.ExportedToMake() {
info := OtherModuleProviderOrDefault(ctx, m, InstallFilesProvider)
katiInstalls = append(katiInstalls, info.KatiInstalls...)
- katiInitRcInstalls = append(katiInitRcInstalls, m.base().katiInitRcInstalls...)
- katiVintfManifestInstalls = append(katiVintfManifestInstalls, m.base().katiVintfInstalls...)
+ katiInitRcInstalls = append(katiInitRcInstalls, info.KatiInitRcInstalls...)
+ katiVintfManifestInstalls = append(katiVintfManifestInstalls, info.KatiVintfInstalls...)
katiSymlinks = append(katiSymlinks, info.KatiSymlinks...)
}
})
diff --git a/android/module.go b/android/module.go
index 9e882ec..5d68a87 100644
--- a/android/module.go
+++ b/android/module.go
@@ -87,8 +87,6 @@
ReplacedByPrebuilt()
IsReplacedByPrebuilt() bool
ExportedToMake() bool
- InitRc() Paths
- VintfFragments() Paths
EffectiveLicenseKinds() []string
EffectiveLicenseFiles() Paths
@@ -837,13 +835,6 @@
noAddressSanitizer bool
packagingSpecsDepSet *DepSet[PackagingSpec]
- // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
- // allowed to have duplicates across modules and variants.
- katiInitRcInstalls katiInstalls
- katiVintfInstalls katiInstalls
-
- // The files to copy to the dist as explicitly specified in the .bp file.
- distFiles TaggedDistFiles
hooks hooks
@@ -854,22 +845,9 @@
ruleParams map[blueprint.Rule]blueprint.RuleParams
variables map[string]string
- initRcPaths Paths
- vintfFragmentsPaths Paths
-
- installedInitRcPaths InstallPaths
- installedVintfFragmentsPaths InstallPaths
-
// Merged Aconfig files for all transitive deps.
aconfigFilePaths Paths
- // The path to the generated license metadata file for the module.
- licenseMetadataFile WritablePath
-
- // moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
- // be included in the final module-info.json produced by Make.
- moduleInfoJSON *ModuleInfoJSON
-
// complianceMetadataInfo is for different module types to dump metadata.
// See android.ModuleContext interface.
complianceMetadataInfo *ComplianceMetadataInfo
@@ -1590,18 +1568,6 @@
return m.base().commonProperties.Vintf_fragment_modules.GetOrDefault(m.ConfigurableEvaluator(ctx), nil)
}
-func (m *ModuleBase) InitRc() Paths {
- return append(Paths{}, m.initRcPaths...)
-}
-
-func (m *ModuleBase) VintfFragments() Paths {
- return append(Paths{}, m.vintfFragmentsPaths...)
-}
-
-func (m *ModuleBase) CompileMultilib() *string {
- return m.base().commonProperties.Compile_multilib
-}
-
func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) {
var allInstalledFiles InstallPaths
var allCheckbuildFiles Paths
@@ -1768,12 +1734,26 @@
PackagingSpecs []PackagingSpec
// katiInstalls tracks the install rules that were created by Soong but are being exported
// to Make to convert to ninja rules so that Make can add additional dependencies.
- KatiInstalls katiInstalls
- KatiSymlinks katiInstalls
- TestData []DataPath
- // This was private before, make it private again once we have better solution.
- TransitiveInstallFiles *DepSet[InstallPath]
+ KatiInstalls katiInstalls
+ KatiSymlinks katiInstalls
+ TestData []DataPath
TransitivePackagingSpecs *DepSet[PackagingSpec]
+ LicenseMetadataFile WritablePath
+
+ // The following fields are private before, make it private again once we have
+ // better solution.
+ TransitiveInstallFiles *DepSet[InstallPath]
+ // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
+ // allowed to have duplicates across modules and variants.
+ KatiInitRcInstalls katiInstalls
+ KatiVintfInstalls katiInstalls
+ InitRcPaths Paths
+ VintfFragmentsPaths Paths
+ InstalledInitRcPaths InstallPaths
+ InstalledVintfFragmentsPaths InstallPaths
+
+ // The files to copy to the dist as explicitly specified in the .bp file.
+ DistFiles TaggedDistFiles
}
var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]()
@@ -1799,7 +1779,7 @@
setContainerInfo(ctx)
- m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic")
+ ctx.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic")
dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx)
// set the TransitiveInstallFiles to only the transitive dependencies to be used as the dependencies
@@ -1868,30 +1848,36 @@
// so only a single rule is created for each init.rc or vintf fragment file.
if !m.InVendorRamdisk() {
- m.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc)
+ ctx.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc)
rcDir := PathForModuleInstall(ctx, "etc", "init")
- for _, src := range m.initRcPaths {
+ for _, src := range ctx.initRcPaths {
installedInitRc := rcDir.Join(ctx, src.Base())
- m.katiInitRcInstalls = append(m.katiInitRcInstalls, katiInstall{
+ ctx.katiInitRcInstalls = append(ctx.katiInitRcInstalls, katiInstall{
from: src,
to: installedInitRc,
})
ctx.PackageFile(rcDir, src.Base(), src)
- m.installedInitRcPaths = append(m.installedInitRcPaths, installedInitRc)
+ ctx.installedInitRcPaths = append(ctx.installedInitRcPaths, installedInitRc)
}
+ installFiles.InitRcPaths = ctx.initRcPaths
+ installFiles.KatiInitRcInstalls = ctx.katiInitRcInstalls
+ installFiles.InstalledInitRcPaths = ctx.installedInitRcPaths
}
- m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments.GetOrDefault(ctx, nil))
+ ctx.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments.GetOrDefault(ctx, nil))
vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
- for _, src := range m.vintfFragmentsPaths {
+ for _, src := range ctx.vintfFragmentsPaths {
installedVintfFragment := vintfDir.Join(ctx, src.Base())
- m.katiVintfInstalls = append(m.katiVintfInstalls, katiInstall{
+ ctx.katiVintfInstalls = append(ctx.katiVintfInstalls, katiInstall{
from: src,
to: installedVintfFragment,
})
ctx.PackageFile(vintfDir, src.Base(), src)
- m.installedVintfFragmentsPaths = append(m.installedVintfFragmentsPaths, installedVintfFragment)
+ ctx.installedVintfFragmentsPaths = append(ctx.installedVintfFragmentsPaths, installedVintfFragment)
}
+ installFiles.VintfFragmentsPaths = ctx.vintfFragmentsPaths
+ installFiles.KatiVintfInstalls = ctx.katiVintfInstalls
+ installFiles.InstalledVintfFragmentsPaths = ctx.installedVintfFragmentsPaths
}
licensesPropertyFlattener(ctx)
@@ -1957,6 +1943,13 @@
if ctx.Failed() {
return
}
+
+ if x, ok := m.module.(IDEInfo); ok {
+ var result IdeInfo
+ x.IDEInfo(ctx, &result)
+ result.BaseModuleName = x.BaseModuleName()
+ SetProvider(ctx, IdeInfoProviderKey, result)
+ }
}
if incrementalEnabled && cacheKey != nil {
@@ -1967,11 +1960,12 @@
// as GenerateTaggedDistFiles() calls OutputFiles(tag) and so relies on the
// output paths being set which must be done before or during
// GenerateAndroidBuildActions.
- m.distFiles = m.GenerateTaggedDistFiles(ctx)
+ installFiles.DistFiles = m.GenerateTaggedDistFiles(ctx)
if ctx.Failed() {
return
}
+ installFiles.LicenseMetadataFile = ctx.licenseMetadataFile
installFiles.InstallFiles = ctx.installFiles
installFiles.CheckbuildFiles = ctx.checkbuildFiles
installFiles.PackagingSpecs = ctx.packagingSpecs
@@ -1999,14 +1993,14 @@
installFiles.TransitivePackagingSpecs = m.packagingSpecsDepSet
SetProvider(ctx, InstallFilesProvider, installFiles)
- buildLicenseMetadata(ctx, m.licenseMetadataFile)
+ buildLicenseMetadata(ctx, ctx.licenseMetadataFile)
- if m.moduleInfoJSON != nil {
+ if ctx.moduleInfoJSON != nil {
var installed InstallPaths
installed = append(installed, ctx.katiInstalls.InstallPaths()...)
installed = append(installed, ctx.katiSymlinks.InstallPaths()...)
- installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
- installed = append(installed, m.katiVintfInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiInitRcInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiVintfInstalls.InstallPaths()...)
installedStrings := installed.Strings()
var targetRequired, hostRequired []string
@@ -2021,28 +2015,28 @@
data = append(data, d.ToRelativeInstallPath())
}
- if m.moduleInfoJSON.Uninstallable {
+ if ctx.moduleInfoJSON.Uninstallable {
installedStrings = nil
- if len(m.moduleInfoJSON.CompatibilitySuites) == 1 && m.moduleInfoJSON.CompatibilitySuites[0] == "null-suite" {
- m.moduleInfoJSON.CompatibilitySuites = nil
- m.moduleInfoJSON.TestConfig = nil
- m.moduleInfoJSON.AutoTestConfig = nil
+ if len(ctx.moduleInfoJSON.CompatibilitySuites) == 1 && ctx.moduleInfoJSON.CompatibilitySuites[0] == "null-suite" {
+ ctx.moduleInfoJSON.CompatibilitySuites = nil
+ ctx.moduleInfoJSON.TestConfig = nil
+ ctx.moduleInfoJSON.AutoTestConfig = nil
data = nil
}
}
- m.moduleInfoJSON.core = CoreModuleInfoJSON{
- RegisterName: m.moduleInfoRegisterName(ctx, m.moduleInfoJSON.SubName),
+ ctx.moduleInfoJSON.core = CoreModuleInfoJSON{
+ RegisterName: m.moduleInfoRegisterName(ctx, ctx.moduleInfoJSON.SubName),
Path: []string{ctx.ModuleDir()},
Installed: installedStrings,
- ModuleName: m.BaseModuleName() + m.moduleInfoJSON.SubName,
+ ModuleName: m.BaseModuleName() + ctx.moduleInfoJSON.SubName,
SupportedVariants: []string{m.moduleInfoVariant(ctx)},
TargetDependencies: targetRequired,
HostDependencies: hostRequired,
Data: data,
Required: m.RequiredModuleNames(ctx),
}
- SetProvider(ctx, ModuleInfoJSONProvider, m.moduleInfoJSON)
+ SetProvider(ctx, ModuleInfoJSONProvider, ctx.moduleInfoJSON)
}
m.buildParams = ctx.buildParams
@@ -2741,7 +2735,7 @@
// Collect information for opening IDE project files in java/jdeps.go.
type IDEInfo interface {
- IDEInfo(ideInfo *IdeInfo)
+ IDEInfo(ctx BaseModuleContext, ideInfo *IdeInfo)
BaseModuleName() string
}
@@ -2753,7 +2747,9 @@
IDECustomizedModuleName() string
}
+// Collect information for opening IDE project files in java/jdeps.go.
type IdeInfo struct {
+ BaseModuleName string `json:"-"`
Deps []string `json:"dependencies,omitempty"`
Srcs []string `json:"srcs,omitempty"`
Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
@@ -2767,6 +2763,31 @@
Libs []string `json:"libs,omitempty"`
}
+// Merge merges two IdeInfos and produces a new one, leaving the origional unchanged
+func (i IdeInfo) Merge(other IdeInfo) IdeInfo {
+ return IdeInfo{
+ Deps: mergeStringLists(i.Deps, other.Deps),
+ Srcs: mergeStringLists(i.Srcs, other.Srcs),
+ Aidl_include_dirs: mergeStringLists(i.Aidl_include_dirs, other.Aidl_include_dirs),
+ Jarjar_rules: mergeStringLists(i.Jarjar_rules, other.Jarjar_rules),
+ Jars: mergeStringLists(i.Jars, other.Jars),
+ Classes: mergeStringLists(i.Classes, other.Classes),
+ Installed_paths: mergeStringLists(i.Installed_paths, other.Installed_paths),
+ SrcJars: mergeStringLists(i.SrcJars, other.SrcJars),
+ Paths: mergeStringLists(i.Paths, other.Paths),
+ Static_libs: mergeStringLists(i.Static_libs, other.Static_libs),
+ Libs: mergeStringLists(i.Libs, other.Libs),
+ }
+}
+
+// mergeStringLists appends the two string lists together and returns a new string list,
+// leaving the originals unchanged. Duplicate strings will be deduplicated.
+func mergeStringLists(a, b []string) []string {
+ return FirstUniqueStrings(Concat(a, b))
+}
+
+var IdeInfoProviderKey = blueprint.NewProvider[IdeInfo]()
+
func CheckBlueprintSyntax(ctx BaseModuleContext, filename string, contents string) []error {
bpctx := ctx.blueprintBaseModuleContext()
return blueprint.CheckBlueprintSyntax(bpctx.ModuleFactories(), filename, contents)
diff --git a/android/module_context.go b/android/module_context.go
index 632fc96..5322240 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -246,8 +246,19 @@
// apex containers.
licenseInstallMap []string
+ // The path to the generated license metadata file for the module.
+ licenseMetadataFile WritablePath
+
katiInstalls katiInstalls
katiSymlinks katiInstalls
+ // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
+ // allowed to have duplicates across modules and variants.
+ katiInitRcInstalls katiInstalls
+ katiVintfInstalls katiInstalls
+ initRcPaths Paths
+ vintfFragmentsPaths Paths
+ installedInitRcPaths InstallPaths
+ installedVintfFragmentsPaths InstallPaths
testData []DataPath
@@ -255,6 +266,10 @@
buildParams []BuildParams
ruleParams map[blueprint.Rule]blueprint.RuleParams
variables map[string]string
+
+ // moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
+ // be included in the final module-info.json produced by Make.
+ moduleInfoJSON *ModuleInfoJSON
}
var _ ModuleContext = &moduleContext{}
@@ -532,8 +547,8 @@
if m.requiresFullInstall() {
deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...)
- deps = append(deps, m.module.base().installedInitRcPaths...)
- deps = append(deps, m.module.base().installedVintfFragmentsPaths...)
+ deps = append(deps, m.installedInitRcPaths...)
+ deps = append(deps, m.installedVintfFragmentsPaths...)
var implicitDeps, orderOnlyDeps Paths
@@ -714,15 +729,15 @@
}
func (m *moduleContext) LicenseMetadataFile() Path {
- return m.module.base().licenseMetadataFile
+ return m.licenseMetadataFile
}
func (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
- if moduleInfoJSON := m.module.base().moduleInfoJSON; moduleInfoJSON != nil {
+ if moduleInfoJSON := m.moduleInfoJSON; moduleInfoJSON != nil {
return moduleInfoJSON
}
moduleInfoJSON := &ModuleInfoJSON{}
- m.module.base().moduleInfoJSON = moduleInfoJSON
+ m.moduleInfoJSON = moduleInfoJSON
return moduleInfoJSON
}
diff --git a/android/neverallow.go b/android/neverallow.go
index 0f363e7..a68f5ea 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -287,7 +287,7 @@
continue
}
- if !n.appliesToProperties(properties) {
+ if !n.appliesToProperties(ctx, properties) {
continue
}
@@ -604,9 +604,9 @@
return (len(r.moduleTypes) == 0 || InList(moduleType, r.moduleTypes)) && !InList(moduleType, r.unlessModuleTypes)
}
-func (r *rule) appliesToProperties(properties []interface{}) bool {
- includeProps := hasAllProperties(properties, r.props)
- excludeProps := hasAnyProperty(properties, r.unlessProps)
+func (r *rule) appliesToProperties(ctx BottomUpMutatorContext, properties []interface{}) bool {
+ includeProps := hasAllProperties(ctx, properties, r.props)
+ excludeProps := hasAnyProperty(ctx, properties, r.unlessProps)
return includeProps && !excludeProps
}
@@ -644,25 +644,25 @@
return names
}
-func hasAnyProperty(properties []interface{}, props []ruleProperty) bool {
+func hasAnyProperty(ctx BottomUpMutatorContext, properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
- if hasProperty(properties, v) {
+ if hasProperty(ctx, properties, v) {
return true
}
}
return false
}
-func hasAllProperties(properties []interface{}, props []ruleProperty) bool {
+func hasAllProperties(ctx BottomUpMutatorContext, properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
- if !hasProperty(properties, v) {
+ if !hasProperty(ctx, properties, v) {
return false
}
}
return true
}
-func hasProperty(properties []interface{}, prop ruleProperty) bool {
+func hasProperty(ctx BottomUpMutatorContext, properties []interface{}, prop ruleProperty) bool {
for _, propertyStruct := range properties {
propertiesValue := reflect.ValueOf(propertyStruct).Elem()
for _, v := range prop.fields {
@@ -679,14 +679,14 @@
return prop.matcher.Test(value)
}
- if matchValue(propertiesValue, check) {
+ if matchValue(ctx, propertiesValue, check) {
return true
}
}
return false
}
-func matchValue(value reflect.Value, check func(string) bool) bool {
+func matchValue(ctx BottomUpMutatorContext, value reflect.Value, check func(string) bool) bool {
if !value.IsValid() {
return false
}
@@ -698,19 +698,26 @@
value = value.Elem()
}
- switch value.Kind() {
- case reflect.String:
- return check(value.String())
- case reflect.Bool:
- return check(strconv.FormatBool(value.Bool()))
- case reflect.Int:
- return check(strconv.FormatInt(value.Int(), 10))
- case reflect.Slice:
- slice, ok := value.Interface().([]string)
- if !ok {
- panic("Can only handle slice of string")
+ switch v := value.Interface().(type) {
+ case string:
+ return check(v)
+ case bool:
+ return check(strconv.FormatBool(v))
+ case int:
+ return check(strconv.FormatInt((int64)(v), 10))
+ case []string:
+ for _, v := range v {
+ if check(v) {
+ return true
+ }
}
- for _, v := range slice {
+ return false
+ case proptools.Configurable[string]:
+ return check(v.GetOrDefault(ctx, ""))
+ case proptools.Configurable[bool]:
+ return check(strconv.FormatBool(v.GetOrDefault(ctx, false)))
+ case proptools.Configurable[[]string]:
+ for _, v := range v.GetOrDefault(ctx, nil) {
if check(v) {
return true
}
diff --git a/android/notices.go b/android/notices.go
index b9c1682..3c41d92 100644
--- a/android/notices.go
+++ b/android/notices.go
@@ -36,10 +36,22 @@
return SortedUniqueStrings(dirs)
}
-func modulesLicenseMetadata(ctx BuilderContext, modules ...Module) Paths {
+type BuilderAndOtherModuleProviderContext interface {
+ BuilderContext
+ OtherModuleProviderContext
+}
+
+func modulesLicenseMetadata(ctx OtherModuleProviderContext, modules ...Module) Paths {
result := make(Paths, 0, len(modules))
+ mctx, isMctx := ctx.(ModuleContext)
for _, module := range modules {
- if mf := module.base().licenseMetadataFile; mf != nil {
+ var mf Path
+ if isMctx && mctx.Module() == module {
+ mf = mctx.LicenseMetadataFile()
+ } else {
+ mf = OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider).LicenseMetadataFile
+ }
+ if mf != nil {
result = append(result, mf)
}
}
@@ -48,7 +60,7 @@
// buildNoticeOutputFromLicenseMetadata writes out a notice file.
func buildNoticeOutputFromLicenseMetadata(
- ctx BuilderContext, tool, ruleName string, outputFile WritablePath,
+ ctx BuilderAndOtherModuleProviderContext, tool, ruleName string, outputFile WritablePath,
libraryName string, stripPrefix []string, modules ...Module) {
depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
rule := NewRuleBuilder(pctx, ctx)
@@ -84,7 +96,7 @@
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
func BuildNoticeTextOutputFromLicenseMetadata(
- ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
+ ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string,
stripPrefix []string, modules ...Module) {
buildNoticeOutputFromLicenseMetadata(ctx, "textnotice", "text_notice_"+ruleName,
outputFile, libraryName, stripPrefix, modules...)
@@ -94,7 +106,7 @@
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
func BuildNoticeHtmlOutputFromLicenseMetadata(
- ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
+ ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string,
stripPrefix []string, modules ...Module) {
buildNoticeOutputFromLicenseMetadata(ctx, "htmlnotice", "html_notice_"+ruleName,
outputFile, libraryName, stripPrefix, modules...)
@@ -104,7 +116,7 @@
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
func BuildNoticeXmlOutputFromLicenseMetadata(
- ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
+ ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string,
stripPrefix []string, modules ...Module) {
buildNoticeOutputFromLicenseMetadata(ctx, "xmlnotice", "xml_notice_"+ruleName,
outputFile, libraryName, stripPrefix, modules...)
diff --git a/android/variable.go b/android/variable.go
index 10205e3..14f1756 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -512,6 +512,7 @@
SystemPropFiles []string `json:",omitempty"`
SystemExtPropFiles []string `json:",omitempty"`
ProductPropFiles []string `json:",omitempty"`
+ OdmPropFiles []string `json:",omitempty"`
EnableUffdGc *string `json:",omitempty"`
}
diff --git a/apex/apex.go b/apex/apex.go
index 6286be3..d5776b5 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2230,6 +2230,10 @@
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies
} else if rm, ok := child.(*rust.Module); ok {
+ if !android.IsDepInSameApex(ctx, am, am) {
+ return false
+ }
+
af := apexFileForRustLibrary(ctx, rm)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
@@ -2249,6 +2253,10 @@
}
} else if rust.IsDylibDepTag(depTag) {
if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() {
+ if !android.IsDepInSameApex(ctx, am, am) {
+ return false
+ }
+
af := apexFileForRustLibrary(ctx, rustm)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
@@ -2865,7 +2873,7 @@
}
// Collect information for opening IDE project files in java/jdeps.go.
-func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
+func (a *apexBundle) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 6b9944d..8d34e9f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -906,7 +906,7 @@
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
- shared_libs: ["mylib2", "mylib3"],
+ shared_libs: ["mylib2", "mylib3", "my_prebuilt_platform_lib", "my_prebuilt_platform_stub_only_lib"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
@@ -919,6 +919,7 @@
system_shared_libs: [],
stl: "none",
stubs: {
+ symbol_file: "mylib2.map.txt",
versions: ["1", "2", "3"],
},
}
@@ -930,6 +931,7 @@
system_shared_libs: [],
stl: "none",
stubs: {
+ symbol_file: "mylib3.map.txt",
versions: ["10", "11", "12"],
},
apex_available: [ "myapex" ],
@@ -943,6 +945,24 @@
apex_available: [ "myapex" ],
}
+ cc_prebuilt_library_shared {
+ name: "my_prebuilt_platform_lib",
+ stubs: {
+ symbol_file: "my_prebuilt_platform_lib.map.txt",
+ versions: ["1", "2", "3"],
+ },
+ srcs: ["foo.so"],
+ }
+
+ // Similar to my_prebuilt_platform_lib, but this library only provides stubs, i.e. srcs is empty
+ cc_prebuilt_library_shared {
+ name: "my_prebuilt_platform_stub_only_lib",
+ stubs: {
+ symbol_file: "my_prebuilt_platform_stub_only_lib.map.txt",
+ versions: ["1", "2", "3"],
+ }
+ }
+
rust_binary {
name: "foo.rust",
srcs: ["foo.rs"],
@@ -1022,6 +1042,20 @@
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule")
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libfoo.shared_from_rust.so")
+
+ // Ensure that mylib is linking with the latest version of stubs for my_prebuilt_platform_lib
+ ensureContains(t, mylibLdFlags, "my_prebuilt_platform_lib/android_arm64_armv8-a_shared_current/my_prebuilt_platform_lib.so")
+ // ... and not linking to the non-stub (impl) variant of my_prebuilt_platform_lib
+ ensureNotContains(t, mylibLdFlags, "my_prebuilt_platform_lib/android_arm64_armv8-a_shared/my_prebuilt_platform_lib.so")
+ // Ensure that genstub for platform-provided lib is invoked with --systemapi
+ ensureContains(t, ctx.ModuleForTests("my_prebuilt_platform_lib", "android_arm64_armv8-a_shared_3").Rule("genStubSrc").Args["flags"], "--systemapi")
+
+ // Ensure that mylib is linking with the latest version of stubs for my_prebuilt_platform_lib
+ ensureContains(t, mylibLdFlags, "my_prebuilt_platform_stub_only_lib/android_arm64_armv8-a_shared_current/my_prebuilt_platform_stub_only_lib.so")
+ // ... and not linking to the non-stub (impl) variant of my_prebuilt_platform_lib
+ ensureNotContains(t, mylibLdFlags, "my_prebuilt_platform_stub_only_lib/android_arm64_armv8-a_shared/my_prebuilt_platform_stub_only_lib.so")
+ // Ensure that genstub for platform-provided lib is invoked with --systemapi
+ ensureContains(t, ctx.ModuleForTests("my_prebuilt_platform_stub_only_lib", "android_arm64_armv8-a_shared_3").Rule("genStubSrc").Args["flags"], "--systemapi")
}
func TestApexShouldNotEmbedStubVariant(t *testing.T) {
@@ -1156,6 +1190,7 @@
system_shared_libs: [],
stl: "none",
stubs: {
+ symbol_file: "mylib2.map.txt",
versions: ["28", "29", "30", "current"],
},
min_sdk_version: "28",
@@ -1168,6 +1203,7 @@
system_shared_libs: [],
stl: "none",
stubs: {
+ symbol_file: "mylib3.map.txt",
versions: ["28", "29", "30", "current"],
},
apex_available: [ "myapex" ],
@@ -11940,7 +11976,7 @@
).RunTest(t)
ldRule := result.ModuleForTests("installedlib", "android_arm64_armv8-a_shared").Rule("ld")
- android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared/libfoo.so")
+ android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared_current/libfoo.so")
installRules := result.InstallMakeRulesForTesting(t)
diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go
index 95db37d..d8ee4ba 100644
--- a/apex/dexpreopt_bootjars_test.go
+++ b/apex/dexpreopt_bootjars_test.go
@@ -409,3 +409,106 @@
android.AssertStringListContains(t, tc.desc, inputs, tc.expectedProfile)
}
}
+
+// Check that dexpreopt works with Google mainline prebuilts even in workspaces where source is missing
+func TestDexpreoptWithMainlinePrebuiltNoSource(t *testing.T) {
+ bp := `
+ // Platform.
+
+ platform_bootclasspath {
+ name: "platform-bootclasspath",
+ fragments: [
+ {
+ apex: "com.android.art",
+ module: "art-bootclasspath-fragment",
+ },
+ ],
+ }
+
+ // Source AOSP ART apex
+ java_library {
+ name: "core-oj",
+ srcs: ["core-oj.java"],
+ installable: true,
+ apex_available: [
+ "com.android.art",
+ ],
+ }
+
+ bootclasspath_fragment {
+ name: "art-bootclasspath-fragment",
+ image_name: "art",
+ contents: ["core-oj"],
+ apex_available: [
+ "com.android.art",
+ ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+
+ apex_key {
+ name: "com.android.art.key",
+ public_key: "com.android.art.avbpubkey",
+ private_key: "com.android.art.pem",
+ }
+
+ apex {
+ name: "com.android.art",
+ key: "com.android.art.key",
+ bootclasspath_fragments: ["art-bootclasspath-fragment"],
+ updatable: false,
+ }
+
+
+ // Prebuilt Google ART APEX.
+
+ java_import {
+ name: "core-oj",
+ jars: ["core-oj.jar"],
+ apex_available: [
+ "com.android.art",
+ ],
+ }
+
+ prebuilt_bootclasspath_fragment {
+ name: "art-bootclasspath-fragment",
+ image_name: "art",
+ contents: ["core-oj"],
+ hidden_api: {
+ annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
+ metadata: "my-bootclasspath-fragment/metadata.csv",
+ index: "my-bootclasspath-fragment/index.csv",
+ stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
+ all_flags: "my-bootclasspath-fragment/all-flags.csv",
+ },
+ apex_available: [
+ "com.android.art",
+ ],
+ }
+
+ prebuilt_apex {
+ name: "com.google.android.art",
+ apex_name: "com.android.art",
+ src: "com.android.art-arm.apex",
+ exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
+ }
+
+ apex_contributions {
+ name: "art.prebuilt.contributions",
+ api_domain: "com.android.art",
+ contents: ["prebuilt_com.google.android.art"],
+ }
+ `
+ res := android.GroupFixturePreparers(
+ java.PrepareForTestWithDexpreopt,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureConfigureBootJars("com.android.art:core-oj"),
+ PrepareForTestWithApexBuildComponents,
+ prepareForTestWithArtApex,
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "art.prebuilt.contributions"),
+ ).RunTestWithBp(t, bp)
+ if !java.CheckModuleHasDependency(t, res.TestContext, "dex_bootjars", "android_common", "prebuilt_com.google.android.art") {
+ t.Errorf("Expected dexpreopt to use prebuilt apex")
+ }
+}
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 920fc0c..17ade1d 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -791,6 +791,128 @@
`)
}
+// Skip bcp_fragment content validation of source apexes if prebuilts are active.
+func TestNonBootJarInPrebuilts(t *testing.T) {
+ testCases := []struct {
+ description string
+ selectedApexContributions string
+ expectedError string
+ }{
+ {
+ description: "source is active",
+ selectedApexContributions: "",
+ expectedError: "in contents must also be declared in PRODUCT_APEX_BOOT_JARS",
+ },
+ {
+ description: "prebuilts are active",
+ selectedApexContributions: "myapex.prebuilt.contributions",
+ expectedError: "", // skip content validation of source bcp fragment
+ },
+ }
+ bp := `
+// Source
+apex {
+ name: "myapex",
+ key: "myapex.key",
+ bootclasspath_fragments: ["apex-fragment"],
+ updatable: false,
+ min_sdk_version: "29",
+}
+
+override_apex {
+ name: "myapex.override", // overrides the min_sdk_version, thereby creating different variants of its transitive deps
+ base: "myapex",
+ min_sdk_version: "34",
+}
+
+apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+}
+
+java_library {
+ name: "foo",
+ srcs: ["b.java"],
+ installable: true,
+ apex_available: ["myapex"],
+ permitted_packages: ["foo"],
+ min_sdk_version: "29",
+}
+
+java_library {
+ name: "bar",
+ srcs: ["b.java"],
+ installable: true,
+ apex_available: ["myapex"],
+ permitted_packages: ["bar"],
+ min_sdk_version: "29",
+}
+
+bootclasspath_fragment {
+ name: "apex-fragment",
+ contents: ["foo", "bar"],
+ apex_available:[ "myapex" ],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+}
+
+platform_bootclasspath {
+ name: "myplatform-bootclasspath",
+ fragments: [{
+ apex: "myapex",
+ module:"apex-fragment",
+ }],
+}
+
+// prebuilts
+prebuilt_apex {
+ name: "myapex",
+ apex_name: "myapex",
+ src: "myapex.apex",
+ exported_bootclasspath_fragments: ["apex-fragment"],
+ }
+
+ prebuilt_bootclasspath_fragment {
+ name: "apex-fragment",
+ contents: ["foo"],
+ hidden_api: {
+ annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
+ metadata: "my-bootclasspath-fragment/metadata.csv",
+ index: "my-bootclasspath-fragment/index.csv",
+ stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
+ all_flags: "my-bootclasspath-fragment/all-flags.csv",
+ },
+ }
+ java_import {
+ name: "foo",
+ jars: ["foo.jar"],
+ }
+
+apex_contributions {
+ name: "myapex.prebuilt.contributions",
+ api_domain: "myapex",
+ contents: ["prebuilt_myapex"],
+}
+`
+
+ for _, tc := range testCases {
+ fixture := android.GroupFixturePreparers(
+ prepareForTestWithPlatformBootclasspath,
+ PrepareForTestWithApexBuildComponents,
+ prepareForTestWithMyapex,
+ java.FixtureConfigureApexBootJars("myapex:foo"),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions),
+ )
+ if tc.expectedError != "" {
+ fixture = fixture.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(tc.expectedError))
+ }
+ fixture.RunTestWithBp(t, bp)
+ }
+
+}
+
// Source and prebuilt apex provide different set of boot jars
func TestNonBootJarMissingInPrebuiltFragment(t *testing.T) {
bp := `
diff --git a/cc/cc.go b/cc/cc.go
index 947dc1a..927935c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3042,7 +3042,7 @@
}
if dep.Target().Os != ctx.Os() {
- ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
+ ctx.ModuleErrorf("OS mismatch between %q (%s) and %q (%s)", ctx.ModuleName(), ctx.Os().Name, depName, dep.Target().Os.Name)
return
}
if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 79e386f..93630db 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -927,7 +927,7 @@
cc_prebuilt_library_shared {
name: "libllndkprebuilt",
- stubs: { versions: ["1", "2"] },
+ stubs: { versions: ["1", "2"] , symbol_file: "libllndkprebuilt.map.txt" },
llndk: {
symbol_file: "libllndkprebuilt.map.txt",
},
diff --git a/cc/library.go b/cc/library.go
index 6017848..65a923a 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -594,43 +594,7 @@
return objs
}
if library.buildStubs() {
- symbolFile := String(library.Properties.Stubs.Symbol_file)
- if symbolFile != "" && !strings.HasSuffix(symbolFile, ".map.txt") {
- ctx.PropertyErrorf("symbol_file", "%q doesn't have .map.txt suffix", symbolFile)
- return Objects{}
- }
- library.stubsSymbolFilePath = android.PathForModuleSrc(ctx, symbolFile)
- // b/239274367 --apex and --systemapi filters symbols tagged with # apex and #
- // systemapi, respectively. The former is for symbols defined in platform libraries
- // and the latter is for symbols defined in APEXes.
- // A single library can contain either # apex or # systemapi, but not both.
- // The stub generator (ndkstubgen) is additive, so passing _both_ of these to it should be a no-op.
- // However, having this distinction helps guard accidental
- // promotion or demotion of API and also helps the API review process b/191371676
- var flag string
- if ctx.Module().(android.ApexModule).NotInPlatform() {
- flag = "--apex"
- } else {
- flag = "--systemapi"
- }
- // b/184712170, unless the lib is an NDK library, exclude all public symbols from
- // the stub so that it is mandated that all symbols are explicitly marked with
- // either apex or systemapi.
- if !ctx.Module().(*Module).IsNdk(ctx.Config()) {
- flag = flag + " --no-ndk"
- }
- nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile,
- android.ApiLevelOrPanic(ctx, library.MutatedProperties.StubsVersion), flag)
- objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
- library.versionScriptPath = android.OptionalPathForPath(
- nativeAbiResult.versionScript)
-
- // Parse symbol file to get API list for coverage
- if library.stubsVersion() == "current" && ctx.PrimaryArch() && !ctx.inRecovery() && !ctx.inProduct() && !ctx.inVendor() {
- library.apiListCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile)
- }
-
- return objs
+ return library.compileModuleLibApiStubs(ctx, flags, deps)
}
srcs := library.baseCompiler.Properties.Srcs.GetOrDefault(ctx, nil)
@@ -681,6 +645,61 @@
return objs
}
+// Compile stubs for the API surface between platform and apex
+// This method will be used by source and prebuilt cc module types.
+func (library *libraryDecorator) compileModuleLibApiStubs(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
+ // TODO (b/275273834): Make this a hard error when the symbol files have been added to module sdk.
+ if library.Properties.Stubs.Symbol_file == nil {
+ return Objects{}
+ }
+ symbolFile := String(library.Properties.Stubs.Symbol_file)
+ library.stubsSymbolFilePath = android.PathForModuleSrc(ctx, symbolFile)
+ // b/239274367 --apex and --systemapi filters symbols tagged with # apex and #
+ // systemapi, respectively. The former is for symbols defined in platform libraries
+ // and the latter is for symbols defined in APEXes.
+ // A single library can contain either # apex or # systemapi, but not both.
+ // The stub generator (ndkstubgen) is additive, so passing _both_ of these to it should be a no-op.
+ // However, having this distinction helps guard accidental
+ // promotion or demotion of API and also helps the API review process b/191371676
+ var flag string
+ if ctx.Module().(android.ApexModule).NotInPlatform() {
+ flag = "--apex"
+ } else {
+ flag = "--systemapi"
+ }
+ // b/184712170, unless the lib is an NDK library, exclude all public symbols from
+ // the stub so that it is mandated that all symbols are explicitly marked with
+ // either apex or systemapi.
+ if !ctx.Module().(*Module).IsNdk(ctx.Config()) &&
+ // the symbol files of libclang libs are autogenerated and do not contain systemapi tags
+ // TODO (spandandas): Update mapfile.py to include #systemapi tag on all symbols
+ !strings.Contains(ctx.ModuleName(), "libclang_rt") {
+ flag = flag + " --no-ndk"
+ }
+ // TODO(b/361303067): Remove this special case if bionic/ projects are added to ART development branches.
+ if isBionic(ctx.baseModuleName()) {
+ // set the flags explicitly for bionic libs.
+ // this is necessary for development in minimal branches which does not contain bionic/*.
+ // In such minimal branches, e.g. on the prebuilt libc stubs
+ // 1. IsNdk will return false (since the ndk_library definition for libc does not exist)
+ // 2. NotInPlatform will return true (since the source com.android.runtime does not exist)
+ flag = "--apex"
+ }
+ nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile,
+ android.ApiLevelOrPanic(ctx, library.MutatedProperties.StubsVersion), flag)
+ objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
+
+ library.versionScriptPath = android.OptionalPathForPath(
+ nativeAbiResult.versionScript)
+
+ // Parse symbol file to get API list for coverage
+ if library.stubsVersion() == "current" && ctx.PrimaryArch() && !ctx.inRecovery() && !ctx.inProduct() && !ctx.inVendor() {
+ library.apiListCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile)
+ }
+
+ return objs
+}
+
type libraryInterface interface {
versionedInterface
@@ -1182,12 +1201,17 @@
return unstrippedOutputFile
}
-func addStubDependencyProviders(ctx ModuleContext) {
+// Visits the stub variants of the library and returns a struct containing the stub .so paths
+func addStubDependencyProviders(ctx ModuleContext) []SharedStubLibrary {
+ stubsInfo := []SharedStubLibrary{}
stubs := ctx.GetDirectDepsWithTag(stubImplDepTag)
if len(stubs) > 0 {
- var stubsInfo []SharedStubLibrary
for _, stub := range stubs {
- stubInfo, _ := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
+ stubInfo, ok := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
+ // TODO (b/275273834): Make this a hard error when the symbol files have been added to module sdk.
+ if !ok {
+ continue
+ }
flagInfo, _ := android.OtherModuleProvider(ctx, stub, FlagExporterInfoProvider)
stubsInfo = append(stubsInfo, SharedStubLibrary{
Version: moduleLibraryInterface(stub).stubsVersion(),
@@ -1195,11 +1219,14 @@
FlagExporterInfo: flagInfo,
})
}
- android.SetProvider(ctx, SharedLibraryStubsProvider, SharedLibraryStubsInfo{
- SharedStubLibraries: stubsInfo,
- IsLLNDK: ctx.IsLlndk(),
- })
+ if len(stubsInfo) > 0 {
+ android.SetProvider(ctx, SharedLibraryStubsProvider, SharedLibraryStubsInfo{
+ SharedStubLibraries: stubsInfo,
+ IsLLNDK: ctx.IsLlndk(),
+ })
+ }
}
+ return stubsInfo
}
func (library *libraryDecorator) unstrippedOutputFilePath() android.Path {
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index fb151d8..299fb51 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -16,6 +16,7 @@
import (
"path/filepath"
+ "strings"
"github.com/google/blueprint/proptools"
@@ -95,10 +96,6 @@
return p.libraryDecorator.linkerDeps(ctx, deps)
}
-func (p *prebuiltLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
- return flags
-}
-
func (p *prebuiltLibraryLinker) linkerProps() []interface{} {
return p.libraryDecorator.linkerProps()
}
@@ -117,6 +114,30 @@
// TODO(ccross): verify shared library dependencies
srcs := p.prebuiltSrcs(ctx)
+ stubInfo := addStubDependencyProviders(ctx)
+
+ // Stub variants will create a stub .so file from stub .c files
+ if p.buildStubs() && objs.objFiles != nil {
+ // TODO (b/275273834): Make objs.objFiles == nil a hard error when the symbol files have been added to module sdk.
+
+ // The map.txt files of libclang_rt.* contain version information, but the checked in .so files do not.
+ // e.g. libclang_rt.* libs impl
+ // $ nm -D prebuilts/../libclang_rt.hwasan-aarch64-android.so
+ // __hwasan_init
+
+ // stubs generated from .map.txt
+ // $ nm -D out/soong/.intermediates/../<stubs>/libclang_rt.hwasan-aarch64-android.so
+ // __hwasan_init@@LIBCLANG_RT_ASAN
+
+ // Special-case libclang_rt.* libs to account for this discrepancy.
+ // TODO (spandandas): Remove this special case https://r.android.com/3236596 has been submitted, and a new set of map.txt
+ // files of libclang_rt.* libs have been generated.
+ if strings.Contains(ctx.ModuleName(), "libclang_rt.") {
+ p.versionScriptPath = android.OptionalPathForPath(nil)
+ }
+ return p.linkShared(ctx, flags, deps, objs)
+ }
+
if len(srcs) > 0 {
if len(srcs) > 1 {
ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
@@ -203,6 +224,16 @@
return outputFile
}
+ } else if p.shared() && len(stubInfo) > 0 {
+ // This is a prebuilt which does not have any implementation (nil `srcs`), but provides APIs.
+ // Provide the latest (i.e. `current`) stubs to reverse dependencies.
+ latestStub := stubInfo[len(stubInfo)-1].SharedLibraryInfo.SharedLibrary
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
+ SharedLibrary: latestStub,
+ Target: ctx.Target(),
+ })
+
+ return latestStub
}
if p.header() {
@@ -257,11 +288,11 @@
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported, srcsProperty string) (*Module, *libraryDecorator) {
module, library := NewLibrary(hod)
- module.compiler = nil
prebuilt := &prebuiltLibraryLinker{
libraryDecorator: library,
}
+ module.compiler = prebuilt
module.linker = prebuilt
module.library = prebuilt
@@ -280,6 +311,13 @@
return module, library
}
+func (p *prebuiltLibraryLinker) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
+ if p.buildStubs() && p.stubsVersion() != "" {
+ return p.compileModuleLibApiStubs(ctx, flags, deps)
+ }
+ return Objects{}
+}
+
// cc_prebuilt_library installs a precompiled shared library that are
// listed in the srcs property in the device's directory.
func PrebuiltLibraryFactory() android.Module {
diff --git a/genrule/genrule.go b/genrule/genrule.go
index b8b9968..806b160 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -625,7 +625,7 @@
}
// Collect information for opening IDE project files in java/jdeps.go.
-func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
+func (g *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
for _, src := range g.properties.ResolvedSrcs {
if strings.HasPrefix(src, ":") {
diff --git a/java/aar.go b/java/aar.go
index e6ad502..1bd372f 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -914,12 +914,12 @@
setOutputFiles(ctx, a.Library.Module)
}
-func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) {
- a.Library.IDEInfo(dpInfo)
- a.aapt.IDEInfo(dpInfo)
+func (a *AndroidLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
+ a.Library.IDEInfo(ctx, dpInfo)
+ a.aapt.IDEInfo(ctx, dpInfo)
}
-func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) {
+func (a *aapt) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
if a.rJar != nil {
dpInfo.Jars = append(dpInfo.Jars, a.rJar.String())
}
@@ -1451,6 +1451,6 @@
return module
}
-func (a *AARImport) IDEInfo(dpInfo *android.IdeInfo) {
+func (a *AARImport) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Jars = append(dpInfo.Jars, a.headerJarFile.String(), a.rJar.String())
}
diff --git a/java/app.go b/java/app.go
index 1ebf658..abd78b7 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1243,9 +1243,9 @@
var _ cc.Coverage = (*AndroidApp)(nil)
-func (a *AndroidApp) IDEInfo(dpInfo *android.IdeInfo) {
- a.Library.IDEInfo(dpInfo)
- a.aapt.IDEInfo(dpInfo)
+func (a *AndroidApp) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
+ a.Library.IDEInfo(ctx, dpInfo)
+ a.aapt.IDEInfo(ctx, dpInfo)
}
func (a *AndroidApp) productCharacteristicsRROPackageName() string {
diff --git a/java/base.go b/java/base.go
index 9101457..4cd6021 100644
--- a/java/base.go
+++ b/java/base.go
@@ -2049,7 +2049,7 @@
}
// Collect information for opening IDE project files in java/jdeps.go.
-func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
+func (j *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
// jarjar rules will repackage the sources. To prevent misleading results, IdeInfo should contain the
// repackaged jar instead of the input sources.
if j.expandJarjarRules != nil {
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index bce507a..bef3b58 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -836,7 +836,7 @@
}
// Collect information for opening IDE project files in java/jdeps.go.
-func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) {
+func (b *BootclasspathFragmentModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...)
}
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index 63b69d0..7cc06fc 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -192,7 +192,7 @@
// implement the following interface for IDE completion.
var _ android.IDEInfo = (*DeviceHostConverter)(nil)
-func (d *DeviceHostConverter) IDEInfo(ideInfo *android.IdeInfo) {
+func (d *DeviceHostConverter) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) {
ideInfo.Deps = append(ideInfo.Deps, d.properties.Libs...)
ideInfo.Libs = append(ideInfo.Libs, d.properties.Libs...)
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index e15ebb0..f949b12 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -210,15 +210,19 @@
}
})
// Find the apex variant for this module
- _, apexVariantsWithoutTestApexes, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
+ var apexVariantsWithoutTestApexes []string
+ if apexInfo.BaseApexName != "" {
+ // This is a transitive dependency of an override_apex
+ apexVariantsWithoutTestApexes = []string{apexInfo.BaseApexName}
+ } else {
+ _, apexVariantsWithoutTestApexes, _ = android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
+ }
disableSource := false
// find the selected apexes
for _, apexVariant := range apexVariantsWithoutTestApexes {
- for _, selected := range psi.GetSelectedModulesForApiDomain(apexVariant) {
- // If the apex_contribution for this api domain contains a prebuilt apex, disable the source variant
- if strings.HasPrefix(selected, "prebuilt_com.google.android") {
- disableSource = true
- }
+ if len(psi.GetSelectedModulesForApiDomain(apexVariant)) > 0 {
+ // If the apex_contribution for this api domain is non-empty, disable the source variant
+ disableSource = true
}
}
return disableSource
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index a81ab83..a2e4734 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -558,6 +558,10 @@
apexVariationOfSelected := append(ctx.Target().Variations(), blueprint.Variation{Mutator: "apex", Variation: apex})
if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, selected) {
ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected)
+ } else if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, android.RemoveOptionalPrebuiltPrefix(selected)) {
+ // The prebuilt might have been renamed by prebuilt_rename mutator if the source module does not exist.
+ // Remove the prebuilt_ prefix.
+ ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, android.RemoveOptionalPrebuiltPrefix(selected))
}
}
}
diff --git a/java/java.go b/java/java.go
index 46344c8..55c878e 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2404,15 +2404,15 @@
return al.SdkVersion(ctx).ApiLevel
}
-func (al *ApiLibrary) IDEInfo(i *android.IdeInfo) {
- i.Deps = append(i.Deps, al.ideDeps()...)
+func (al *ApiLibrary) IDEInfo(ctx android.BaseModuleContext, i *android.IdeInfo) {
+ i.Deps = append(i.Deps, al.ideDeps(ctx)...)
i.Libs = append(i.Libs, al.properties.Libs...)
i.Static_libs = append(i.Static_libs, al.properties.Static_libs...)
i.SrcJars = append(i.SrcJars, al.stubsSrcJar.String())
}
// deps of java_api_library for module_bp_java_deps.json
-func (al *ApiLibrary) ideDeps() []string {
+func (al *ApiLibrary) ideDeps(ctx android.BaseModuleContext) []string {
ret := []string{}
ret = append(ret, al.properties.Libs...)
ret = append(ret, al.properties.Static_libs...)
@@ -2933,7 +2933,7 @@
// Collect information for opening IDE project files in java/jdeps.go.
-func (j *Import) IDEInfo(dpInfo *android.IdeInfo) {
+func (j *Import) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Jars = append(dpInfo.Jars, j.combinedHeaderFile.String())
}
diff --git a/java/jdeps.go b/java/jdeps.go
index e856b37..c2ce503 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -57,27 +57,19 @@
return
}
- ideInfoProvider, ok := module.(android.IDEInfo)
+ ideInfoProvider, ok := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
if !ok {
return
}
- name := ideInfoProvider.BaseModuleName()
+ name := ideInfoProvider.BaseModuleName
ideModuleNameProvider, ok := module.(android.IDECustomizedModuleName)
if ok {
name = ideModuleNameProvider.IDECustomizedModuleName()
}
dpInfo := moduleInfos[name]
- ideInfoProvider.IDEInfo(&dpInfo)
- dpInfo.Deps = android.FirstUniqueStrings(dpInfo.Deps)
- dpInfo.Srcs = android.FirstUniqueStrings(dpInfo.Srcs)
- dpInfo.Aidl_include_dirs = android.FirstUniqueStrings(dpInfo.Aidl_include_dirs)
- dpInfo.Jarjar_rules = android.FirstUniqueStrings(dpInfo.Jarjar_rules)
- dpInfo.Jars = android.FirstUniqueStrings(dpInfo.Jars)
- dpInfo.SrcJars = android.FirstUniqueStrings(dpInfo.SrcJars)
+ dpInfo = dpInfo.Merge(ideInfoProvider)
dpInfo.Paths = []string{ctx.ModuleDir(module)}
- dpInfo.Static_libs = android.FirstUniqueStrings(dpInfo.Static_libs)
- dpInfo.Libs = android.FirstUniqueStrings(dpInfo.Libs)
moduleInfos[name] = dpInfo
mkProvider, ok := module.(android.AndroidMkDataProvider)
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index ff54da9..d282f19 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -32,9 +32,7 @@
}
`)
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
- dpInfo := &android.IdeInfo{}
-
- module.IDEInfo(dpInfo)
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
for _, expected := range []string{"Foo", "Bar"} {
if !android.InList(expected, dpInfo.Deps) {
@@ -54,9 +52,7 @@
}
`)
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
- dpInfo := &android.IdeInfo{}
-
- module.IDEInfo(dpInfo)
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
for _, expected := range []string{"Foo", "Bar"} {
if !android.InList(expected, dpInfo.Deps) {
@@ -66,26 +62,36 @@
}
func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
- expected := []string{"Foo", "Bar"}
- module := LibraryFactory().(*Library)
- module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...)
- dpInfo := &android.IdeInfo{}
+ ctx, _ := testJava(t,
+ `
+ java_library {
+ name: "javalib",
+ srcs: ["Foo.java", "Bar.java"],
+ }
+ `)
+ module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
- module.IDEInfo(dpInfo)
-
+ expected := []string{"Foo.java", "Bar.java"}
if !reflect.DeepEqual(dpInfo.Srcs, expected) {
t.Errorf("Library.IDEInfo() Srcs = %v, want %v", dpInfo.Srcs, expected)
}
}
func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
+ ctx, _ := testJava(t,
+ `
+ java_library {
+ name: "javalib",
+ aidl: {
+ include_dirs: ["Foo", "Bar"],
+ },
+ }
+ `)
+ module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
+
expected := []string{"Foo", "Bar"}
- module := LibraryFactory().(*Library)
- module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...)
- dpInfo := &android.IdeInfo{}
-
- module.IDEInfo(dpInfo)
-
if !reflect.DeepEqual(dpInfo.Aidl_include_dirs, expected) {
t.Errorf("Library.IDEInfo() Aidl_include_dirs = %v, want %v", dpInfo.Aidl_include_dirs, expected)
}
@@ -101,9 +107,8 @@
}
`)
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
- dpInfo := &android.IdeInfo{}
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
- module.IDEInfo(dpInfo)
android.AssertBoolEquals(t, "IdeInfo.Srcs of repackaged library should be empty", true, len(dpInfo.Srcs) == 0)
android.AssertStringEquals(t, "IdeInfo.Jar_rules of repackaged library should not be empty", "jarjar_rules.txt", dpInfo.Jarjar_rules[0])
if !android.SubstringInList(dpInfo.Jars, "soong/.intermediates/javalib/android_common/jarjar/turbine/javalib.jar") {
@@ -125,8 +130,7 @@
}
`)
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
- dpInfo := &android.IdeInfo{}
+ dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
- module.IDEInfo(dpInfo)
android.AssertStringListContains(t, "IdeInfo.Deps should contain versioned sdk module", dpInfo.Deps, "sdk_public_29_android")
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 2fe629f..25317c5 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -3599,8 +3599,8 @@
}
// TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library.
-func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) {
- s.Library.IDEInfo(dpInfo)
+func (s *SdkLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
+ s.Library.IDEInfo(ctx, dpInfo)
if s.implLibraryModule != nil {
dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name())
} else {
diff --git a/java/system_modules.go b/java/system_modules.go
index 5b00079..f89bf9e 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -307,7 +307,7 @@
// implement the following interface for IDE completion.
var _ android.IDEInfo = (*SystemModules)(nil)
-func (s *SystemModules) IDEInfo(ideInfo *android.IdeInfo) {
+func (s *SystemModules) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) {
ideInfo.Deps = append(ideInfo.Deps, s.properties.Libs...)
ideInfo.Libs = append(ideInfo.Libs, s.properties.Libs...)
}
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index 3225a3a..924abd4 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -239,7 +239,7 @@
}
// Collect information for opening IDE project files in java/jdeps.go.
-func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) {
+func (s *SystemServerClasspathModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...)
dpInfo.Deps = append(dpInfo.Deps, s.properties.Standalone_contents...)
}
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 533ec62..05b99fd 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -98,6 +98,7 @@
builder.Command().
BuiltTool("conv_linker_config").
Flag("proto").
+ Flag("--force").
FlagWithInput("-s ", input).
FlagWithOutput("-o ", interimOutput)
diff --git a/rust/config/global.go b/rust/config/global.go
index 0c5eb85..990a643 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var (
pctx = android.NewPackageContext("android/soong/rust/config")
- RustDefaultVersion = "1.79.0"
+ RustDefaultVersion = "1.80.1"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/rust/library.go b/rust/library.go
index 50d5a72..7db8f36 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -70,6 +70,10 @@
// Whether this library is part of the Rust toolchain sysroot.
Sysroot *bool
+
+ // Exclude this rust_ffi target from being included in APEXes.
+ // TODO(b/362509506): remove this once stubs are properly supported by rust_ffi targets.
+ Apex_exclude *bool
}
type LibraryMutatedProperties struct {
@@ -122,6 +126,7 @@
shared() bool
sysroot() bool
source() bool
+ apexExclude() bool
// Returns true if the build options for the module have selected a particular build type
buildRlib() bool
@@ -186,6 +191,10 @@
return library.MutatedProperties.VariantIsSource
}
+func (library *libraryDecorator) apexExclude() bool {
+ return Bool(library.Properties.Apex_exclude)
+}
+
func (library *libraryDecorator) buildRlib() bool {
return library.MutatedProperties.BuildRlib && BoolDefault(library.Properties.Rlib.Enabled, true)
}
diff --git a/rust/rust.go b/rust/rust.go
index 3402adc..5a973c4 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -294,6 +294,15 @@
return mod.StaticallyLinked()
}
+func (mod *Module) ApexExclude() bool {
+ if mod.compiler != nil {
+ if library, ok := mod.compiler.(libraryInterface); ok {
+ return library.apexExclude()
+ }
+ }
+ return false
+}
+
func (mod *Module) Object() bool {
// Rust has no modules which produce only object files.
return false
@@ -1863,6 +1872,10 @@
return false
}
+ if rustDep, ok := dep.(*Module); ok && rustDep.ApexExclude() {
+ return false
+ }
+
return true
}