summaryrefslogtreecommitdiff
path: root/android/sdk.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-05-06 15:53:19 +0100
committer Paul Duffin <paulduffin@google.com> 2021-05-06 23:13:06 +0100
commitb9e7a3ca7afeba46322749b6a3cab10363af76f2 (patch)
tree5186879df05cadd2ad0f688bdb98dd4064ce4f7e /android/sdk.go
parent525a59056552a66cb82a621507eb5ac90c96f9f7 (diff)
Make licenseModule SdkAware
Making licenseModule SdkAware caused two breakages in the build. The breakages were both caused by having an SdkAware module that was depended upon by a versioned sdk snapshot but which was not itself versioned and so did not have the member_name property set. That occured because some default licenses have been added to the packages containing prebuilts, e.g. prebuilts_runtime_license in prebuilts/runtime/Android.bp. They apply to both the versioned and unversioned members. Once license support has been added to the sdk most of those will be removed and replaced with properly versioned license modules. However, in the meantime it is necessary to support that. This change avoids the issue by checking to see whether the module is itself versioned before relying on the member_name property. It also improves the error message when a panic is recovered to make it easier to identify where it originates. Bug: 181569894 Test: m nothing Change-Id: I0e7da2e0c4a30a6f814c2faab821b185aaed2135
Diffstat (limited to 'android/sdk.go')
-rw-r--r--android/sdk.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/android/sdk.go b/android/sdk.go
index 8992bab35..95924561a 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -41,6 +41,11 @@ type sdkAwareWithoutModule interface {
sdkBase() *SdkBase
MakeMemberOf(sdk SdkRef)
IsInAnySdk() bool
+
+ // IsVersioned determines whether the module is versioned, i.e. has a name of the form
+ // <name>@<version>
+ IsVersioned() bool
+
ContainingSdk() SdkRef
MemberName() string
BuildWithSdks(sdks SdkRefs)
@@ -140,6 +145,11 @@ func (s *SdkBase) IsInAnySdk() bool {
return s.properties.ContainingSdk != nil
}
+// IsVersioned returns true if this module is versioned.
+func (s *SdkBase) IsVersioned() bool {
+ return strings.Contains(s.module.Name(), "@")
+}
+
// ContainingSdk returns the SDK that this module is a member of
func (s *SdkBase) ContainingSdk() SdkRef {
if s.properties.ContainingSdk != nil {