export.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2022 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 multitree
  15. import (
  16. "android/soong/android"
  17. "github.com/google/blueprint/proptools"
  18. )
  19. type moduleExportProperty struct {
  20. // True if the module is exported to the other components in a multi-tree.
  21. // Any components in the multi-tree can import this module to use.
  22. Export *bool
  23. }
  24. type ExportableModuleBase struct {
  25. properties moduleExportProperty
  26. }
  27. type Exportable interface {
  28. // Properties for the exporable module.
  29. exportableModuleProps() *moduleExportProperty
  30. // Check if this module can be exported.
  31. // If this returns false, the module will not be exported regardless of the 'export' value.
  32. Exportable() bool
  33. // Returns 'true' if this module has 'export: true'
  34. // This module will not be exported if it returns 'false' to 'Exportable()' interface even if
  35. // it has 'export: true'.
  36. IsExported() bool
  37. // Map from tags to outputs.
  38. // Each module can tag their outputs for convenience.
  39. TaggedOutputs() map[string]android.Paths
  40. }
  41. type ExportableModule interface {
  42. android.Module
  43. android.OutputFileProducer
  44. Exportable
  45. }
  46. func InitExportableModule(module ExportableModule) {
  47. module.AddProperties(module.exportableModuleProps())
  48. }
  49. func (m *ExportableModuleBase) exportableModuleProps() *moduleExportProperty {
  50. return &m.properties
  51. }
  52. func (m *ExportableModuleBase) IsExported() bool {
  53. return proptools.Bool(m.properties.Export)
  54. }