diff options
author | 2019-07-08 17:08:34 -0700 | |
---|---|---|
committer | 2019-07-11 13:05:19 -0700 | |
commit | ee94d6ab14ee9480e9c68ca9616698ba2bd93e70 (patch) | |
tree | d56576f100e7d7cee2f16c47f0d9bf5ecee52c3b /android/rule_builder.go | |
parent | a3002fc7abb9d3691b1f4d4316a1c4ee256c79dd (diff) |
Add RuleBuilder helper functions for built and prebuilt tools
Replace the common pattern of:
cmd.Tool(ctx.Config().HostToolPath(ctx, "tool"))
with:
cmd.BuiltTool("tool")
And similarly for PrebuiltBuildTool.
Test: m checkbuild
Change-Id: I7d63188505362c7df6a3b3e7330b4a2cca5a2409
Diffstat (limited to 'android/rule_builder.go')
-rw-r--r-- | android/rule_builder.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/android/rule_builder.go b/android/rule_builder.go index e53eb0d2a..5797bc262 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -284,7 +284,7 @@ var _ BuilderContext = SingletonContext(nil) func (r *RuleBuilder) depFileMergerCmd(ctx PathContext, depFiles WritablePaths) *RuleBuilderCommand { return r.Command(). - Tool(ctx.Config().HostToolPath(ctx, "dep_fixer")). + BuiltTool(ctx, "dep_fixer"). Inputs(depFiles.Paths()) } @@ -352,7 +352,7 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string } sboxCmd := &RuleBuilderCommand{} - sboxCmd.Tool(ctx.Config().HostToolPath(ctx, "sbox")). + sboxCmd.BuiltTool(ctx, "sbox"). Flag("-c").Text(commandString). Flag("--sandbox-path").Text(shared.TempDirForOutDir(PathForOutput(ctx).String())). Flag("--output-root").Text(r.sboxOutDir.String()). @@ -478,6 +478,24 @@ func (c *RuleBuilderCommand) Tool(path Path) *RuleBuilderCommand { return c.Text(path.String()) } +// BuiltTool adds the specified tool path that was built using a host Soong module to the command line. The path will +// be also added to the dependencies returned by RuleBuilder.Tools. +// +// It is equivalent to: +// cmd.Tool(ctx.Config().HostToolPath(ctx, tool)) +func (c *RuleBuilderCommand) BuiltTool(ctx PathContext, tool string) *RuleBuilderCommand { + return c.Tool(ctx.Config().HostToolPath(ctx, tool)) +} + +// PrebuiltBuildTool adds the specified tool path from prebuils/build-tools. The path will be also added to the +// dependencies returned by RuleBuilder.Tools. +// +// It is equivalent to: +// cmd.Tool(ctx.Config().PrebuiltBuildTool(ctx, tool)) +func (c *RuleBuilderCommand) PrebuiltBuildTool(ctx PathContext, tool string) *RuleBuilderCommand { + return c.Tool(ctx.Config().PrebuiltBuildTool(ctx, tool)) +} + // Input adds the specified input path to the command line. The path will also be added to the dependencies returned by // RuleBuilder.Inputs. func (c *RuleBuilderCommand) Input(path Path) *RuleBuilderCommand { |