Merge "Copy selinux_fc file to target_files.zip" into main
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index b17820e..3d07e16 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -162,9 +162,7 @@
 		})
 		ctx.Phony("all_aconfig_declarations_textproto", this.releaseMap[rcName].intermediateTextProtoPath)
 	}
-}
 
-func (this *allAconfigDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) {
 	for _, rcName := range this.sortedConfigNames() {
 		ctx.DistForGoal("droid", this.releaseMap[rcName].intermediateBinaryProtoPath)
 		for _, goal := range []string{"docs", "droid", "sdk"} {
diff --git a/aconfig/all_aconfig_declarations_extension.go b/aconfig/all_aconfig_declarations_extension.go
index 44992cd..d5a4588 100644
--- a/aconfig/all_aconfig_declarations_extension.go
+++ b/aconfig/all_aconfig_declarations_extension.go
@@ -79,12 +79,10 @@
 
 	ctx.Phony(ctx.ModuleName(), ext.finalizedFlags)
 
+	ctx.DistForGoalWithFilename("sdk", ext.finalizedFlags, path.Join(proptools.String(ext.properties.Dist_dir), "finalized-flags.txt"))
+
 	// This module must not set any provider or call `ctx.SetOutputFiles`!
 	// This module is only used to depend on the singleton module all_aconfig_declarations and
 	// generate the custom finalized-flags.txt file in dist builds, and should not be depended
 	// by other modules.
 }
-
-func (ext *allAconfigDeclarationsExtension) MakeVars(ctx android.MakeVarsContext) {
-	ctx.DistForGoalWithFilename("sdk", ext.finalizedFlags, path.Join(proptools.String(ext.properties.Dist_dir), "finalized-flags.txt"))
-}
diff --git a/aconfig/build_flags/build_flags_singleton.go b/aconfig/build_flags/build_flags_singleton.go
index e76db49..e375d9c 100644
--- a/aconfig/build_flags/build_flags_singleton.go
+++ b/aconfig/build_flags/build_flags_singleton.go
@@ -111,9 +111,7 @@
 		this.configsBinaryProtoPath,
 		this.configsTextProtoPath,
 	)
-}
 
-func (this *allBuildFlagDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) {
 	ctx.DistForGoal("droid", this.flagsBinaryProtoPath)
 	for _, goal := range []string{"docs", "droid", "sdk", "release_config_metadata"} {
 		ctx.DistForGoalWithFilename(goal, this.flagsBinaryProtoPath, "build_flags/all_flags.pb")
diff --git a/aconfig/exported_java_aconfig_library.go b/aconfig/exported_java_aconfig_library.go
index dd068d1..63d824a 100644
--- a/aconfig/exported_java_aconfig_library.go
+++ b/aconfig/exported_java_aconfig_library.go
@@ -63,8 +63,5 @@
 		},
 	})
 	ctx.Phony("exported_java_aconfig_library", this.intermediatePath)
-}
-
-func (this *exportedJavaDeclarationsLibrarySingleton) MakeVars(ctx android.MakeVarsContext) {
 	ctx.DistForGoalWithFilename("sdk", this.intermediatePath, "android-flags.jar")
 }
diff --git a/android/Android.bp b/android/Android.bp
index 540d65b..aef18fe 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -11,6 +11,7 @@
         "blueprint-depset",
         "blueprint-gobtools",
         "blueprint-metrics",
+        "blueprint-pool",
         "sbox_proto",
         "soong",
         "soong-android_team_proto",
diff --git a/android/all_teams.go b/android/all_teams.go
index 01be396..3b20107 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -134,9 +134,6 @@
 
 	WriteFileRuleVerbatim(ctx, t.outputPath, string(data))
 	ctx.Phony("all_teams", t.outputPath)
-}
-
-func (t *allTeamsSingleton) MakeVars(ctx MakeVarsContext) {
 	ctx.DistForGoal("all_teams", t.outputPath)
 }
 
diff --git a/android/mutator.go b/android/mutator.go
index d6166d2..12861c0 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -15,9 +15,8 @@
 package android
 
 import (
-	"sync"
-
 	"github.com/google/blueprint"
+	"github.com/google/blueprint/pool"
 )
 
 // Phases:
@@ -272,15 +271,9 @@
 // for each transition mutator.  bottomUpMutatorContext is created once for every module for every BottomUp mutator.
 // Use a global pool for each to avoid reallocating every time.
 var (
-	outgoingTransitionContextPool = sync.Pool{
-		New: func() any { return &outgoingTransitionContextImpl{} },
-	}
-	incomingTransitionContextPool = sync.Pool{
-		New: func() any { return &incomingTransitionContextImpl{} },
-	}
-	bottomUpMutatorContextPool = sync.Pool{
-		New: func() any { return &bottomUpMutatorContext{} },
-	}
+	outgoingTransitionContextPool = pool.New[outgoingTransitionContextImpl]()
+	incomingTransitionContextPool = pool.New[incomingTransitionContextImpl]()
+	bottomUpMutatorContextPool    = pool.New[bottomUpMutatorContext]()
 )
 
 type bottomUpMutatorContext struct {
@@ -291,10 +284,10 @@
 
 // callers must immediately follow the call to this function with defer bottomUpMutatorContextPool.Put(mctx).
 func bottomUpMutatorContextFactory(ctx blueprint.BottomUpMutatorContext, a Module,
-	finalPhase bool) BottomUpMutatorContext {
+	finalPhase bool) *bottomUpMutatorContext {
 
 	moduleContext := a.base().baseModuleContextFactory(ctx)
-	mctx := bottomUpMutatorContextPool.Get().(*bottomUpMutatorContext)
+	mctx := bottomUpMutatorContextPool.Get()
 	*mctx = bottomUpMutatorContext{
 		bp:                ctx,
 		baseModuleContext: moduleContext,
diff --git a/android/sbom.go b/android/sbom.go
index f2b9c0f..fc61c41 100644
--- a/android/sbom.go
+++ b/android/sbom.go
@@ -84,12 +84,6 @@
 			Inputs: []Path{this.sbomFile},
 			Output: PathForPhony(ctx, "sbom"),
 		})
-	}
-}
-
-func (this *sbomSingleton) MakeVars(ctx MakeVarsContext) {
-	// When building SBOM of products
-	if !ctx.Config().UnbundledBuildApps() {
 		ctx.DistForGoalWithFilename("droid", this.sbomFile, "sbom/sbom.spdx.json")
 	}
 }
diff --git a/android/test_suites.go b/android/test_suites.go
index 936d2b6..18744f1 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -58,9 +58,6 @@
 
 	t.ravenwood = ravenwoodTestSuite(ctx, files["ravenwood-tests"])
 	ctx.Phony("ravenwood-tests", t.ravenwood...)
-}
-
-func (t *testSuiteFiles) MakeVars(ctx MakeVarsContext) {
 	ctx.DistForGoal("robolectric-tests", t.robolectric...)
 	ctx.DistForGoal("ravenwood-tests", t.ravenwood...)
 }
diff --git a/android/transition.go b/android/transition.go
index e1aa891..0677ca1 100644
--- a/android/transition.go
+++ b/android/transition.go
@@ -197,7 +197,7 @@
 func (a *androidTransitionMutatorAdapter) OutgoingTransition(bpctx blueprint.OutgoingTransitionContext,
 	sourceTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
 	m := bpctx.Module().(Module)
-	ctx := outgoingTransitionContextPool.Get().(*outgoingTransitionContextImpl)
+	ctx := outgoingTransitionContextPool.Get()
 	defer outgoingTransitionContextPool.Put(ctx)
 	*ctx = outgoingTransitionContextImpl{
 		archModuleContext: m.base().archModuleContextFactory(bpctx),
@@ -209,7 +209,7 @@
 func (a *androidTransitionMutatorAdapter) IncomingTransition(bpctx blueprint.IncomingTransitionContext,
 	incomingTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
 	m := bpctx.Module().(Module)
-	ctx := incomingTransitionContextPool.Get().(*incomingTransitionContextImpl)
+	ctx := incomingTransitionContextPool.Get()
 	defer incomingTransitionContextPool.Put(ctx)
 	*ctx = incomingTransitionContextImpl{
 		archModuleContext: m.base().archModuleContextFactory(bpctx),
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 263e0a5..a8bd984 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -175,8 +175,5 @@
 	}
 	a.out = android.PathForOutput(ctx, "prebuilt_info.json")
 	android.WriteFileRule(ctx, a.out, string(j))
-}
-
-func (a *apexPrebuiltInfo) MakeVars(ctx android.MakeVarsContext) {
 	ctx.DistForGoal("droidcore", a.out)
 }
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index 8ecea98..26f2aa8 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -105,13 +105,11 @@
 		}
 	})
 
+	protoFilenamePath := android.PathForOutput(ctx, protoFilename)
 	ctx.Build(pctx, android.BuildParams{
 		Rule:   bloatyMerger,
 		Inputs: android.SortedUniquePaths(deps),
-		Output: android.PathForOutput(ctx, protoFilename),
+		Output: protoFilenamePath,
 	})
-}
-
-func (singleton *sizesSingleton) MakeVars(ctx android.MakeVarsContext) {
-	ctx.DistForGoalWithFilename("checkbuild", android.PathForOutput(ctx, protoFilename), protoFilename)
+	ctx.DistForGoalWithFilename("checkbuild", protoFilenamePath, protoFilename)
 }
diff --git a/cc/ccdeps.go b/cc/ccdeps.go
index 469fe31..4247778 100644
--- a/cc/ccdeps.go
+++ b/cc/ccdeps.go
@@ -41,8 +41,6 @@
 	outputPath android.Path
 }
 
-var _ android.SingletonMakeVarsProvider = (*ccdepsGeneratorSingleton)(nil)
-
 const (
 	ccdepsJsonFileName = "module_bp_cc_deps.json"
 	cClang             = "clang"
@@ -114,13 +112,6 @@
 		Rule:   android.Touch,
 		Output: ccfpath,
 	})
-}
-
-func (c *ccdepsGeneratorSingleton) MakeVars(ctx android.MakeVarsContext) {
-	if c.outputPath == nil {
-		return
-	}
-
 	ctx.DistForGoal("general-tests", c.outputPath)
 }
 
diff --git a/cc/test.go b/cc/test.go
index 9f86c7a..b3b2ae8 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -442,6 +442,9 @@
 			if standaloneTestDep.ToGob().SrcPath == nil {
 				continue
 			}
+			if standaloneTestDep.SkipInstall() {
+				continue
+			}
 			test.binaryDecorator.baseInstaller.installStandaloneTestDep(ctx, standaloneTestDep)
 		}
 	}
diff --git a/java/droidstubs.go b/java/droidstubs.go
index c8f798a..caad688 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -1429,6 +1429,16 @@
 	d.setOutputFiles(ctx)
 
 	d.setPhonyRules(ctx)
+
+	if d.apiLintTimestamp != nil {
+		if d.apiLintReport != nil {
+			ctx.DistForGoalsWithFilename(
+				[]string{fmt.Sprintf("%s-api-lint", d.Name()), "droidcore"},
+				d.apiLintReport,
+				fmt.Sprintf("apilint/%s-lint-report.txt", d.Name()),
+			)
+		}
+	}
 }
 
 func setDroidInfo(ctx android.ModuleContext, d *Droidstubs, info *StubsInfo, typ StubsType) {
@@ -1524,18 +1534,6 @@
 	}
 )
 
-func (d *Droidstubs) MakeVars(ctx android.MakeVarsModuleContext) {
-	if d.apiLintTimestamp != nil {
-		if d.apiLintReport != nil {
-			ctx.DistForGoalsWithFilename(
-				[]string{fmt.Sprintf("%s-api-lint", d.Name()), "droidcore"},
-				d.apiLintReport,
-				fmt.Sprintf("apilint/%s-lint-report.txt", d.Name()),
-			)
-		}
-	}
-}
-
 func StubsDefaultsFactory() android.Module {
 	module := &DocDefaults{}
 
diff --git a/java/java.go b/java/java.go
index 91b7cf2..383fc3f 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1282,13 +1282,6 @@
 			Input:  j.implementationAndResourcesJar,
 			Output: j.apiXmlFile,
 		})
-	}
-}
-
-var _ android.ModuleMakeVarsProvider = (*Library)(nil)
-
-func (j *Library) MakeVars(ctx android.MakeVarsModuleContext) {
-	if j.apiXmlFile != nil {
 		ctx.DistForGoal("dist_files", j.apiXmlFile)
 	}
 }
diff --git a/java/jdeps.go b/java/jdeps.go
index c2ce503..927c169 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -37,8 +37,6 @@
 	outputPath android.Path
 }
 
-var _ android.SingletonMakeVarsProvider = (*jdepsGeneratorSingleton)(nil)
-
 const (
 	jdepsJsonFileName = "module_bp_java_deps.json"
 )
@@ -101,13 +99,6 @@
 		Rule:   android.Touch,
 		Output: jfpath,
 	})
-}
-
-func (j *jdepsGeneratorSingleton) MakeVars(ctx android.MakeVarsContext) {
-	if j.outputPath == nil {
-		return
-	}
-
 	ctx.DistForGoal("general-tests", j.outputPath)
 }
 
diff --git a/java/lint.go b/java/lint.go
index 3838745..66f7f85 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -704,16 +704,12 @@
 	zip(l.referenceBaselineZip, func(l *LintInfo) android.Path { return l.ReferenceBaseline })
 
 	ctx.Phony("lint-check", l.htmlZip, l.textZip, l.xmlZip, l.referenceBaselineZip)
-}
 
-func (l *lintSingleton) MakeVars(ctx android.MakeVarsContext) {
 	if !ctx.Config().UnbundledBuild() {
 		ctx.DistForGoal("lint-check", l.htmlZip, l.textZip, l.xmlZip, l.referenceBaselineZip)
 	}
 }
 
-var _ android.SingletonMakeVarsProvider = (*lintSingleton)(nil)
-
 func init() {
 	android.RegisterParallelSingletonType("lint",
 		func() android.Singleton { return &lintSingleton{} })
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index bb98944..d4d2fb5 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -278,12 +278,7 @@
 	rule.Build("merged-compat-config", "Merge compat config")
 
 	p.metadata = outputPath
-}
-
-func (p *platformCompatConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
-	if p.metadata != nil {
-		ctx.DistForGoal("droidcore", p.metadata)
-	}
+	ctx.DistForGoal("droidcore", p.metadata)
 }
 
 func platformCompatConfigSingletonFactory() android.Singleton {
diff --git a/phony/phony.go b/phony/phony.go
index 4f61c45..807b95b 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -38,11 +38,9 @@
 
 type phony struct {
 	android.ModuleBase
-
 	requiredModuleNames       []string
 	hostRequiredModuleNames   []string
 	targetRequiredModuleNames []string
-	outputDeps                android.Paths
 }
 
 func PhonyFactory() android.Module {
@@ -56,14 +54,6 @@
 	p.requiredModuleNames = ctx.RequiredModuleNames(ctx)
 	p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
 	p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
-
-	ctx.VisitDirectDepsWithTag(android.RequiredDepTag, func(dep android.Module) {
-		if o, ok := android.OtherModuleProvider(ctx, dep, android.OutputFilesProvider); ok {
-			p.outputDeps = append(p.outputDeps, o.DefaultOutputFiles...)
-		}
-	})
-
-	ctx.Phony(p.Name(), p.outputDeps...)
 }
 
 func (p *phony) AndroidMk() android.AndroidMkData {
@@ -87,10 +77,6 @@
 				fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=",
 					strings.Join(p.targetRequiredModuleNames, " "))
 			}
-			if len(p.outputDeps) > 0 {
-				fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=",
-					strings.Join(p.outputDeps.Strings(), " "))
-			}
 			// AconfigUpdateAndroidMkData may have added elements to Extra.  Process them here.
 			for _, extra := range data.Extra {
 				extra(w, nil)
diff --git a/provenance/provenance_singleton.go b/provenance/provenance_singleton.go
index c372db2..c1bc1c7 100644
--- a/provenance/provenance_singleton.go
+++ b/provenance/provenance_singleton.go
@@ -99,6 +99,7 @@
 	})
 
 	context.Phony("droidcore", android.PathForPhony(context, "provenance_metadata"))
+	context.DistForGoal("droidcore", p.mergedMetaDataFile)
 }
 
 func GenerateArtifactProvenanceMetaData(ctx android.ModuleContext, artifactPath android.Path, installedFile android.InstallPath) android.Path {
@@ -116,9 +117,3 @@
 
 	return artifactMetaDataFile
 }
-
-func (p *provenanceInfoSingleton) MakeVars(ctx android.MakeVarsContext) {
-	ctx.DistForGoal("droidcore", p.mergedMetaDataFile)
-}
-
-var _ android.SingletonMakeVarsProvider = (*provenanceInfoSingleton)(nil)