summaryrefslogtreecommitdiff
path: root/android/license.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/license.go')
-rw-r--r--android/license.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/android/license.go b/android/license.go
index 5bffc2519..7b4aeeb5d 100644
--- a/android/license.go
+++ b/android/license.go
@@ -18,6 +18,15 @@ import (
"github.com/google/blueprint"
)
+type LicenseInfo struct {
+ PackageName *string
+ EffectiveLicenseText NamedPaths
+ EffectiveLicenseKinds []string
+ EffectiveLicenseConditions []string
+}
+
+var LicenseInfoProvider = blueprint.NewProvider[LicenseInfo]()
+
type licenseKindDependencyTag struct {
blueprint.BaseDependencyTag
}
@@ -69,16 +78,24 @@ func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) {
// license modules have no licenses, but license_kinds must refer to license_kind modules
- mergeStringProps(&m.base().commonProperties.Effective_licenses, ctx.ModuleName())
namePathProps(&m.base().commonProperties.Effective_license_text, m.properties.Package_name, PathsForModuleSrc(ctx, m.properties.License_text)...)
- for _, module := range ctx.GetDirectDepsWithTag(licenseKindTag) {
- if lk, ok := module.(*licenseKindModule); ok {
- mergeStringProps(&m.base().commonProperties.Effective_license_conditions, lk.properties.Conditions...)
- mergeStringProps(&m.base().commonProperties.Effective_license_kinds, ctx.OtherModuleName(module))
+ var conditions []string
+ var kinds []string
+ for _, module := range ctx.GetDirectDepsProxyWithTag(licenseKindTag) {
+ if lk, ok := OtherModuleProvider(ctx, module, LicenseKindInfoProvider); ok {
+ conditions = append(conditions, lk.Conditions...)
+ kinds = append(kinds, ctx.OtherModuleName(module))
} else {
ctx.ModuleErrorf("license_kinds property %q is not a license_kind module", ctx.OtherModuleName(module))
}
}
+
+ SetProvider(ctx, LicenseInfoProvider, LicenseInfo{
+ PackageName: m.properties.Package_name,
+ EffectiveLicenseText: m.base().commonProperties.Effective_license_text,
+ EffectiveLicenseKinds: SortedUniqueStrings(kinds),
+ EffectiveLicenseConditions: SortedUniqueStrings(conditions),
+ })
}
func LicenseFactory() Module {