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

Commit a5f64f03 authored by Cole Faust's avatar Cole Faust
Browse files

Convert RuleBuilder to static rule in buildRuleToGenerateIndex

This saves ~34kb from the build.ninja file.

Test: Presubmits
Change-Id: I8fa4974e4f1509be7938c774e536d15a63534753
parent 1d09ec6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ func init() {
	pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger")

	pctx.HostBinToolVariable("Class2NonSdkList", "class2nonsdklist")
	pctx.HostBinToolVariable("MergeCsvCommand", "merge_csv")
	pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")

	hostBinToolVariableWithSdkToolsPrebuilt("Aapt2Cmd", "aapt2")
+17 −12
Original line number Diff line number Diff line
@@ -20,11 +20,18 @@ import (
	"android/soong/android"
)

var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", blueprint.RuleParams{
var (
	hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", blueprint.RuleParams{
		Command:     "${config.Class2NonSdkList} --stub-api-flags ${stubAPIFlags} $in $outFlag $out",
		CommandDeps: []string{"${config.Class2NonSdkList}"},
	}, "outFlag", "stubAPIFlags")

	hiddenAPIGenerateIndexRule = pctx.AndroidStaticRule("hiddenAPIGenerateIndex", blueprint.RuleParams{
		Command:     "${config.MergeCsvCommand} --zip_input --key_field signature --output=$out $in",
		CommandDeps: []string{"${config.MergeCsvCommand}"},
	})
)

type hiddenAPI struct {
	// True if the module containing this structure contributes to the hiddenapi information or has
	// that information encoded within it.
@@ -216,14 +223,12 @@ func buildRuleToGenerateMetadata(ctx android.ModuleContext, desc string, classes
// created by the unsupported app usage annotation processor during compilation of the class
// implementation jar.
func buildRuleToGenerateIndex(ctx android.ModuleContext, desc string, classesJars android.Paths, indexCSV android.WritablePath) {
	rule := android.NewRuleBuilder(pctx, ctx)
	rule.Command().
		BuiltTool("merge_csv").
		Flag("--zip_input").
		Flag("--key_field signature").
		FlagWithOutput("--output=", indexCSV).
		Inputs(classesJars)
	rule.Build(desc, desc)
	ctx.Build(pctx, android.BuildParams{
		Rule:        hiddenAPIGenerateIndexRule,
		Description: desc,
		Inputs:      classesJars,
		Output:      indexCSV,
	})
}

var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", blueprint.RuleParams{