Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 19 | "github.com/google/blueprint" |
Yi Kong | e2ec01c | 2025-03-19 15:20:37 +0900 | [diff] [blame] | 20 | |
| 21 | "github.com/google/blueprint/proptools" |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | func init() { |
| 25 | RegisterFdoProfileBuildComponents(android.InitRegistrationContext) |
| 26 | } |
| 27 | |
| 28 | func RegisterFdoProfileBuildComponents(ctx android.RegistrationContext) { |
Vinh Tran | ce40b92 | 2023-06-05 12:57:55 -0400 | [diff] [blame] | 29 | ctx.RegisterModuleType("fdo_profile", FdoProfileFactory) |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | type fdoProfile struct { |
| 33 | android.ModuleBase |
| 34 | |
| 35 | properties fdoProfileProperties |
| 36 | } |
| 37 | |
| 38 | type fdoProfileProperties struct { |
Yi Kong | e2ec01c | 2025-03-19 15:20:37 +0900 | [diff] [blame] | 39 | Profile proptools.Configurable[string] `android:"arch_variant,replace_instead_of_append"` |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | // FdoProfileInfo is provided by FdoProfileProvider |
| 43 | type FdoProfileInfo struct { |
| 44 | Path android.Path |
| 45 | } |
| 46 | |
| 47 | // FdoProfileProvider is used to provide path to an fdo profile |
Colin Cross | 3513fb1 | 2024-01-24 14:44:47 -0800 | [diff] [blame] | 48 | var FdoProfileProvider = blueprint.NewProvider[FdoProfileInfo]() |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 49 | |
| 50 | // GenerateAndroidBuildActions of fdo_profile does not have any build actions |
Colin Cross | 3513fb1 | 2024-01-24 14:44:47 -0800 | [diff] [blame] | 51 | func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Yi Kong | e2ec01c | 2025-03-19 15:20:37 +0900 | [diff] [blame] | 52 | profile := fp.properties.Profile.GetOrDefault(ctx, "") |
| 53 | if profile != "" { |
| 54 | path := android.PathForModuleSrc(ctx, profile) |
Colin Cross | 4021302 | 2023-12-13 15:19:49 -0800 | [diff] [blame] | 55 | android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{ |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 56 | Path: path, |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
Vinh Tran | ce40b92 | 2023-06-05 12:57:55 -0400 | [diff] [blame] | 61 | func FdoProfileFactory() android.Module { |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 62 | m := &fdoProfile{} |
| 63 | m.AddProperties(&m.properties) |
| 64 | android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibBoth) |
Vinh Tran | 0ccc232 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 65 | return m |
| 66 | } |