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
diff --git a/java/droiddoc.go b/java/droiddoc.go
index da8489a..10f8881 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -671,7 +671,7 @@
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 @@
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 @@
zipSyncCleanupCmd(rule, srcJarDir)
- rule.Build(pctx, ctx, "javadoc", "javadoc")
+ rule.Build("javadoc", "javadoc")
}
//
@@ -845,7 +845,7 @@
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 @@
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 @@
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 @@
}
rule.Command().
- BuiltTool(ctx, "soong_zip").
+ BuiltTool("soong_zip").
Flag("-write_if_changed").
Flag("-d").
FlagWithOutput("-o ", d.docZip).
@@ -979,7 +979,7 @@
zipSyncCleanupCmd(rule, srcJarDir)
- rule.Build(pctx, ctx, "javadoc", desc)
+ rule.Build("javadoc", desc)
}
//
@@ -1278,7 +1278,7 @@
}).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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
` 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 @@
Text("; exit 38").
Text(")")
- rule.Build(pctx, ctx, "nullabilityWarningsCheck", "nullability warnings check")
+ rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
}
@@ -1722,7 +1722,7 @@
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 @@
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 @@
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 {