Make buildinfo_prop a regular module

Singleton modules have the capability to do a lot more than regular
modules, which is often problematic for incremental builds.
buildinfo_prop wasn't using those capabilities, so make it a regular
module type to prove it.

Bug: 332733525
Test: m out/target/product/emu64x/obj/ETC/buildinfo.prop_intermediates/buildinfo.prop
Change-Id: I288bf2fd4727a17ff299272d4cfcc611e064c55a
This commit is contained in:
Cole Faust 2024-06-06 14:49:23 -07:00
parent 89b4d18ba1
commit a700d7fa9f

View file

@ -23,7 +23,7 @@ import (
func init() {
ctx := InitRegistrationContext
ctx.RegisterParallelSingletonModuleType("buildinfo_prop", buildinfoPropFactory)
ctx.RegisterModuleType("buildinfo_prop", buildinfoPropFactory)
}
type buildinfoPropProperties struct {
@ -32,7 +32,7 @@ type buildinfoPropProperties struct {
}
type buildinfoPropModule struct {
SingletonModuleBase
ModuleBase
properties buildinfoPropProperties
@ -88,6 +88,10 @@ func shouldAddBuildThumbprint(config Config) bool {
}
func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
if ctx.ModuleName() != "buildinfo.prop" || ctx.ModuleDir() != "build/soong" {
ctx.ModuleErrorf("There can only be one buildinfo_prop module in build/soong")
return
}
p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath
if !ctx.Config().KatiEnabled() {
WriteFileRule(ctx, p.outputFilePath, "# no buildinfo.prop if kati is disabled")
@ -166,12 +170,8 @@ func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
ctx.InstallFile(p.installPath, p.Name(), p.outputFilePath)
}
func (f *buildinfoPropModule) GenerateSingletonBuildActions(ctx SingletonContext) {
// does nothing; buildinfo_prop is a singeton because two buildinfo modules don't make sense.
}
func (p *buildinfoPropModule) AndroidMkEntries() []AndroidMkEntries {
return []AndroidMkEntries{AndroidMkEntries{
return []AndroidMkEntries{{
Class: "ETC",
OutputFile: OptionalPathForPath(p.outputFilePath),
ExtraEntries: []AndroidMkExtraEntriesFunc{
@ -187,7 +187,7 @@ func (p *buildinfoPropModule) AndroidMkEntries() []AndroidMkEntries {
// buildinfo_prop module generates a build.prop file, which contains a set of common
// system/build.prop properties, such as ro.build.version.*. Not all properties are implemented;
// currently this module is only for microdroid.
func buildinfoPropFactory() SingletonModule {
func buildinfoPropFactory() Module {
module := &buildinfoPropModule{}
module.AddProperties(&module.properties)
InitAndroidModule(module)