diff options
Diffstat (limited to 'aconfig/build_flags/release_configs.go')
| -rw-r--r-- | aconfig/build_flags/release_configs.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/aconfig/build_flags/release_configs.go b/aconfig/build_flags/release_configs.go index 3fa8a7c02..b5012152b 100644 --- a/aconfig/build_flags/release_configs.go +++ b/aconfig/build_flags/release_configs.go @@ -15,6 +15,7 @@ package build_flags import ( + "fmt" "path/filepath" "android/soong/android" @@ -28,6 +29,12 @@ type ReleaseConfigContributionsProviderData struct { var ReleaseConfigContributionsProviderKey = blueprint.NewProvider[ReleaseConfigContributionsProviderData]() +type AllReleaseConfigsProviderData struct { + AllReleaseConfigsPath android.Path +} + +var AllReleaseConfigsProviderKey = blueprint.NewProvider[AllReleaseConfigsProviderData]() + // Soong uses `release_config_contributions` modules to produce the // `build_flags/all_release_config_contributions.*` artifacts, listing *all* of // the directories in the source tree that contribute to each release config, @@ -76,3 +83,49 @@ func (module *ReleaseConfigContributionsModule) GenerateAndroidBuildActions(ctx }) } + +// Soong provides release config informamtion via an `all_release_configs` module. +// +// This module can be used by test modules that need to inspect release configs. +type AllReleaseConfigsModule struct { + android.ModuleBase + android.DefaultableModuleBase + + // There are no extra properties for "all_release_configs". + properties struct{} +} + +func AllReleaseConfigsFactory() android.Module { + module := &AllReleaseConfigsModule{} + + android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) + android.InitDefaultableModule(module) + module.AddProperties(&module.properties) + + return module +} + +func (module *AllReleaseConfigsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { + if !ctx.Config().HasDeviceProduct() { + return + } + // The 'release-config' command is called for every build, and generates the + // all_release_configs-${TARGET_PRODUCT}.pb file. + srcPath := android.PathForOutput(ctx, "release-config", fmt.Sprintf("all_release_configs-%s.pb", ctx.Config().DeviceProduct())) + outputPath := android.PathForModuleOut(ctx, "all_release_configs.pb") + + ctx.Phony("droid", outputPath) + ctx.Phony("all_release_configs", outputPath) + + // Update the output file only if the source file is changed. + ctx.Build(pctx, android.BuildParams{ + Rule: android.CpIfChanged, + Input: srcPath, + Output: outputPath, + }) + ctx.SetOutputFiles(android.Paths{outputPath}, "") + + android.SetProvider(ctx, AllReleaseConfigsProviderKey, AllReleaseConfigsProviderData{ + AllReleaseConfigsPath: outputPath, + }) +} |
