Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 1 | // Copyright (C) 2022 The Android Open Source Project |
| 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 apex |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "github.com/google/blueprint" |
| 20 | "github.com/google/blueprint/proptools" |
| 21 | ) |
| 22 | |
| 23 | // This file contains support for using apex modules within an sdk. |
| 24 | |
| 25 | func init() { |
| 26 | // Register sdk member types. |
| 27 | android.RegisterSdkMemberType(&apexSdkMemberType{ |
| 28 | SdkMemberTypeBase: android.SdkMemberTypeBase{ |
| 29 | PropertyName: "apexes", |
| 30 | SupportsSdk: true, |
| 31 | |
| 32 | // The apexes property does not need to be included in the snapshot as adding an apex to an |
| 33 | // sdk does not produce any prebuilts of the apex. |
| 34 | PrebuiltsRequired: proptools.BoolPtr(false), |
| 35 | }, |
| 36 | }) |
| 37 | } |
| 38 | |
| 39 | type apexSdkMemberType struct { |
| 40 | android.SdkMemberTypeBase |
| 41 | } |
| 42 | |
| 43 | func (mt *apexSdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) { |
| 44 | ctx.AddVariationDependencies(nil, dependencyTag, names...) |
| 45 | } |
| 46 | |
| 47 | func (mt *apexSdkMemberType) IsInstance(module android.Module) bool { |
| 48 | _, ok := module.(*apexBundle) |
| 49 | return ok |
| 50 | } |
| 51 | |
| 52 | func (mt *apexSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { |
| 53 | panic("Sdk does not create prebuilts of the apexes in its snapshot") |
| 54 | } |
| 55 | |
| 56 | func (mt *apexSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { |
| 57 | panic("Sdk does not create prebuilts of the apexes in its snapshot") |
| 58 | } |