From a700d7fa9f2d6a03673405dcc3d31e2f17fcf150 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 6 Jun 2024 14:49:23 -0700 Subject: [PATCH] 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 --- android/buildinfo_prop.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go index e84aec21a..083f3efcb 100644 --- a/android/buildinfo_prop.go +++ b/android/buildinfo_prop.go @@ -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)