Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 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 | |
| 15 | package android |
| 16 | |
Yu Liu | ddccb2a | 2025-01-17 20:04:46 +0000 | [diff] [blame^] | 17 | import "github.com/google/blueprint" |
| 18 | |
| 19 | type LicenseKindInfo struct { |
| 20 | Conditions []string |
| 21 | } |
| 22 | |
| 23 | var LicenseKindInfoProvider = blueprint.NewProvider[LicenseKindInfo]() |
| 24 | |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 25 | func init() { |
| 26 | RegisterLicenseKindBuildComponents(InitRegistrationContext) |
| 27 | } |
| 28 | |
| 29 | // Register the license_kind module type. |
| 30 | func RegisterLicenseKindBuildComponents(ctx RegistrationContext) { |
| 31 | ctx.RegisterModuleType("license_kind", LicenseKindFactory) |
| 32 | } |
| 33 | |
| 34 | type 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 | |
| 43 | type licenseKindModule struct { |
| 44 | ModuleBase |
| 45 | DefaultableModuleBase |
| 46 | |
| 47 | properties licenseKindProperties |
| 48 | } |
| 49 | |
| 50 | func (m *licenseKindModule) DepsMutator(ctx BottomUpMutatorContext) { |
| 51 | // Nothing to do. |
| 52 | } |
| 53 | |
Yu Liu | ddccb2a | 2025-01-17 20:04:46 +0000 | [diff] [blame^] | 54 | func (m *licenseKindModule) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 55 | SetProvider(ctx, LicenseKindInfoProvider, LicenseKindInfo{ |
| 56 | Conditions: m.properties.Conditions, |
| 57 | }) |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | func LicenseKindFactory() Module { |
| 61 | module := &licenseKindModule{} |
| 62 | |
| 63 | base := module.base() |
Colin Cross | 8ff1058 | 2023-12-07 13:10:56 -0800 | [diff] [blame] | 64 | module.AddProperties(&base.nameProperties, &module.properties) |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 65 | |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 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) |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 71 | |
| 72 | return module |
| 73 | } |