Add SOONG_ONLY to the banner

Bug: 393162468
Test: manual
Change-Id: I91561c00ef0521cdd350820524b3c198b209a61c
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index a884964..4f6de82 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -338,7 +338,7 @@
 			ctx.Fatal(err)
 		}
 
-		fmt.Println(build.Banner(varData))
+		fmt.Println(build.Banner(config, varData))
 	} else {
 		varData, err := build.DumpMakeVars(ctx, config, nil, []string{varName})
 		if err != nil {
@@ -414,7 +414,7 @@
 
 	for _, name := range vars {
 		if name == "report_config" {
-			fmt.Printf("%sreport_config='%s'\n", *varPrefix, build.Banner(varData))
+			fmt.Printf("%sreport_config='%s'\n", *varPrefix, build.Banner(config, varData))
 		} else {
 			fmt.Printf("%s%s='%s'\n", *varPrefix, name, varData[name])
 		}
diff --git a/ui/build/config.go b/ui/build/config.go
index 9fbbc48..890ed46 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -78,15 +78,19 @@
 	logsPrefix    string
 
 	// From the arguments
-	parallel                  int
-	keepGoing                 int
-	verbose                   bool
-	checkbuild                bool
-	dist                      bool
-	jsonModuleGraph           bool
-	reportMkMetrics           bool // Collect and report mk2bp migration progress metrics.
-	soongDocs                 bool
-	skipConfig                bool
+	parallel        int
+	keepGoing       int
+	verbose         bool
+	checkbuild      bool
+	dist            bool
+	jsonModuleGraph bool
+	reportMkMetrics bool // Collect and report mk2bp migration progress metrics.
+	soongDocs       bool
+	skipConfig      bool
+	// Either the user or product config requested that we skip soong (for the banner). The other
+	// skip flags tell whether *this* soong_ui invocation will skip kati - which will be true
+	// during lunch.
+	soongOnlyRequested        bool
 	skipKati                  bool
 	skipKatiControlledByFlags bool
 	skipKatiNinja             bool
@@ -254,6 +258,7 @@
 
 	if value, ok := ret.environ.Get("SOONG_ONLY"); ok && !ret.skipKatiControlledByFlags {
 		if value == "true" || value == "1" || value == "y" || value == "yes" {
+			ret.soongOnlyRequested = true
 			ret.skipKatiControlledByFlags = true
 			ret.skipKati = true
 			ret.skipKatiNinja = true
@@ -866,6 +871,7 @@
 			if c.skipKatiControlledByFlags {
 				ctx.Fatalf("Cannot specify both --soong-only and --no-soong-only")
 			}
+			c.soongOnlyRequested = true
 			c.skipKatiControlledByFlags = true
 			c.skipKati = true
 			c.skipKatiNinja = true
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index d5aab54..16a3db8 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -172,7 +172,7 @@
 	"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE",
 }
 
-func Banner(make_vars map[string]string) string {
+func Banner(config Config, make_vars map[string]string) string {
 	b := &bytes.Buffer{}
 
 	fmt.Fprintln(b, "============================================")
@@ -181,6 +181,7 @@
 			fmt.Fprintf(b, "%s=%s\n", name, make_vars[name])
 		}
 	}
+	fmt.Fprintf(b, "SOONG_ONLY=%t\n", config.soongOnlyRequested)
 	fmt.Fprint(b, "============================================")
 
 	return b.String()
@@ -289,13 +290,8 @@
 		ctx.Fatalln("Error dumping make vars:", err)
 	}
 
-	env := config.Environment()
-	// Print the banner like make does
-	if !env.IsEnvTrue("ANDROID_QUIET_BUILD") {
-		fmt.Fprintln(ctx.Writer, Banner(makeVars))
-	}
-
 	// Populate the environment
+	env := config.Environment()
 	for _, name := range exportEnvVars {
 		if makeVars[name] == "" {
 			env.Unset(name)
@@ -319,8 +315,14 @@
 
 	if !config.skipKatiControlledByFlags {
 		if makeVars["PRODUCT_SOONG_ONLY"] == "true" {
+			config.soongOnlyRequested = true
 			config.skipKati = true
 			config.skipKatiNinja = true
 		}
 	}
+
+	// Print the banner like make did
+	if !env.IsEnvTrue("ANDROID_QUIET_BUILD") {
+		fmt.Fprintln(ctx.Writer, Banner(config, makeVars))
+	}
 }