license_kind.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. package android
  15. func init() {
  16. RegisterLicenseKindBuildComponents(InitRegistrationContext)
  17. }
  18. // Register the license_kind module type.
  19. func RegisterLicenseKindBuildComponents(ctx RegistrationContext) {
  20. ctx.RegisterModuleType("license_kind", LicenseKindFactory)
  21. }
  22. type licenseKindProperties struct {
  23. // Specifies the conditions for all licenses of the kind.
  24. Conditions []string
  25. // Specifies the url to the canonical license definition.
  26. Url string
  27. // Specifies where this license can be used
  28. Visibility []string
  29. }
  30. type licenseKindModule struct {
  31. ModuleBase
  32. DefaultableModuleBase
  33. properties licenseKindProperties
  34. }
  35. func (m *licenseKindModule) DepsMutator(ctx BottomUpMutatorContext) {
  36. // Nothing to do.
  37. }
  38. func (m *licenseKindModule) GenerateAndroidBuildActions(ModuleContext) {
  39. // Nothing to do.
  40. }
  41. func LicenseKindFactory() Module {
  42. module := &licenseKindModule{}
  43. base := module.base()
  44. module.AddProperties(&base.nameProperties, &module.properties)
  45. // The visibility property needs to be checked and parsed by the visibility module.
  46. setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
  47. initAndroidModuleBase(module)
  48. InitDefaultableModule(module)
  49. return module
  50. }