summaryrefslogtreecommitdiff
path: root/android/rule_builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/rule_builder.go')
-rw-r--r--android/rule_builder.go40
1 files changed, 39 insertions, 1 deletions
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 06e82c8e9..2507c4c83 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -283,6 +283,28 @@ func (r *RuleBuilder) OrderOnlys() Paths {
return orderOnlyList
}
+// Validations returns the list of paths that were passed to RuleBuilderCommand.Validation or
+// RuleBuilderCommand.Validations. The list is sorted and duplicates removed.
+func (r *RuleBuilder) Validations() Paths {
+ validations := make(map[string]Path)
+ for _, c := range r.commands {
+ for _, validation := range c.validations {
+ validations[validation.String()] = validation
+ }
+ }
+
+ var validationList Paths
+ for _, validation := range validations {
+ validationList = append(validationList, validation)
+ }
+
+ sort.Slice(validationList, func(i, j int) bool {
+ return validationList[i].String() < validationList[j].String()
+ })
+
+ return validationList
+}
+
func (r *RuleBuilder) outputSet() map[string]WritablePath {
outputs := make(map[string]WritablePath)
for _, c := range r.commands {
@@ -460,7 +482,6 @@ func (r *RuleBuilder) Build(name string, desc string) {
r.ctx.Build(pctx, BuildParams{
Rule: ErrorRule,
Outputs: r.Outputs(),
- OrderOnly: r.OrderOnlys(),
Description: desc,
Args: map[string]string{
"error": "missing dependencies: " + strings.Join(r.missingDeps, ", "),
@@ -707,6 +728,8 @@ func (r *RuleBuilder) Build(name string, desc string) {
}),
Inputs: rspFileInputs,
Implicits: inputs,
+ OrderOnly: r.OrderOnlys(),
+ Validations: r.Validations(),
Output: output,
ImplicitOutputs: implicitOutputs,
SymlinkOutputs: r.SymlinkOutputs(),
@@ -727,6 +750,7 @@ type RuleBuilderCommand struct {
inputs Paths
implicits Paths
orderOnlys Paths
+ validations Paths
outputs WritablePaths
symlinkOutputs WritablePaths
depFiles WritablePaths
@@ -1061,6 +1085,20 @@ func (c *RuleBuilderCommand) OrderOnlys(paths Paths) *RuleBuilderCommand {
return c
}
+// Validation adds the specified input path to the validation dependencies by
+// RuleBuilder.Validations without modifying the command line.
+func (c *RuleBuilderCommand) Validation(path Path) *RuleBuilderCommand {
+ c.validations = append(c.validations, path)
+ return c
+}
+
+// Validations adds the specified input paths to the validation dependencies by
+// RuleBuilder.Validations without modifying the command line.
+func (c *RuleBuilderCommand) Validations(paths Paths) *RuleBuilderCommand {
+ c.validations = append(c.validations, paths...)
+ return c
+}
+
// Output adds the specified output path to the command line. The path will also be added to the outputs returned by
// RuleBuilder.Outputs.
func (c *RuleBuilderCommand) Output(path WritablePath) *RuleBuilderCommand {