Fix reanalysis after full build

Blueprint bootstrap and Soong each create rules to install
blueprint_go_binary modules to the same location, but with different
command lines.  Binaries used during bootstrap are installed using
the bootstrap rule, but then get reinstalled during a full build via
the blueprint_tools phony that is a dependency of droid.  This
changes the command line used for the rule stored in .ninja_log,
and then on the next bootstrap ninja will rerun the binaries,
triggering reanalysis.

As a quick fix, don't create install rules for loadplugins and
soong_build.  A more permanent fix may be to move the bootstrap
installation to a different location, but that will require more
testing.

Bug: 366291149
Test: m blueprint_tools && m blueprint_tools
Flag; EXEMPT bugfix

Change-Id: Ib7f2910976f4b5e6add2128ce0b2a5d10445a53c
This commit is contained in:
Colin Cross
2024-09-12 23:04:43 -07:00
parent 167230037c
commit 893528a4c9

View File

@@ -96,17 +96,31 @@ func (g *GoBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
outputFile := android.PathForArbitraryOutput(ctx, android.Rel(ctx, ctx.Config().OutDir(), g.IntermediateFile())).WithoutRel() outputFile := android.PathForArbitraryOutput(ctx, android.Rel(ctx, ctx.Config().OutDir(), g.IntermediateFile())).WithoutRel()
g.outputFile = outputFile g.outputFile = outputFile
installPath := ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), ctx.ModuleName(), outputFile) // Don't create install rules for modules used by bootstrap, the install command line will differ from
// what was used during bootstrap, which will cause ninja to rebuild the module on the next run,
// triggering reanalysis.
if !usedByBootstrap(ctx.ModuleName()) {
installPath := ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), ctx.ModuleName(), outputFile)
if !ctx.Config().KatiEnabled() || g.ExportedToMake() {
// Modules in an unexported namespace have no install rule, only add modules in the exported namespaces // Modules in an unexported namespace have no install rule, only add modules in the exported namespaces
// to the blueprint_tools phony rules. // to the blueprint_tools phony rules.
ctx.Phony("blueprint_tools", installPath) if !ctx.Config().KatiEnabled() || g.ExportedToMake() {
ctx.Phony("blueprint_tools", installPath)
}
} }
ctx.SetOutputFiles(android.Paths{outputFile}, "") ctx.SetOutputFiles(android.Paths{outputFile}, "")
} }
func usedByBootstrap(name string) bool {
switch name {
case "loadplugins", "soong_build":
return true
default:
return false
}
}
func (g *GoBinary) HostToolPath() android.OptionalPath { func (g *GoBinary) HostToolPath() android.OptionalPath {
return android.OptionalPathForPath(g.outputFile) return android.OptionalPathForPath(g.outputFile)
} }