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//
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.
14package snapshot
15
16import (
17	"android/soong/android"
18)
19
20var pctx = android.NewPackageContext("android/soong/snapshot")
21
22func init() {
23	pctx.Import("android/soong/android")
24}
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.
32type SnapshotJsonFlags struct {
33	ModuleName          string `json:",omitempty"`
34	RelativeInstallPath string `json:",omitempty"`
35	Filename            string `json:",omitempty"`
36	ModuleStemName      string `json:",omitempty"`
37	RustProcMacro       bool   `json:",omitempty"`
38	CrateName           string `json:",omitempty"`
39
40	// dependencies
41	Required  []string `json:",omitempty"`
42	Overrides []string `json:",omitempty"`
43
44	// license information
45	LicenseKinds []string `json:",omitempty"`
46	LicenseTexts []string `json:",omitempty"`
47}
48
49func (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
56func (prop *SnapshotJsonFlags) InitBaseSnapshotProps(m android.Module) {
57	prop.InitBaseSnapshotPropsWithName(m, m.Name())
58}
59