From df5a90502d6d7980a699d8f32a12fc46e700dde6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 6 May 2021 21:52:31 +0100 Subject: [PATCH] Move license module processing to GenerateAndroidBuildActions Previously, the processing of the license module was done in the licensesPropertyFlattener method which is called for all modules before their GenerateAndroidBuildActions method is called. This change moves the processing into the license module's GenerateAndroidBuildActions method which was previously empty to match the normal practice. Bug: 181569894 Test: m nothing Change-Id: I3736879bfa4b4d1f4e2b35770852a02d09b3db83 --- android/license.go | 12 +++++++++++- android/licenses.go | 15 --------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/android/license.go b/android/license.go index cb375a2e5..d571b1f35 100644 --- a/android/license.go +++ b/android/license.go @@ -61,7 +61,17 @@ func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) { } func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) { - // Nothing to do. + // license modules have no licenses, but license_kinds must refer to license_kind modules + mergeProps(&m.base().commonProperties.Effective_licenses, ctx.ModuleName()) + mergeProps(&m.base().commonProperties.Effective_license_text, PathsForModuleSrc(ctx, m.properties.License_text).Strings()...) + for _, module := range ctx.GetDirectDepsWithTag(licenseKindTag) { + if lk, ok := module.(*licenseKindModule); ok { + mergeProps(&m.base().commonProperties.Effective_license_conditions, lk.properties.Conditions...) + mergeProps(&m.base().commonProperties.Effective_license_kinds, ctx.OtherModuleName(module)) + } else { + ctx.ModuleErrorf("license_kinds property %q is not a license_kind module", ctx.OtherModuleName(module)) + } + } } func LicenseFactory() Module { diff --git a/android/licenses.go b/android/licenses.go index 2838f5d28..933c2f7df 100644 --- a/android/licenses.go +++ b/android/licenses.go @@ -187,21 +187,6 @@ func licensesPropertyFlattener(ctx ModuleContext) { return } - // license modules have no licenses, but license_kinds must refer to license_kind modules - if l, ok := m.(*licenseModule); ok { - mergeProps(&m.base().commonProperties.Effective_licenses, ctx.ModuleName()) - mergeProps(&m.base().commonProperties.Effective_license_text, PathsForModuleSrc(ctx, l.properties.License_text).Strings()...) - for _, module := range ctx.GetDirectDepsWithTag(licenseKindTag) { - if lk, ok := module.(*licenseKindModule); ok { - mergeProps(&m.base().commonProperties.Effective_license_conditions, lk.properties.Conditions...) - mergeProps(&m.base().commonProperties.Effective_license_kinds, ctx.OtherModuleName(module)) - } else { - ctx.ModuleErrorf("license_kinds property %q is not a license_kind module", ctx.OtherModuleName(module)) - } - } - return - } - if exemptFromRequiredApplicableLicensesProperty(m) { return }