summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-11-09 14:53:19 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-11-09 15:41:49 +0100
commitfe008d9a8e24e043de00cecc2754908f57d0a00e (patch)
treea43f899bfd366fd3b8bfcd90cf5a794a33d17094 /files
downloadrules-typesetting-fe008d9a8e24e043de00cecc2754908f57d0a00e.tar.gz
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 <oliver.reiche@huawei.com>
Diffstat (limited to 'files')
-rw-r--r--files/EXPRESSIONS36
-rw-r--r--files/RULES61
2 files changed, 97 insertions, 0 deletions
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"}
+ }
+ }
+ }
+ }
+}