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
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user