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/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 65380fe..b0a684e 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -51,7 +51,7 @@
// GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a
// ModuleConfig. The produced files and their install locations will be available through rule.Installs().
-func GenerateDexpreoptRule(ctx android.PathContext, globalSoong *GlobalSoongConfig,
+func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongConfig,
global *GlobalConfig, module *ModuleConfig) (rule *android.RuleBuilder, err error) {
defer func() {
@@ -67,7 +67,7 @@
}
}()
- rule = android.NewRuleBuilder()
+ rule = android.NewRuleBuilder(pctx, ctx)
generateProfile := module.ProfileClassListing.Valid() && !global.DisableGenerateProfile
generateBootProfile := module.ProfileBootListing.Valid() && !global.DisableGenerateProfile
diff --git a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
index e89f045..32c4f84 100644
--- a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
+++ b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
@@ -27,6 +27,7 @@
"android/soong/android"
"android/soong/dexpreopt"
+ "github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
)
@@ -38,12 +39,16 @@
outDir = flag.String("out_dir", "", "path to output directory")
)
-type pathContext struct {
+type builderContext struct {
config android.Config
}
-func (x *pathContext) Config() android.Config { return x.config }
-func (x *pathContext) AddNinjaFileDeps(...string) {}
+func (x *builderContext) Config() android.Config { return x.config }
+func (x *builderContext) AddNinjaFileDeps(...string) {}
+func (x *builderContext) Build(android.PackageContext, android.BuildParams) {}
+func (x *builderContext) Rule(android.PackageContext, string, blueprint.RuleParams, ...string) blueprint.Rule {
+ return nil
+}
func main() {
flag.Parse()
@@ -76,7 +81,7 @@
usage("--module configuration file is required")
}
- ctx := &pathContext{android.NullConfig(*outDir)}
+ ctx := &builderContext{android.NullConfig(*outDir)}
globalSoongConfigData, err := ioutil.ReadFile(*globalSoongConfigPath)
if err != nil {
@@ -133,7 +138,7 @@
writeScripts(ctx, globalSoongConfig, globalConfig, moduleConfig, *dexpreoptScriptPath)
}
-func writeScripts(ctx android.PathContext, globalSoong *dexpreopt.GlobalSoongConfig,
+func writeScripts(ctx android.BuilderContext, globalSoong *dexpreopt.GlobalSoongConfig,
global *dexpreopt.GlobalConfig, module *dexpreopt.ModuleConfig, dexpreoptScriptPath string) {
dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, globalSoong, global, module)
if err != nil {
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index feabd70..59278fd 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -60,7 +60,7 @@
func TestDexPreopt(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
- ctx := android.PathContextForTesting(config)
+ ctx := android.BuilderContextForTesting(config)
globalSoong := GlobalSoongConfigForTests(config)
global := GlobalConfigForTests(ctx)
module := testSystemModuleConfig(ctx, "test")
@@ -82,7 +82,7 @@
func TestDexPreoptSystemOther(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
- ctx := android.PathContextForTesting(config)
+ ctx := android.BuilderContextForTesting(config)
globalSoong := GlobalSoongConfigForTests(config)
global := GlobalConfigForTests(ctx)
systemModule := testSystemModuleConfig(ctx, "Stest")
@@ -142,7 +142,7 @@
func TestDexPreoptProfile(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
- ctx := android.PathContextForTesting(config)
+ ctx := android.BuilderContextForTesting(config)
globalSoong := GlobalSoongConfigForTests(config)
global := GlobalConfigForTests(ctx)
module := testSystemModuleConfig(ctx, "test")