• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
17import "github.com/google/blueprint"
18
19type LicenseKindInfo struct {
20	Conditions []string
21}
22
23var LicenseKindInfoProvider = blueprint.NewProvider[LicenseKindInfo]()
24
25func 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
54func (m *licenseKindModule) GenerateAndroidBuildActions(ctx ModuleContext) {
55	SetProvider(ctx, LicenseKindInfoProvider, LicenseKindInfo{
56		Conditions: m.properties.Conditions,
57	})
58}
59
60func LicenseKindFactory() Module {
61	module := &licenseKindModule{}
62
63	base := module.base()
64	module.AddProperties(&base.nameProperties, &module.properties)
65
66	// 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)
71
72	return module
73}
74