summaryrefslogtreecommitdiff
path: root/CC
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2022-04-26 16:51:01 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2022-04-26 18:24:36 +0200
commit8bbb5274b2779aae44a0c4f76da8df08cf63da84 (patch)
tree5787e11a0e441a23c37976f02b92ab6ff96064bd /CC
parent6fa381769ea5ac3505cc202ae442eb7fee35f4ce (diff)
downloadrules-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.
Diffstat (limited to 'CC')
-rw-r--r--CC/EXPRESSIONS22
-rw-r--r--CC/IDE/RULES35
-rw-r--r--CC/RULES9
-rw-r--r--CC/proto/EXPRESSIONS19
-rw-r--r--CC/test/RULES9
5 files changed, 37 insertions, 57 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 @@
}
}
}
- }
- ]
+ ]
+ }
}
}
]
diff --git a/CC/RULES b/CC/RULES
index d1925e6..0c87721 100644
--- a/CC/RULES
+++ b/CC/RULES
@@ -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"}
}
}
]