blob: ad37f28c9ff786e6830dcb1fd063192ecd072c97 [file] [log] [blame]
Ronald Braunstein73b08ff2023-12-19 10:24:47 -08001// Copyright 2020 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
15package android
16
Ronald Braunsteinc5603092024-03-27 06:46:47 -070017import "github.com/google/blueprint"
18
Ronald Braunstein73b08ff2023-12-19 10:24:47 -080019func init() {
20 RegisterTeamBuildComponents(InitRegistrationContext)
21}
22
23func RegisterTeamBuildComponents(ctx RegistrationContext) {
24 ctx.RegisterModuleType("team", TeamFactory)
25}
26
27var PrepareForTestWithTeamBuildComponents = GroupFixturePreparers(
28 FixtureRegisterWithContext(RegisterTeamBuildComponents),
29)
30
31type teamProperties struct {
32 Trendy_team_id *string `json:"trendy_team_id"`
33}
34
Yu Liu95cef3a2025-02-25 00:54:20 +000035type TeamInfo struct {
36 Properties teamProperties
37}
38
39var TeamInfoProvider = blueprint.NewProvider[TeamInfo]()
40
Ronald Braunstein73b08ff2023-12-19 10:24:47 -080041type teamModule struct {
42 ModuleBase
43 DefaultableModuleBase
44
45 properties teamProperties
46}
47
Ronald Braunsteinc5603092024-03-27 06:46:47 -070048type TestModuleInformation struct {
49 TestOnly bool
50 TopLevelTarget bool
51}
52
53var TestOnlyProviderKey = blueprint.NewProvider[TestModuleInformation]()
54
Ronald Braunstein73b08ff2023-12-19 10:24:47 -080055// Real work is done for the module that depends on us.
56// If needed, the team can serialize the config to json/proto file as well.
Yu Liu95cef3a2025-02-25 00:54:20 +000057func (t *teamModule) GenerateAndroidBuildActions(ctx ModuleContext) {
58 SetProvider(ctx, TeamInfoProvider, TeamInfo{
59 Properties: t.properties,
60 })
61}
Ronald Braunstein73b08ff2023-12-19 10:24:47 -080062
63func (t *teamModule) TrendyTeamId(ctx ModuleContext) string {
64 return *t.properties.Trendy_team_id
65}
66
67func TeamFactory() Module {
68 module := &teamModule{}
69
70 base := module.base()
71 module.AddProperties(&base.nameProperties, &module.properties)
72
73 InitAndroidModule(module)
74 InitDefaultableModule(module)
75
76 return module
77}