diff options
author | 2024-03-13 01:13:21 +0000 | |
---|---|---|
committer | 2024-03-13 01:13:21 +0000 | |
commit | 86cc1e896b952df87592f42bc02786f5c9357dcf (patch) | |
tree | 76d517285fe649bed34c5035d0600af24cb41ebc /apex/apex_singleton.go | |
parent | 66e8a75700edf18c9d594077e23637da727a7655 (diff) | |
parent | a747d2ec486415f80c7b0724fad62f5575d08853 (diff) |
Merge "Generate info about the selected apex variant in platform builds" into main
Diffstat (limited to 'apex/apex_singleton.go')
-rw-r--r-- | apex/apex_singleton.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index 25c0cc444..8aaddbe25 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -17,6 +17,8 @@ package apex import ( + "encoding/json" + "github.com/google/blueprint" "android/soong/android" @@ -129,3 +131,43 @@ func (s *apexDepsInfoSingleton) MakeVars(ctx android.MakeVarsContext) { // Export check result to Make. The path is added to droidcore. ctx.Strict("APEX_ALLOWED_DEPS_CHECK", s.allowedApexDepsInfoCheckResult.String()) } + +func init() { + registerApexPrebuiltInfoComponents(android.InitRegistrationContext) +} + +func registerApexPrebuiltInfoComponents(ctx android.RegistrationContext) { + ctx.RegisterParallelSingletonType("apex_prebuiltinfo_singleton", apexPrebuiltInfoFactory) +} + +func apexPrebuiltInfoFactory() android.Singleton { + return &apexPrebuiltInfo{} +} + +type apexPrebuiltInfo struct { + out android.WritablePath +} + +func (a *apexPrebuiltInfo) GenerateBuildActions(ctx android.SingletonContext) { + prebuiltInfos := []prebuiltInfo{} + + ctx.VisitAllModules(func(m android.Module) { + prebuiltInfo, exists := android.SingletonModuleProvider(ctx, m, prebuiltInfoProvider) + // Use prebuiltInfoProvider to filter out non apex soong modules. + // Use HideFromMake to filter out the unselected variants of a specific apex. + if exists && !m.IsHideFromMake() { + prebuiltInfos = append(prebuiltInfos, prebuiltInfo) + } + }) + + j, err := json.Marshal(prebuiltInfos) + if err != nil { + ctx.Errorf("Could not convert prebuilt info of apexes to json due to error: %v", err) + } + a.out = android.PathForOutput(ctx, "prebuilt_info.json") + android.WriteFileRule(ctx, a.out, string(j)) +} + +func (a *apexPrebuiltInfo) MakeVars(ctx android.MakeVarsContext) { + ctx.DistForGoal("droidcore", a.out) +} |