all_aconfig_declarations.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. package aconfig
  15. import (
  16. "android/soong/android"
  17. )
  18. // A singleton module that collects all of the aconfig flags declared in the
  19. // tree into a single combined file for export to the external flag setting
  20. // server (inside Google it's Gantry).
  21. //
  22. // Note that this is ALL aconfig_declarations modules present in the tree, not just
  23. // ones that are relevant to the product currently being built, so that that infra
  24. // doesn't need to pull from multiple builds and merge them.
  25. func AllAconfigDeclarationsFactory() android.Singleton {
  26. return &allAconfigDeclarationsSingleton{}
  27. }
  28. type allAconfigDeclarationsSingleton struct {
  29. intermediatePath android.OutputPath
  30. }
  31. func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
  32. // Find all of the aconfig_declarations modules
  33. var cacheFiles android.Paths
  34. ctx.VisitAllModules(func(module android.Module) {
  35. if !ctx.ModuleHasProvider(module, declarationsProviderKey) {
  36. return
  37. }
  38. decl := ctx.ModuleProvider(module, declarationsProviderKey).(declarationsProviderData)
  39. cacheFiles = append(cacheFiles, decl.IntermediatePath)
  40. })
  41. // Generate build action for aconfig
  42. this.intermediatePath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
  43. ctx.Build(pctx, android.BuildParams{
  44. Rule: allDeclarationsRule,
  45. Inputs: cacheFiles,
  46. Output: this.intermediatePath,
  47. Description: "all_aconfig_declarations",
  48. Args: map[string]string{
  49. "cache_files": android.JoinPathsWithPrefix(cacheFiles, "--cache "),
  50. },
  51. })
  52. ctx.Phony("all_aconfig_declarations", this.intermediatePath)
  53. }
  54. func (this *allAconfigDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) {
  55. ctx.DistForGoal("droid", this.intermediatePath)
  56. }