Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 1 | // Copyright 2021 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 | // |
Colin Cross | d079e0b | 2022-08-16 10:27:33 -0700 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 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 snapshot |
| 15 | |
| 16 | import ( |
| 17 | "android/soong/android" |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 18 | ) |
| 19 | |
Kiyoung Kim | 37693d0 | 2024-04-04 09:56:15 +0900 | [diff] [blame] | 20 | var pctx = android.NewPackageContext("android/soong/snapshot") |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 21 | |
Kiyoung Kim | 37693d0 | 2024-04-04 09:56:15 +0900 | [diff] [blame] | 22 | func init() { |
| 23 | pctx.Import("android/soong/android") |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 24 | } |
Rob Seymour | 925aa09 | 2021-08-10 20:42:03 +0000 | [diff] [blame] | 25 | |
| 26 | // This is to be saved as .json files, which is for development/vendor_snapshot/update.py. |
| 27 | // These flags become Android.bp snapshot module properties. |
| 28 | // |
| 29 | // Attributes are optional and will be populated based on each module's need. |
| 30 | // Common attributes are defined here, languages may extend this struct to add |
| 31 | // additional attributes. |
| 32 | type SnapshotJsonFlags struct { |
| 33 | ModuleName string `json:",omitempty"` |
| 34 | RelativeInstallPath string `json:",omitempty"` |
| 35 | Filename string `json:",omitempty"` |
| 36 | ModuleStemName string `json:",omitempty"` |
Ivan Lozano | 872d579 | 2022-03-23 17:31:39 -0400 | [diff] [blame] | 37 | RustProcMacro bool `json:",omitempty"` |
| 38 | CrateName string `json:",omitempty"` |
Rob Seymour | 925aa09 | 2021-08-10 20:42:03 +0000 | [diff] [blame] | 39 | |
| 40 | // dependencies |
Inseob Kim | a1888ce | 2022-10-04 14:42:02 +0900 | [diff] [blame] | 41 | Required []string `json:",omitempty"` |
| 42 | Overrides []string `json:",omitempty"` |
Justin Yun | 1db9748 | 2023-04-11 18:20:07 +0900 | [diff] [blame] | 43 | |
| 44 | // license information |
| 45 | LicenseKinds []string `json:",omitempty"` |
| 46 | LicenseTexts []string `json:",omitempty"` |
| 47 | } |
| 48 | |
| 49 | func (prop *SnapshotJsonFlags) InitBaseSnapshotPropsWithName(m android.Module, name string) { |
| 50 | prop.ModuleName = name |
| 51 | |
| 52 | prop.LicenseKinds = m.EffectiveLicenseKinds() |
| 53 | prop.LicenseTexts = m.EffectiveLicenseFiles().Strings() |
| 54 | } |
| 55 | |
| 56 | func (prop *SnapshotJsonFlags) InitBaseSnapshotProps(m android.Module) { |
| 57 | prop.InitBaseSnapshotPropsWithName(m, m.Name()) |
Rob Seymour | 925aa09 | 2021-08-10 20:42:03 +0000 | [diff] [blame] | 58 | } |