Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access the BuilderContext by passing it to NewRuleBuilder instead of RuleBuilder.Build. Test: genrule_test.go Test: rule_builder_test.go Test: m checkbuild Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
This commit is contained in:
@@ -671,7 +671,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
j.stubsSrcJar = nil
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
rule.Command().Text("rm -rf").Text(outDir.String())
|
||||
rule.Command().Text("mkdir -p").Text(outDir.String())
|
||||
@@ -689,7 +689,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
Flag("-Xdoclint:none")
|
||||
|
||||
rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-d").
|
||||
FlagWithOutput("-o ", j.docZip).
|
||||
@@ -700,7 +700,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
zipSyncCleanupCmd(rule, srcJarDir)
|
||||
|
||||
rule.Build(pctx, ctx, "javadoc", "javadoc")
|
||||
rule.Build("javadoc", "javadoc")
|
||||
}
|
||||
|
||||
//
|
||||
@@ -845,7 +845,7 @@ func javadocCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs andro
|
||||
outDir, srcJarDir, srcJarList android.Path, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
||||
|
||||
cmd := rule.Command().
|
||||
BuiltTool(ctx, "soong_javac_wrapper").Tool(config.JavadocCmd(ctx)).
|
||||
BuiltTool("soong_javac_wrapper").Tool(config.JavadocCmd(ctx)).
|
||||
Flag(config.JavacVmFlags).
|
||||
FlagWithArg("-encoding ", "UTF-8").
|
||||
FlagWithRspFileInputList("@", srcs).
|
||||
@@ -914,7 +914,7 @@ func dokkaCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
|
||||
dokkaClasspath := append(bootclasspath.Paths(), classpath.Paths()...)
|
||||
|
||||
return rule.Command().
|
||||
BuiltTool(ctx, "dokka").
|
||||
BuiltTool("dokka").
|
||||
Flag(config.JavacVmFlags).
|
||||
Flag(srcJarDir.String()).
|
||||
FlagWithInputList("-classpath ", dokkaClasspath, ":").
|
||||
@@ -934,7 +934,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
outDir := android.PathForModuleOut(ctx, "out")
|
||||
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
||||
|
||||
@@ -968,7 +968,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-d").
|
||||
FlagWithOutput("-o ", d.docZip).
|
||||
@@ -979,7 +979,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
zipSyncCleanupCmd(rule, srcJarDir)
|
||||
|
||||
rule.Build(pctx, ctx, "javadoc", desc)
|
||||
rule.Build("javadoc", desc)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1278,7 +1278,7 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
||||
}).NoVarTemplate(ctx.Config()))
|
||||
}
|
||||
|
||||
cmd.BuiltTool(ctx, "metalava").
|
||||
cmd.BuiltTool("metalava").
|
||||
Flag(config.JavacVmFlags).
|
||||
Flag("-J--add-opens=java.base/java.util=ALL-UNNAMED").
|
||||
FlagWithArg("-encoding ", "UTF-8").
|
||||
@@ -1333,7 +1333,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
if BoolDefault(d.properties.High_mem, false) {
|
||||
// This metalava run uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
||||
@@ -1480,19 +1480,19 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
cmd.FlagWithArg("--error-message:compatibility:released ", msg)
|
||||
}
|
||||
|
||||
impRule := android.NewRuleBuilder()
|
||||
impRule := android.NewRuleBuilder(pctx, ctx)
|
||||
impCmd := impRule.Command()
|
||||
// An action that copies the ninja generated rsp file to a new location. This allows us to
|
||||
// add a large number of inputs to a file without exceeding bash command length limits (which
|
||||
// would happen if we use the WriteFile rule). The cp is needed because RuleBuilder sets the
|
||||
// rsp file to be ${output}.rsp.
|
||||
impCmd.Text("cp").FlagWithRspFileInputList("", cmd.GetImplicits()).Output(implicitsRsp)
|
||||
impRule.Build(pctx, ctx, "implicitsGen", "implicits generation")
|
||||
impRule.Build("implicitsGen", "implicits generation")
|
||||
cmd.Implicit(implicitsRsp)
|
||||
|
||||
if generateStubs {
|
||||
rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-jar").
|
||||
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
|
||||
@@ -1503,7 +1503,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if Bool(d.properties.Write_sdk_values) {
|
||||
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")
|
||||
rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-d").
|
||||
FlagWithOutput("-o ", d.metadataZip).
|
||||
@@ -1524,7 +1524,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
zipSyncCleanupCmd(rule, srcJarDir)
|
||||
|
||||
rule.Build(pctx, ctx, "metalava", "metalava merged")
|
||||
rule.Build("metalava", "metalava merged")
|
||||
|
||||
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
|
||||
|
||||
@@ -1542,7 +1542,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
// Diff command line.
|
||||
// -F matches the closest "opening" line, such as "package android {"
|
||||
@@ -1576,12 +1576,12 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
Text("; exit 38").
|
||||
Text(")")
|
||||
|
||||
rule.Build(pctx, ctx, "metalavaCurrentApiCheck", "check current API")
|
||||
rule.Build("metalavaCurrentApiCheck", "check current API")
|
||||
|
||||
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
||||
|
||||
// update API rule
|
||||
rule = android.NewRuleBuilder()
|
||||
rule = android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
rule.Command().Text("( true")
|
||||
|
||||
@@ -1602,7 +1602,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
Text("; exit 38").
|
||||
Text(")")
|
||||
|
||||
rule.Build(pctx, ctx, "metalavaCurrentApiUpdate", "update current API")
|
||||
rule.Build("metalavaCurrentApiUpdate", "update current API")
|
||||
}
|
||||
|
||||
if String(d.properties.Check_nullability_warnings) != "" {
|
||||
@@ -1625,7 +1625,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
` and submitting the updated file as part of your change.`,
|
||||
d.nullabilityWarningsFile, checkNullabilityWarnings)
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
rule.Command().
|
||||
Text("(").
|
||||
@@ -1637,7 +1637,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
Text("; exit 38").
|
||||
Text(")")
|
||||
|
||||
rule.Build(pctx, ctx, "nullabilityWarningsCheck", "nullability warnings check")
|
||||
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1722,7 +1722,7 @@ func zipSyncCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
|
||||
|
||||
rule.Temporary(srcJarList)
|
||||
|
||||
rule.Command().BuiltTool(ctx, "zipsync").
|
||||
rule.Command().BuiltTool("zipsync").
|
||||
FlagWithArg("-d ", srcJarDir.String()).
|
||||
FlagWithOutput("-l ", srcJarList).
|
||||
FlagWithArg("-f ", `"*.java"`).
|
||||
@@ -1783,9 +1783,9 @@ func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleCon
|
||||
srcGlob := localSrcDir + "/**/*"
|
||||
srcPaths := android.PathsForModuleSrc(ctx, []string{srcGlob})
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-jar").
|
||||
FlagWithOutput("-o ", p.stubsSrcJar).
|
||||
@@ -1794,7 +1794,7 @@ func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleCon
|
||||
|
||||
rule.Restat()
|
||||
|
||||
rule.Build(pctx, ctx, "zip src", "Create srcjar from prebuilt source")
|
||||
rule.Build("zip src", "Create srcjar from prebuilt source")
|
||||
}
|
||||
|
||||
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
||||
|
Reference in New Issue
Block a user