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