summaryrefslogtreecommitdiff
path: root/android/sdk.go
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2022-05-12 20:40:00 -0400
committer Liz Kammer <eakammer@google.com> 2022-05-23 10:51:22 -0400
commit96320dfff8fd5859a5e5f2a5c74bf8d79dd6499d (patch)
tree2daf8bf3214a0fe1d79d0a668c8f56149126e7fd /android/sdk.go
parent4dd76eb26c6f673a85d1c33c504e3beb1324bcdb (diff)
Handle multiple linkages in sdk snapshots
Currently, if the same library is specified for multiple of native_libs, native_shared_libs, and native_static_libs for different arch/oses, there can be a few errors: 1. specifying a .so file as `srcs` within a cc_prebuilt_library rather than being specified only for shared 2. the final type of prebuilt library is dependent on the arch/os This change introduces: * an ability for a member type to override the type for specified properties * checks for a library being used with incompatible member types * basing linkage nesting on the member type in addition to variants This will ensure that the correct library type is used, regardless of the order of iteration over oses/arches, and support nesting linkages where necessary but only one linkage variant exists. Test: soong tests Test: CI Change-Id: I81dee013b09b99c34ca6c18f9cfcc12ee56d33d1
Diffstat (limited to 'android/sdk.go')
-rw-r--r--android/sdk.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/android/sdk.go b/android/sdk.go
index 3a5624030..f0fa7260b 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -670,6 +670,9 @@ type SdkMemberType interface {
// host OS variant explicitly and disable all other host OS'es.
IsHostOsDependent() bool
+ // SupportedLinkages returns the names of the linkage variants supported by this module.
+ SupportedLinkages() []string
+
// AddDependencies adds dependencies from the SDK module to all the module variants the member
// type contributes to the SDK. `names` is the list of module names given in the member type
// property (as returned by SdkPropertyName()) in the SDK module. The exact set of variants
@@ -733,6 +736,9 @@ type SdkMemberType interface {
// SupportedTraits returns the set of traits supported by this member type.
SupportedTraits() SdkMemberTraitSet
+
+ // Overrides returns whether type overrides other SdkMemberType
+ Overrides(SdkMemberType) bool
}
var _ sdkRegisterable = (SdkMemberType)(nil)
@@ -756,6 +762,13 @@ type SdkDependencyContext interface {
type SdkMemberTypeBase struct {
PropertyName string
+ // Property names that this SdkMemberTypeBase can override, this is useful when a module type is a
+ // superset of another module type.
+ OverridesPropertyNames map[string]bool
+
+ // The names of linkage variants supported by this module.
+ SupportedLinkageNames []string
+
// When set to true BpPropertyNotRequired indicates that the member type does not require the
// property to be specifiable in an Android.bp file.
BpPropertyNotRequired bool
@@ -796,6 +809,14 @@ func (b *SdkMemberTypeBase) SupportedTraits() SdkMemberTraitSet {
return NewSdkMemberTraitSet(b.Traits)
}
+func (b *SdkMemberTypeBase) Overrides(other SdkMemberType) bool {
+ return b.OverridesPropertyNames[other.SdkPropertyName()]
+}
+
+func (b *SdkMemberTypeBase) SupportedLinkages() []string {
+ return b.SupportedLinkageNames
+}
+
// registeredModuleExportsMemberTypes is the set of registered SdkMemberTypes for module_exports
// modules.
var registeredModuleExportsMemberTypes = &sdkRegistry{}