blob: 1a339577382c7a7aa251efe5753e0fbee2ca9639 [file] [log] [blame]
Vinh Tran0ccc2322023-03-09 22:07:19 -05001// Copyright 2023 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 cc
16
17import (
18 "android/soong/android"
Vinh Tran0ccc2322023-03-09 22:07:19 -050019 "github.com/google/blueprint"
20)
21
22func init() {
23 RegisterFdoProfileBuildComponents(android.InitRegistrationContext)
24}
25
26func RegisterFdoProfileBuildComponents(ctx android.RegistrationContext) {
Vinh Trance40b922023-06-05 12:57:55 -040027 ctx.RegisterModuleType("fdo_profile", FdoProfileFactory)
Vinh Tran0ccc2322023-03-09 22:07:19 -050028}
29
30type fdoProfile struct {
31 android.ModuleBase
32
33 properties fdoProfileProperties
34}
35
36type fdoProfileProperties struct {
37 Profile *string `android:"arch_variant"`
38}
39
40// FdoProfileInfo is provided by FdoProfileProvider
41type FdoProfileInfo struct {
42 Path android.Path
43}
44
45// FdoProfileProvider is used to provide path to an fdo profile
Colin Cross3513fb12024-01-24 14:44:47 -080046var FdoProfileProvider = blueprint.NewProvider[FdoProfileInfo]()
Vinh Tran0ccc2322023-03-09 22:07:19 -050047
48// GenerateAndroidBuildActions of fdo_profile does not have any build actions
Colin Cross3513fb12024-01-24 14:44:47 -080049func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Vinh Tran0ccc2322023-03-09 22:07:19 -050050 if fp.properties.Profile != nil {
51 path := android.PathForModuleSrc(ctx, *fp.properties.Profile)
Colin Cross40213022023-12-13 15:19:49 -080052 android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{
Vinh Tran0ccc2322023-03-09 22:07:19 -050053 Path: path,
54 })
55 }
56}
57
Vinh Trance40b922023-06-05 12:57:55 -040058func FdoProfileFactory() android.Module {
Vinh Tran0ccc2322023-03-09 22:07:19 -050059 m := &fdoProfile{}
60 m.AddProperties(&m.properties)
61 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibBoth)
Vinh Tran0ccc2322023-03-09 22:07:19 -050062 return m
63}