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/gen.go b/cc/gen.go
index 5895b31..75b9e49 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -75,10 +75,9 @@
cmd := rule.Command()
// Fix up #line markers to not use the sbox temporary directory
- // android.SboxPathForOutput(outDir, outDir) returns the sbox placeholder for the out
+ // android.sboxPathForOutput(outDir, outDir) returns the sbox placeholder for the out
// directory itself, without any filename appended.
- // TODO(ccross): make this cmd.PathForOutput(outDir) instead.
- sboxOutDir := android.SboxPathForOutput(outDir, outDir)
+ sboxOutDir := cmd.PathForOutput(outDir)
sedCmd := "sed -i.bak 's#" + sboxOutDir + "#" + outDir.String() + "#'"
rule.Command().Text(sedCmd).Input(outFile)
rule.Command().Text(sedCmd).Input(headerFile)
@@ -137,7 +136,7 @@
}
cmd := rule.Command()
- cmd.BuiltTool(ctx, "aidl-cpp").
+ cmd.BuiltTool("aidl-cpp").
FlagWithDepFile("-d", depFile).
Flag("--ninja").
Flag(aidlFlags).
@@ -232,7 +231,7 @@
var yaccRule_ *android.RuleBuilder
yaccRule := func() *android.RuleBuilder {
if yaccRule_ == nil {
- yaccRule_ = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "yacc"),
+ yaccRule_ = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "yacc"),
android.PathForModuleGen(ctx, "yacc.sbox.textproto"))
}
return yaccRule_
@@ -262,7 +261,7 @@
deps = append(deps, headerFile)
case ".aidl":
if aidlRule == nil {
- aidlRule = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "aidl"),
+ aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"),
android.PathForModuleGen(ctx, "aidl.sbox.textproto"))
}
cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp")
@@ -285,11 +284,11 @@
}
if aidlRule != nil {
- aidlRule.Build(pctx, ctx, "aidl", "gen aidl")
+ aidlRule.Build("aidl", "gen aidl")
}
if yaccRule_ != nil {
- yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
+ yaccRule_.Build("yacc", "gen yacc")
}
if len(rsFiles) > 0 {