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/cc/cflag_artifacts.go b/cc/cflag_artifacts.go
index 855ff25..be46fc0 100644
--- a/cc/cflag_artifacts.go
+++ b/cc/cflag_artifacts.go
@@ -68,7 +68,7 @@
cleanedName := strings.Replace(flag, "=", "_", -1)
filename, filepath := s.incrementFile(ctx, cleanedName, part)
- rule := android.NewRuleBuilder()
+ rule := android.NewRuleBuilder(pctx, ctx)
rule.Command().Textf("rm -f %s", filepath.String())
if using {
@@ -84,7 +84,7 @@
length := len(modules)
if length == 0 {
- rule.Build(pctx, ctx, filename, "gen "+filename)
+ rule.Build(filename, "gen "+filename)
part++
}
@@ -98,11 +98,11 @@
strings.Join(proptools.ShellEscapeList(shard), " ")).
FlagWithOutput(">> ", filepath).
Text("; done")
- rule.Build(pctx, ctx, filename, "gen "+filename)
+ rule.Build(filename, "gen "+filename)
if index+1 != len(moduleShards) {
filename, filepath = s.incrementFile(ctx, cleanedName, part+index+1)
- rule = android.NewRuleBuilder()
+ rule = android.NewRuleBuilder(pctx, ctx)
rule.Command().Textf("rm -f %s", filepath.String())
}
}
@@ -121,14 +121,14 @@
for _, flag := range TrackedCFlags {
// Generate build rule to combine related intermediary files into a
// C Flag artifact
- rule := android.NewRuleBuilder()
+ rule := android.NewRuleBuilder(pctx, ctx)
filename := s.genFlagFilename(flag)
outputpath := android.PathForOutput(ctx, "cflags", filename)
rule.Command().
Text("cat").
Inputs(s.interOutputs[flag].Paths()).
FlagWithOutput("> ", outputpath)
- rule.Build(pctx, ctx, filename, "gen "+filename)
+ rule.Build(filename, "gen "+filename)
s.outputs = append(s.outputs, outputpath)
}
}