Merge "Make RuleBuilder fail fast when passed a nil Path"
This commit is contained in:
@@ -769,16 +769,25 @@ type rspFileAndPaths struct {
|
|||||||
paths Paths
|
paths Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkPathNotNil(path Path) {
|
||||||
|
if path == nil {
|
||||||
|
panic("rule_builder paths cannot be nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *RuleBuilderCommand) addInput(path Path) string {
|
func (c *RuleBuilderCommand) addInput(path Path) string {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.inputs = append(c.inputs, path)
|
c.inputs = append(c.inputs, path)
|
||||||
return c.PathForInput(path)
|
return c.PathForInput(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RuleBuilderCommand) addImplicit(path Path) {
|
func (c *RuleBuilderCommand) addImplicit(path Path) {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.implicits = append(c.implicits, path)
|
c.implicits = append(c.implicits, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RuleBuilderCommand) addOrderOnly(path Path) {
|
func (c *RuleBuilderCommand) addOrderOnly(path Path) {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.orderOnlys = append(c.orderOnlys, path)
|
c.orderOnlys = append(c.orderOnlys, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1004,19 +1013,23 @@ func (c *RuleBuilderCommand) FlagWithList(flag string, list []string, sep string
|
|||||||
// Tool adds the specified tool path to the command line. The path will be also added to the dependencies returned by
|
// Tool adds the specified tool path to the command line. The path will be also added to the dependencies returned by
|
||||||
// RuleBuilder.Tools.
|
// RuleBuilder.Tools.
|
||||||
func (c *RuleBuilderCommand) Tool(path Path) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) Tool(path Path) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.tools = append(c.tools, path)
|
c.tools = append(c.tools, path)
|
||||||
return c.Text(c.PathForTool(path))
|
return c.Text(c.PathForTool(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tool adds the specified tool path to the dependencies returned by RuleBuilder.Tools.
|
// Tool adds the specified tool path to the dependencies returned by RuleBuilder.Tools.
|
||||||
func (c *RuleBuilderCommand) ImplicitTool(path Path) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) ImplicitTool(path Path) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.tools = append(c.tools, path)
|
c.tools = append(c.tools, path)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tool adds the specified tool path to the dependencies returned by RuleBuilder.Tools.
|
// Tool adds the specified tool path to the dependencies returned by RuleBuilder.Tools.
|
||||||
func (c *RuleBuilderCommand) ImplicitTools(paths Paths) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) ImplicitTools(paths Paths) *RuleBuilderCommand {
|
||||||
c.tools = append(c.tools, paths...)
|
for _, path := range paths {
|
||||||
|
c.ImplicitTool(path)
|
||||||
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,6 +1106,7 @@ func (c *RuleBuilderCommand) OrderOnlys(paths Paths) *RuleBuilderCommand {
|
|||||||
// Validation adds the specified input path to the validation dependencies by
|
// Validation adds the specified input path to the validation dependencies by
|
||||||
// RuleBuilder.Validations without modifying the command line.
|
// RuleBuilder.Validations without modifying the command line.
|
||||||
func (c *RuleBuilderCommand) Validation(path Path) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) Validation(path Path) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.validations = append(c.validations, path)
|
c.validations = append(c.validations, path)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -1100,13 +1114,16 @@ func (c *RuleBuilderCommand) Validation(path Path) *RuleBuilderCommand {
|
|||||||
// Validations adds the specified input paths to the validation dependencies by
|
// Validations adds the specified input paths to the validation dependencies by
|
||||||
// RuleBuilder.Validations without modifying the command line.
|
// RuleBuilder.Validations without modifying the command line.
|
||||||
func (c *RuleBuilderCommand) Validations(paths Paths) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) Validations(paths Paths) *RuleBuilderCommand {
|
||||||
c.validations = append(c.validations, paths...)
|
for _, path := range paths {
|
||||||
|
c.Validation(path)
|
||||||
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output adds the specified output path to the command line. The path will also be added to the outputs returned by
|
// Output adds the specified output path to the command line. The path will also be added to the outputs returned by
|
||||||
// RuleBuilder.Outputs.
|
// RuleBuilder.Outputs.
|
||||||
func (c *RuleBuilderCommand) Output(path WritablePath) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) Output(path WritablePath) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.outputs = append(c.outputs, path)
|
c.outputs = append(c.outputs, path)
|
||||||
return c.Text(c.PathForOutput(path))
|
return c.Text(c.PathForOutput(path))
|
||||||
}
|
}
|
||||||
@@ -1133,6 +1150,7 @@ func (c *RuleBuilderCommand) OutputDir() *RuleBuilderCommand {
|
|||||||
// line, and causes RuleBuilder.Build file to set the depfile flag for ninja. If multiple depfiles are added to
|
// line, and causes RuleBuilder.Build file to set the depfile flag for ninja. If multiple depfiles are added to
|
||||||
// commands in a single RuleBuilder then RuleBuilder.Build will add an extra command to merge the depfiles together.
|
// commands in a single RuleBuilder then RuleBuilder.Build will add an extra command to merge the depfiles together.
|
||||||
func (c *RuleBuilderCommand) DepFile(path WritablePath) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) DepFile(path WritablePath) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.depFiles = append(c.depFiles, path)
|
c.depFiles = append(c.depFiles, path)
|
||||||
return c.Text(c.PathForOutput(path))
|
return c.Text(c.PathForOutput(path))
|
||||||
}
|
}
|
||||||
@@ -1155,6 +1173,7 @@ func (c *RuleBuilderCommand) ImplicitOutputs(paths WritablePaths) *RuleBuilderCo
|
|||||||
// will be a symlink instead of a regular file. Does not modify the command
|
// will be a symlink instead of a regular file. Does not modify the command
|
||||||
// line.
|
// line.
|
||||||
func (c *RuleBuilderCommand) ImplicitSymlinkOutput(path WritablePath) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) ImplicitSymlinkOutput(path WritablePath) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.symlinkOutputs = append(c.symlinkOutputs, path)
|
c.symlinkOutputs = append(c.symlinkOutputs, path)
|
||||||
return c.ImplicitOutput(path)
|
return c.ImplicitOutput(path)
|
||||||
}
|
}
|
||||||
@@ -1172,6 +1191,7 @@ func (c *RuleBuilderCommand) ImplicitSymlinkOutputs(paths WritablePaths) *RuleBu
|
|||||||
// SymlinkOutput declares the specified path as an output that will be a symlink
|
// SymlinkOutput declares the specified path as an output that will be a symlink
|
||||||
// instead of a regular file. Modifies the command line.
|
// instead of a regular file. Modifies the command line.
|
||||||
func (c *RuleBuilderCommand) SymlinkOutput(path WritablePath) *RuleBuilderCommand {
|
func (c *RuleBuilderCommand) SymlinkOutput(path WritablePath) *RuleBuilderCommand {
|
||||||
|
checkPathNotNil(path)
|
||||||
c.symlinkOutputs = append(c.symlinkOutputs, path)
|
c.symlinkOutputs = append(c.symlinkOutputs, path)
|
||||||
return c.Output(path)
|
return c.Output(path)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user