diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-04-26 16:51:01 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-04-26 18:24:36 +0200 |
commit | 8bbb5274b2779aae44a0c4f76da8df08cf63da84 (patch) | |
tree | 5787e11a0e441a23c37976f02b92ab6ff96064bd | |
parent | 6fa381769ea5ac3505cc202ae442eb7fee35f4ce (diff) | |
download | rules-cc-8bbb5274b2779aae44a0c4f76da8df08cf63da84.tar.gz |
rules: Add field_artifacts_list and field_runfiles_list
... which are more efficient if the caller wants to perform
the union manually (because disjointness should be enforced
or additional maps should be added to the union, etc.). As a
positive side effect, code reuse is slightly increased by
consistently calling these newly introduced expressions for
obtaining the artifacts/runfiles from all targets of a
target field.
-rw-r--r-- | CC/EXPRESSIONS | 22 | ||||
-rw-r--r-- | CC/IDE/RULES | 35 | ||||
-rw-r--r-- | CC/RULES | 9 | ||||
-rw-r--r-- | CC/proto/EXPRESSIONS | 19 | ||||
-rw-r--r-- | CC/test/RULES | 9 | ||||
-rw-r--r-- | EXPRESSIONS | 86 | ||||
-rw-r--r-- | data/RULES | 9 | ||||
-rw-r--r-- | proto/RULES | 10 | ||||
-rw-r--r-- | shell/test/EXPRESSIONS | 28 |
9 files changed, 110 insertions, 117 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index efaf577..b7b755d 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -134,6 +134,7 @@ { "deps-fieldnames": ["List of target_field names to collect dependencies from."] } + , "imports": {"runfiles_list": ["./", "..", "field_runfiles_list"]} , "expression": { "type": "disjoint_map_union" , "$1": @@ -156,15 +157,7 @@ , "default": {"type": "empty_map"} } } - , { "type": "foreach" - , "var": "target" - , "range": - {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} - , "body": - { "type": "DEP_RUNFILES" - , "dep": {"type": "var", "name": "target"} - } - } + , {"type": "CALL_EXPRESSION", "name": "runfiles_list"} ] } } @@ -178,6 +171,7 @@ { "deps-fieldnames": ["List of target_field names to collect dependencies from."] } + , "imports": {"artifacts_list": ["./", "..", "field_artifacts_list"]} , "expression": { "type": "disjoint_map_union" , "$1": @@ -200,15 +194,7 @@ , "default": {"type": "empty_map"} } } - , { "type": "foreach" - , "var": "target" - , "range": - {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} - , "body": - { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "target"} - } - } + , {"type": "CALL_EXPRESSION", "name": "artifacts_list"} ] } } diff --git a/CC/IDE/RULES b/CC/IDE/RULES index 31da688..dc4b607 100644 --- a/CC/IDE/RULES +++ b/CC/IDE/RULES @@ -20,7 +20,7 @@ } } } - , "imports": {"runfiles": ["./", "../..", "field_runfiles"]} + , "imports": {"runfiles_list": ["./", "../..", "field_runfiles_list"]} , "expression": { "type": "let*" , "bindings": @@ -36,13 +36,14 @@ , "$1": { "type": "map_union" , "$1": - [ { "type": "let*" - , "bindings": [["fieldname", "proto-deps"]] - , "body": {"type": "CALL_EXPRESSION", "name": "runfiles"} - } - , { "type": "map_union" - , "$1": - { "type": "foreach" + { "type": "++" + , "$1": + [ { "type": "let*" + , "bindings": [["fieldname", "proto-deps"]] + , "body": + {"type": "CALL_EXPRESSION", "name": "runfiles_list"} + } + , { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "proto-deps"} , "body": @@ -58,14 +59,12 @@ } } } - } - , { "type": "let*" - , "bindings": [["fieldname", "deps"]] - , "body": {"type": "CALL_EXPRESSION", "name": "runfiles"} - } - , { "type": "map_union" - , "$1": - { "type": "foreach" + , { "type": "let*" + , "bindings": [["fieldname", "deps"]] + , "body": + {"type": "CALL_EXPRESSION", "name": "runfiles_list"} + } + , { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "deps"} , "body": @@ -81,8 +80,8 @@ } } } - } - ] + ] + } } } ] @@ -117,17 +117,16 @@ } , "artifacts_doc": ["The single tree artifact staged to the given location"] , "runfiles_doc": ["Same as artifacts"] + , "imports": {"runfiles_list": ["./", "..", "field_runfiles_list"]} , "expression": { "type": "let*" , "bindings": [ [ "hdrs" , { "type": "disjoint_map_union" , "$1": - { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "hdrs"} - , "body": - {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} + { "type": "let*" + , "bindings": [["fieldname", "hdrs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "runfiles_list"} } } ] diff --git a/CC/proto/EXPRESSIONS b/CC/proto/EXPRESSIONS index dd48744..4b08a2c 100644 --- a/CC/proto/EXPRESSIONS +++ b/CC/proto/EXPRESSIONS @@ -19,7 +19,7 @@ , "imports": { "stage": ["", "stage_singleton_field"] , "result": ["./", "..", "lib result"] - , "field_runfiles": ["", "field_runfiles"] + , "artifacts_list": ["./", "../..", "field_artifacts_list"] , "protoc-deps": "protoc-deps" } , "expression": @@ -52,11 +52,10 @@ , "$1": { "type": "disjoint_map_union" , "$1": - { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "well_known_protos"} - , "body": - {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "x"}} + { "type": "let*" + , "bindings": + [["fieldname", "well_known_protos"], ["transition", null]] + , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"} } } } @@ -65,11 +64,9 @@ , { "type": "disjoint_map_union" , "msg": "Sources may not conflict" , "$1": - { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "srcs"} - , "body": - {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "x"}} + { "type": "let*" + , "bindings": [["fieldname", "srcs"], ["transition", null]] + , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"} } } ] diff --git a/CC/test/RULES b/CC/test/RULES index af20510..3f8e236 100644 --- a/CC/test/RULES +++ b/CC/test/RULES @@ -58,6 +58,7 @@ ] , "imports": { "artifacts": ["./", "../..", "field_artifacts"] + , "runfiles_list": ["./", "../..", "field_runfiles_list"] , "compile-deps": ["./", "..", "compile-deps"] , "link-deps": ["./", "..", "link-deps"] , "objects": ["./", "..", "objects"] @@ -236,11 +237,9 @@ , { "type": "disjoint_map_union" , "msg": "Data runfiles may not conflict" , "$1": - { "type": "foreach" - , "var": "dep" - , "range": {"type": "FIELD", "name": "data"} - , "body": - {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "dep"}} + { "type": "let*" + , "bindings": [["fieldname", "data"]] + , "body": {"type": "CALL_EXPRESSION", "name": "runfiles_list"} } } ] diff --git a/EXPRESSIONS b/EXPRESSIONS index 8c53612..3251f92 100644 --- a/EXPRESSIONS +++ b/EXPRESSIONS @@ -1,43 +1,65 @@ -{ "field_artifacts": - { "vars": ["fieldname", "transition"] +{ "field_artifacts_list": + { "doc": ["Query list of artifacts from target_field's targets"] + , "vars": ["fieldname", "transition"] + , "vars_doc": + { "fieldname": "The name of the target_field to query." + , "transition": "The optional configuration transition for the targets." + } + , "expression": + { "type": "foreach" + , "var": "x" + , "range": {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} + , "body": + { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "x"} + , "transition": + {"type": "var", "name": "transition", "default": {"type": "empty_map"}} + } + } + } +, "field_artifacts": + { "doc": ["Query and merge artifacts from target_field's targets"] + , "vars": ["fieldname", "transition"] + , "vars_doc": + { "fieldname": "The name of the target_field to query." + , "transition": "The optional configuration transition for the targets." + } + , "imports": {"artifacts_list": "field_artifacts_list"} , "expression": { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "x" - , "range": - {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} - , "body": - { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "x"} - , "transition": - { "type": "var" - , "name": "transition" - , "default": {"type": "empty_map"} - } - } + , "$1": {"type": "CALL_EXPRESSION", "name": "artifacts_list"} + } + } +, "field_runfiles_list": + { "doc": ["Query list of runfiles from target_field's targets"] + , "vars": ["fieldname", "transition"] + , "vars_doc": + { "fieldname": "The name of the target_field to query." + , "transition": "The optional configuration transition for the targets." + } + , "expression": + { "type": "foreach" + , "var": "x" + , "range": {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} + , "body": + { "type": "DEP_RUNFILES" + , "dep": {"type": "var", "name": "x"} + , "transition": + {"type": "var", "name": "transition", "default": {"type": "empty_map"}} } } } , "field_runfiles": - { "vars": ["fieldname", "transition"] + { "doc": ["Query and merge runfiles from target_field's targets"] + , "vars": ["fieldname", "transition"] + , "vars_doc": + { "fieldname": "The name of the target_field to query." + , "transition": "The optional configuration transition for the targets." + } + , "imports": {"runfiles_list": "field_runfiles_list"} , "expression": { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "x" - , "range": - {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} - , "body": - { "type": "DEP_RUNFILES" - , "dep": {"type": "var", "name": "x"} - , "transition": - { "type": "var" - , "name": "transition" - , "default": {"type": "empty_map"} - } - } - } + , "$1": {"type": "CALL_EXPRESSION", "name": "runfiles_list"} } } , "action_env": @@ -14,6 +14,7 @@ , "specified in \"stage\"." ] , "runfiles_doc": ["Same as artifacts"] + , "imports": {"runfiles_list": ["./", "..", "field_runfiles_list"]} , "expression": { "type": "let*" , "bindings": @@ -26,11 +27,9 @@ , [ "srcs" , { "type": "disjoint_map_union" , "$1": - { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "srcs"} - , "body": - {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} + { "type": "let*" + , "bindings": [["fieldname", "srcs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "runfiles_list"} } } ] diff --git a/proto/RULES b/proto/RULES index 74182a9..5d1b853 100644 --- a/proto/RULES +++ b/proto/RULES @@ -29,6 +29,7 @@ , "\"service library\"." ] } + , "imports": {"artifacts_list": ["./", "..", "field_artifacts_list"]} , "expression": { "type": "let*" , "bindings": @@ -55,13 +56,10 @@ { "type": "disjoint_map_union" , "msg": "Sources have to be conflict free" , "$1": - { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "srcs"} + { "type": "let*" + , "bindings": [["fieldname", "srcs"]] , "body": - { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "x"} - } + {"type": "CALL_EXPRESSION", "name": "artifacts_list"} } } } diff --git a/shell/test/EXPRESSIONS b/shell/test/EXPRESSIONS index 2b9a62e..2a99876 100644 --- a/shell/test/EXPRESSIONS +++ b/shell/test/EXPRESSIONS @@ -1,5 +1,9 @@ { "test-action": { "vars": ["name", "test.sh", "ATTEMPT"] + , "imports": + { "artifacts_list": ["./", "../..", "field_artifacts_list"] + , "runfiles_list": ["./", "../..", "field_runfiles_list"] + } , "expression": { "type": "let*" , "bindings": @@ -39,23 +43,13 @@ , "$1": { "type": "++" , "$1": - [ { "type": "foreach" - , "var": "dep" - , "range": {"type": "FIELD", "name": "deps"} - , "body": - { "type": "DEP_RUNFILES" - , "dep": {"type": "var", "name": "dep"} - } - } - , { "type": "foreach" - , "var": "dep" - , "range": {"type": "FIELD", "name": "deps"} - , "body": - { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "dep"} - } - } - ] + { "type": "let*" + , "bindings": [["fieldname", "deps"]] + , "body": + [ {"type": "CALL_EXPRESSION", "name": "runfiles_list"} + , {"type": "CALL_EXPRESSION", "name": "artifacts_list"} + ] + } } } } |