Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8933648 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "bp2build: fix BUILD file generation incrementality bug."

parents 9b910824 7dcc4fcc
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ func main() {
	if bazelConversionRequested(configuration) {
		// Run the alternate pipeline of bp2build mutators and singleton to convert Blueprint to BUILD files
		// before everything else.
		runBp2Build(configuration, extraNinjaDeps)
		runBp2Build(srcDir, configuration)
		// Short-circuit and return.
		return
	}
@@ -162,7 +162,7 @@ func main() {
// Run Soong in the bp2build mode. This creates a standalone context that registers
// an alternate pipeline of mutators and singletons specifically for generating
// Bazel BUILD files instead of Ninja files.
func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
func runBp2Build(srcDir string, configuration android.Config) {
	// Register an alternate set of singletons and mutators for bazel
	// conversion for Bazel conversion.
	bp2buildCtx := android.NewContext(configuration)
@@ -172,7 +172,20 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
	configuration.SetStopBefore(bootstrap.StopBeforePrepareBuildActions)
	bp2buildCtx.SetNameInterface(newNameResolver(configuration))

	// Run the loading and analysis pipeline.
	// The bp2build process is a purely functional process that only depends on
	// Android.bp files. It must not depend on the values of per-build product
	// configurations or variables, since those will generate different BUILD
	// files based on how the user has configured their tree.
	bp2buildCtx.SetModuleListFile(bootstrap.ModuleListFile)
	extraNinjaDeps, err := bp2buildCtx.ListModulePaths(srcDir)
	if err != nil {
		panic(err)
	}
	extraNinjaDepsString := strings.Join(extraNinjaDeps, " \\\n ")

	// Run the loading and analysis pipeline to prepare the graph of regular
	// Modules parsed from Android.bp files, and the BazelTargetModules mapped
	// from the regular Modules.
	bootstrap.Main(bp2buildCtx.Context, configuration, extraNinjaDeps...)

	// Run the code-generation phase to convert BazelTargetModules to BUILD files.
@@ -195,7 +208,6 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
	ninjaFileName := "build.ninja"
	ninjaFile := android.PathForOutput(codegenContext, ninjaFileName)
	ninjaFileD := android.PathForOutput(codegenContext, ninjaFileName+".d")
	extraNinjaDepsString := strings.Join(extraNinjaDeps, " \\\n ")
	// A workaround to create the 'nothing' ninja target so `m nothing` works,
	// since bp2build runs without Kati, and the 'nothing' target is declared in
	// a Makefile.