Move fuzz phony to be make-defined, and add to dist.

Add the fuzz packages to dist. This requires that the phony for 'make'
be define in make itself, rather than in Soong. See comments on other
patch in topic for more information.

Bug: 141026328
Test: m fuzz dist

Change-Id: I4cd476adcfa42e4b40911c4a32427a7b00c67cc3
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 7806e83..c19fdc5 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -16,8 +16,8 @@
 
 import (
 	"path/filepath"
+	"strings"
 
-	"github.com/google/blueprint"
 	"github.com/google/blueprint/proptools"
 
 	"android/soong/android"
@@ -161,6 +161,7 @@
 // Responsible for generating GNU Make rules that package fuzz targets into
 // their architecture & target/host specific zip file.
 type fuzzPackager struct {
+	packages android.Paths
 }
 
 func fuzzPackagingFactory() android.Singleton {
@@ -220,15 +221,12 @@
 		}
 	})
 
-	// List of architecture + host/device specific packages to build via. 'make fuzz'.
-	var archDirTargets android.Paths
-
 	for archDir, filesToZip := range archDirs {
 		arch := archDir.Base()
 		hostOrTarget := filepath.Base(filepath.Dir(archDir.String()))
 		builder := android.NewRuleBuilder()
 		outputFile := android.PathForOutput(ctx, "fuzz-"+hostOrTarget+"-"+arch+".zip")
-		archDirTargets = append(archDirTargets, outputFile)
+		s.packages = append(s.packages, outputFile)
 
 		command := builder.Command().BuiltTool(ctx, "soong_zip").
 			Flag("-j").
@@ -242,11 +240,12 @@
 		builder.Build(pctx, ctx, "create-fuzz-package-"+arch+"-"+hostOrTarget,
 			"Create fuzz target packages for "+arch+"-"+hostOrTarget)
 	}
+}
 
-	ctx.Build(pctx, android.BuildParams{
-		Rule:        blueprint.Phony,
-		Output:      android.PathForPhony(ctx, "fuzz"),
-		Implicits:   archDirTargets,
-		Description: "Build all Android fuzz targets, and create packages.",
-	})
+func (s *fuzzPackager) MakeVars(ctx android.MakeVarsContext) {
+	// TODO(mitchp): Migrate this to use MakeVarsContext::DistForGoal() when it's
+	// ready to handle phony targets created in Soong. In the meantime, this
+	// exports the phony 'fuzz' target and dependencies on packages to
+	// core/main.mk so that we can use dist-for-goals.
+	ctx.Strict("SOONG_FUZZ_PACKAGING_ARCH_MODULES", strings.Join(s.packages.Strings(), " "))
 }