Bob Badour | dc5be90 | 2021-03-15 20:00:01 -0700 | [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 | |
| 17 | func init() { |
| 18 | RegisterLicenseBuildComponents(InitRegistrationContext) |
| 19 | } |
| 20 | |
| 21 | // Register the license module type. |
| 22 | func RegisterLicenseBuildComponents(ctx RegistrationContext) { |
| 23 | ctx.RegisterModuleType("license", LicenseFactory) |
| 24 | } |
| 25 | |
| 26 | type licenseProperties struct { |
| 27 | // Specifies the kinds of license that apply. |
| 28 | License_kinds []string |
| 29 | // Specifies a short copyright notice to use for the license. |
| 30 | Copyright_notice *string |
| 31 | // Specifies the path or label for the text of the license. |
| 32 | License_text []string `android:"path"` |
| 33 | // Specifies the package name to which the license applies. |
| 34 | Package_name *string |
| 35 | // Specifies where this license can be used |
| 36 | Visibility []string |
| 37 | } |
| 38 | |
| 39 | type licenseModule struct { |
| 40 | ModuleBase |
| 41 | DefaultableModuleBase |
| 42 | |
| 43 | properties licenseProperties |
| 44 | } |
| 45 | |
| 46 | func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) { |
| 47 | // Do nothing. |
| 48 | } |
| 49 | |
| 50 | func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 51 | // Nothing to do. |
| 52 | } |
| 53 | |
| 54 | func LicenseFactory() Module { |
| 55 | module := &licenseModule{} |
| 56 | |
| 57 | base := module.base() |
| 58 | module.AddProperties(&base.nameProperties, &module.properties) |
| 59 | |
| 60 | base.generalProperties = module.GetProperties() |
| 61 | base.customizableProperties = module.GetProperties() |
| 62 | |
| 63 | // The visibility property needs to be checked and parsed by the visibility module. |
| 64 | setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility) |
| 65 | |
| 66 | initAndroidModuleBase(module) |
| 67 | InitDefaultableModule(module) |
| 68 | |
| 69 | return module |
| 70 | } |