From fe008d9a8e24e043de00cecc2754908f57d0a00e Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 9 Nov 2022 14:53:19 +0100 Subject: Initial commit The rules are still very basic; in particular, the latex rules do not support bibtex. Nevertheless, having typesetting rules in that basic form is already useful, especially when creating documents (slides, handbooks, web pages, etc) containing generated files, like sample logs of tools under development. Co-authored-by: Oliver Reiche --- files/EXPRESSIONS | 36 ++++++++++++++++++++++++++++++++ files/RULES | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 files/EXPRESSIONS create mode 100644 files/RULES (limited to 'files') diff --git a/files/EXPRESSIONS b/files/EXPRESSIONS new file mode 100644 index 0000000..7a418c4 --- /dev/null +++ b/files/EXPRESSIONS @@ -0,0 +1,36 @@ +{ "order": + { "expression": + { "type": "++" + , "$1": + { "type": "foreach" + , "var": "dep" + , "range": {"type": "FIELD", "name": "srcs"} + , "body": + { "type": "if" + , "cond": + { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "dep"} + , "provider": "keys" + } + , "then": + { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "dep"} + , "provider": "keys" + } + , "else": + { "type": "keys" + , "$1": + { "type": "map_union" + , "$1": + [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "dep"}} + , { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "dep"} + } + ] + } + } + } + } + } + } +} diff --git a/files/RULES b/files/RULES new file mode 100644 index 0000000..891ff55 --- /dev/null +++ b/files/RULES @@ -0,0 +1,61 @@ +{ "ordered": + { "doc": + [ "Collect the runfiles and artifacts of the \"srcs\" targets, keeping" + , "record of the order of the targets (in a provider). In this way," + , "a sequence of files can be described at a single place and used later" + , "in several targets where order matters and the respective provider is" + , "supported. As this rule supports its own provider, chaining is possible." + ] + , "target_fields": ["srcs"] + , "field_doc": + { "srcs": + [ "The files to include, in order. For targets that are defined by this" + , "rule, the provided order in honored." + ] + } + , "artifacts_doc": + [ "The runfiles and artifacts of the \"srcs\" field." + , "Within each target, artifacts take precedence; different targets in" + , "the \"srcs\" field may not conflict" + ] + , "runfiles_doc": ["Same as artifacts"] + , "provides_doc": + {"keys": ["The keys of the artifacts in the intended order."]} + , "imports": {"order": "order"} + , "expression": + { "type": "let*" + , "bindings": + [ [ "srcs" + , { "type": "disjoint_map_union" + , "msg": "Sources may not conflict" + , "$1": + { "type": "foreach" + , "var": "x" + , "range": {"type": "FIELD", "name": "srcs"} + , "body": + { "type": "map_union" + , "$1": + [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} + , { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "x"} + } + ] + } + } + } + ] + , ["order", {"type": "CALL_EXPRESSION", "name": "order"}] + ] + , "body": + { "type": "RESULT" + , "runfiles": {"type": "var", "name": "srcs"} + , "artifacts": {"type": "var", "name": "srcs"} + , "provides": + { "type": "singleton_map" + , "key": "keys" + , "value": {"type": "var", "name": "order"} + } + } + } + } +} -- cgit v1.2.3