summaryrefslogtreecommitdiff
path: root/rules/data/RULES
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-05-05 16:28:14 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-05-06 05:47:40 +0200
commitf6f32aa6d88b7bb1691fa80dffa31918b11be432 (patch)
treedb04b8bb6adcc8194beeccf26731bea4cc8ee7bb /rules/data/RULES
parent6a467ee44c933af9755e4bf2d8308218a16710c7 (diff)
downloadrules-cc-f6f32aa6d88b7bb1691fa80dffa31918b11be432.tar.gz
["data", "staged"]: support dropping paths
In this way, GLOB constructs can be used more easily. As the dropping happens early, this can also be used to solve staging conflicts, by removing that logical path and later add a consolidated artifact to that path.
Diffstat (limited to 'rules/data/RULES')
-rw-r--r--rules/data/RULES39
1 files changed, 34 insertions, 5 deletions
diff --git a/rules/data/RULES b/rules/data/RULES
index feb1a73..d1f8975 100644
--- a/rules/data/RULES
+++ b/rules/data/RULES
@@ -1,7 +1,7 @@
{ "staged":
{ "doc": ["Stage data to a logical subdirectory."]
, "target_fields": ["srcs", "deps"]
- , "string_fields": ["stage"]
+ , "string_fields": ["stage", "drop"]
, "field_doc":
{ "srcs": ["The files to be staged"]
, "stage":
@@ -12,9 +12,15 @@
[ "Targets of with their runfiles should be added as well."
, "Their staging is not changed."
]
+ , "drop":
+ [ "List of paths to drop from (each of) the \"srcs\" targets"
+ , "before joining and staging. In this way, GLOB constructs can"
+ , "be used is \"srcs\"."
+ ]
}
, "artifacts_doc":
- [ "The runfiles of the \"srcs\" targets staged to the directory"
+ [ "The runfiles and artifacts of the \"srcs\" targets, leaving out"
+ , "the ones with logical path in \"drop\", staged to the directory"
, "specified in \"stage\" together the runfiles of the targets"
, "specied in the field \"deps\" (in their original location)."
]
@@ -22,6 +28,8 @@
, "imports":
{ "runfiles": ["./", "..", "field_runfiles"]
, "artifacts": ["./", "..", "field_artifacts"]
+ , "runfiles w/o": "field_artifacts_without"
+ , "artifacts w/o": "field_artifacts_without"
}
, "expression":
{ "type": "let*"
@@ -32,15 +40,36 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
+ , [ "exclude"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "drop"}
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "_"}
+ , "value": true
+ }
+ }
+ }
+ ]
, [ "srcs"
, { "type": "let*"
, "bindings": [["fieldname", "srcs"]]
, "body":
{ "type": "map_union"
, "$1":
- [ {"type": "CALL_EXPRESSION", "name": "runfiles"}
- , {"type": "CALL_EXPRESSION", "name": "artifacts"}
- ]
+ { "type": "if"
+ , "cond": {"type": "var", "name": "exclude"}
+ , "then":
+ [ {"type": "CALL_EXPRESSION", "name": "runfiles w/o"}
+ , {"type": "CALL_EXPRESSION", "name": "artifacts w/o"}
+ ]
+ , "else":
+ [ {"type": "CALL_EXPRESSION", "name": "runfiles"}
+ , {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ ]
+ }
}
}
]