blob: 1ca695449cec78f00292455d01293eb7908626fd [file] [log] [blame]
Bob Badour37af0462021-01-07 03:34:31 +00001// Copyright 2020 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
Yu Liuddccb2a2025-01-17 20:04:46 +000017import "github.com/google/blueprint"
18
19type LicenseKindInfo struct {
20 Conditions []string
21}
22
23var LicenseKindInfoProvider = blueprint.NewProvider[LicenseKindInfo]()
24
Bob Badour37af0462021-01-07 03:34:31 +000025func init() {
26 RegisterLicenseKindBuildComponents(InitRegistrationContext)
27}
28
29// Register the license_kind module type.
30func RegisterLicenseKindBuildComponents(ctx RegistrationContext) {
31 ctx.RegisterModuleType("license_kind", LicenseKindFactory)
32}
33
34type licenseKindProperties struct {
35 // Specifies the conditions for all licenses of the kind.
36 Conditions []string
37 // Specifies the url to the canonical license definition.
38 Url string
39 // Specifies where this license can be used
40 Visibility []string
41}
42
43type licenseKindModule struct {
44 ModuleBase
45 DefaultableModuleBase
46
47 properties licenseKindProperties
48}
49
50func (m *licenseKindModule) DepsMutator(ctx BottomUpMutatorContext) {
51 // Nothing to do.
52}
53
Yu Liuddccb2a2025-01-17 20:04:46 +000054func (m *licenseKindModule) GenerateAndroidBuildActions(ctx ModuleContext) {
55 SetProvider(ctx, LicenseKindInfoProvider, LicenseKindInfo{
56 Conditions: m.properties.Conditions,
57 })
Bob Badour37af0462021-01-07 03:34:31 +000058}
59
60func LicenseKindFactory() Module {
61 module := &licenseKindModule{}
62
63 base := module.base()
Colin Cross8ff10582023-12-07 13:10:56 -080064 module.AddProperties(&base.nameProperties, &module.properties)
Bob Badour37af0462021-01-07 03:34:31 +000065
Bob Badour37af0462021-01-07 03:34:31 +000066 // The visibility property needs to be checked and parsed by the visibility module.
67 setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
68
69 initAndroidModuleBase(module)
70 InitDefaultableModule(module)
Bob Badour37af0462021-01-07 03:34:31 +000071
72 return module
73}