From 0fcd2f3d9995f119cd3da4a248c2f53be4b7bd67 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Mon, 12 Sep 2022 16:06:03 -0700 Subject: [PATCH] Integrate gen_notice with Make for dist. Most exempt module types have no output. Support exempt module types with output by requiring they must be 0p and have no license metadata. Disallow `licenses: []` property on gen_notice. Test: m cts dist Change-Id: Ic992bd6420fa6898495866eac43495002ef4b6c8 Merged-in: Ic992bd6420fa6898495866eac43495002ef4b6c8 --- android/androidmk.go | 14 +++++++++----- android/gen_notice.go | 13 +++++++++++++ android/gen_notice_test.go | 13 +++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 1a9cabd6b..69df3582d 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -366,7 +366,9 @@ func (a *AndroidMkEntries) getDistContributions(mod blueprint.Module) *distContr // Collate the contributions this module makes to the dist. distContributions := &distContributions{} - distContributions.licenseMetadataFile = amod.licenseMetadataFile + if !exemptFromRequiredApplicableLicensesProperty(mod.(Module)) { + distContributions.licenseMetadataFile = amod.licenseMetadataFile + } // Iterate over this module's dist structs, merged from the dist and dists properties. for _, dist := range amod.Dists() { @@ -458,10 +460,12 @@ func generateDistContributionsForMake(distContributions *distContributions) []st ret = append(ret, fmt.Sprintf(".PHONY: %s\n", d.goals)) // Create dist-for-goals calls for each of the copy instructions. for _, c := range d.copies { - ret = append( - ret, - fmt.Sprintf("$(if $(strip $(ALL_TARGETS.%s.META_LIC)),,$(eval ALL_TARGETS.%s.META_LIC := %s))\n", - c.from.String(), c.from.String(), distContributions.licenseMetadataFile.String())) + if distContributions.licenseMetadataFile != nil { + ret = append( + ret, + fmt.Sprintf("$(if $(strip $(ALL_TARGETS.%s.META_LIC)),,$(eval ALL_TARGETS.%s.META_LIC := %s))\n", + c.from.String(), c.from.String(), distContributions.licenseMetadataFile.String())) + } ret = append( ret, fmt.Sprintf("$(call dist-for-goals,%s,%s:%s)\n", d.goals, c.from.String(), c.dest)) diff --git a/android/gen_notice.go b/android/gen_notice.go index 2eb6bec88..008aac5e2 100644 --- a/android/gen_notice.go +++ b/android/gen_notice.go @@ -111,6 +111,9 @@ type genNoticeModule struct { } func (m *genNoticeModule) DepsMutator(ctx BottomUpMutatorContext) { + if ctx.ContainsProperty("licenses") { + ctx.PropertyErrorf("licenses", "not supported on \"gen_notice\" modules") + } if proptools.Bool(m.properties.Html) && proptools.Bool(m.properties.Xml) { ctx.ModuleErrorf("can be html or xml but not both") } @@ -195,6 +198,16 @@ func (m *genNoticeModule) OutputFiles(tag string) (Paths, error) { return nil, fmt.Errorf("unrecognized tag %q", tag) } +var _ AndroidMkEntriesProvider = (*genNoticeModule)(nil) + +// Implements AndroidMkEntriesProvider +func (m *genNoticeModule) AndroidMkEntries() []AndroidMkEntries { + return []AndroidMkEntries{AndroidMkEntries{ + Class: "ETC", + OutputFile: OptionalPathForPath(m.output), + }} +} + // missingReferencesRule emits an ErrorRule for missing module references. func missingReferencesRule(ctx BuilderContext, m *genNoticeModule) { if len(m.missing) < 1 { diff --git a/android/gen_notice_test.go b/android/gen_notice_test.go index b45ce4f94..99d982bda 100644 --- a/android/gen_notice_test.go +++ b/android/gen_notice_test.go @@ -11,6 +11,19 @@ var genNoticeTests = []struct { fs MockFS expectedErrors []string }{ + { + name: "gen_notice must not accept licenses property", + fs: map[string][]byte{ + "top/Android.bp": []byte(` + gen_notice { + name: "top_license", + licenses: ["other_license"], + }`), + }, + expectedErrors: []string{ + `not supported on "gen_notice" modules`, + }, + }, { name: "bad gen_notice", fs: map[string][]byte{