1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
{ "standalone":
{ "doc":
[ "A standalone latex run"
, ""
, "Define a pdf file as the output of running pdflatex. A correct staging"
, "of the needed files has to be given through the runfiles of \"deps\"."
]
, "target_fields": ["deps", "srcs"]
, "string_fields": ["main", "stage"]
, "field_doc":
{ "srcs": ["The files needed for the latex run."]
, "stage":
[ "The directory the \"srcs\" logically reside in."
, "Entries are joined with \"/\"."
]
, "deps":
["Runfiles needed for the run of the standalone latex invocation"]
, "main":
[ "The entry point for the latex run; should be the base name"
, "of a .tex file in \"srcs\"; the \"stage\" is prepended automatically."
]
}
, "config_vars": ["env", "latex", "TYPESETTING_EXECUTION_PROPERTIES"]
, "config_doc":
{ "latex": ["Name of the latex command, defaults to \"pdflatex\"."]
, "env":
[ "Any override to the default environment which sets only"
, "PATH and SOURCE_DATE_EPOCH"
]
, "TYPESETTING_EXECUTION_PROPERTIES":
[ "Map of additional remote-execution properties to add for the typesetting"
, "actions; defaults to the empty map."
]
}
, "implicit": {"runner": ["latex_runner.sh"]}
, "imports":
{ "singleton": ["./", "..", "stage_singleton_field"]
, "call latex": "call latex"
}
, "expression":
{ "type": "let*"
, "bindings":
[ ["srcs", {"type": "FIELD", "name": "srcs"}]
, ["main", {"type": "FIELD", "name": "main"}]
, ["deps", {"type": "FIELD", "name": "deps"}]
, ["stage", {"type": "FIELD", "name": "stage"}]
, ["output file extension", [".pdf"]]
, [ "env"
, {"type": "var", "name": "env", "default": {"type": "empty_map"}}
]
, ["executable", {"type": "var", "name": "latex", "default": "pdflatex"}]
, [ "runner"
, { "type": "let*"
, "bindings": [["fieldname", "runner"], ["location", "runner"]]
, "body": {"type": "CALL_EXPRESSION", "name": "singleton"}
}
]
, ["runner type", "standalone"]
]
, "body": {"type": "CALL_EXPRESSION", "name": "call latex"}
}
}
, "verbatim":
{ "doc": ["Add \\begin{verbatim}...\\end{verbatim} around files"]
, "target_fields": ["srcs"]
, "string_fields": ["prefix", "stage"]
, "field_doc":
{ "srcs":
[ "The files to transform to tex files containing them verbatim."
, "In the output file, the ending is changed to .tex"
]
, "prefix": ["Additional prefix to add to the output file name"]
, "stage": ["The logical directory to stage the outputs to"]
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "srcs"
, { "type": "disjoint_map_union"
, "msg": "Source files must not overlap, as this would lead to overlapping output"
, "$1":
{ "type": "foreach"
, "var": "src"
, "range": {"type": "FIELD", "name": "srcs"}
, "body":
{"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "src"}}
}
}
]
, [ "verbatim files"
, { "type": "disjoint_map_union"
, "msg":
[ "Outputfiles must not overlap"
, "Input file names:"
, {"type": "keys", "map": {"type": "var", "name": "srcs"}}
]
, "$1":
{ "type": "foreach_map"
, "var_key": "src"
, "var_val": "input"
, "range": {"type": "var", "name": "srcs"}
, "body":
{ "type": "let*"
, "bindings":
[ [ "action out"
, { "type": "ACTION"
, "inputs":
{ "type": "map_union"
, "$1":
[ { "type": "singleton_map"
, "key": "in"
, "value": {"type": "var", "name": "input"}
}
, { "type": "singleton_map"
, "key": "begin"
, "value":
{"type": "BLOB", "data": "\\begin{verbatim}\n"}
}
, { "type": "singleton_map"
, "key": "end"
, "value":
{"type": "BLOB", "data": "\\end{verbatim}\n"}
}
]
}
, "outs": ["out"]
, "cmd": ["sh", "-c", "cat begin in end > out"]
}
]
, [ "out"
, { "type": "lookup"
, "map": {"type": "var", "name": "action out"}
, "key": "out"
}
]
, [ "out name"
, { "type": "join"
, "$1":
[ { "type": "join"
, "$1": {"type": "FIELD", "name": "prefix"}
}
, { "type": "change_ending"
, "ending": ".tex"
, "$1": {"type": "var", "name": "src"}
}
]
}
]
]
, "body":
{ "type": "singleton_map"
, "key": {"type": "var", "name": "out name"}
, "value": {"type": "var", "name": "out"}
}
}
}
}
]
, [ "stage"
, { "type": "join"
, "separator": "/"
, "$1": {"type": "FIELD", "name": "stage"}
}
]
, [ "staged verbatim files"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
, "$1": {"type": "var", "name": "verbatim files"}
}
]
]
, "body":
{ "type": "RESULT"
, "artifacts": {"type": "var", "name": "staged verbatim files"}
, "runfiles": {"type": "var", "name": "staged verbatim files"}
}
}
}
, "latexmk":
{ "doc":
[ "A latexmk run"
, ""
, "Call latexmk passing main as the entry point. A correct staging"
, "of the needed files has to be given through the runfiles of \"deps\"."
]
, "target_fields": ["deps", "srcs"]
, "string_fields": ["main", "stage", "opts", "output extension"]
, "field_doc":
{ "srcs": ["The files needed for the latexmk run."]
, "stage":
[ "The directory the \"srcs\" logically reside in."
, "Entries are joined with \"/\"."
]
, "deps":
["Runfiles needed for the run of the standalone latex invocation"]
, "main":
[ "The entry point for the latex run; should be the base name"
, "of a .tex file in \"srcs\"; the \"stage\" is prepended automatically."
]
, "opts":
["The latexmk options to be used.", "If omitted, \"-pdf\" is assumed"]
, "output extension":
[ "The extension of the output to be produced (e.g., \".ps\", \".pdf\")."
, "If omitted, \".pdf\" is assumed."
]
}
, "config_vars": ["env", "latexmk", "TYPESETTING_EXECUTION_PROPERTIES"]
, "config_doc":
{ "env":
[ "Any override to the default environment which sets only"
, "PATH and SOURCE_DATE_EPOCH"
]
, "latexmk": ["Name of the latexmk command, defaults to \"latexmk\"."]
, "TYPESETTING_EXECUTION_PROPERTIES":
[ "Map of additional remote-execution properties to add for the typesetting"
, "actions; defaults to the empty map."
]
}
, "imports": {"call latex": "call latex"}
, "expression":
{ "type": "let*"
, "bindings":
[ ["srcs", {"type": "FIELD", "name": "srcs"}]
, ["main", {"type": "FIELD", "name": "main"}]
, ["deps", {"type": "FIELD", "name": "deps"}]
, ["stage", {"type": "FIELD", "name": "stage"}]
, [ "output file extension"
, { "type": "if"
, "cond": {"type": "FIELD", "name": "output extension"}
, "then": {"type": "FIELD", "name": "output extension"}
, "else": [".pdf"]
}
]
, [ "env"
, {"type": "var", "name": "env", "default": {"type": "empty_map"}}
]
, [ "executable"
, {"type": "var", "name": "latexmk", "default": "latexmk"}
]
, ["opts", {"type": "FIELD", "name": "opts"}]
, [ "runner"
, { "type": "singleton_map"
, "key": "runner"
, "value":
{ "type": "BLOB"
, "data":
{ "type": "join"
, "separator": "\n"
, "$1":
[ "set -e"
, "LATEXMK=\"$1\""
, "shift"
, "MAIN=\"$1\""
, "shift"
, "cd work"
, "\"$LATEXMK\" -output-directory=\"$(dirname \"$MAIN\")\" \"$@\" \"$MAIN\" > log 2>&1 || (cat log && exit 1)"
]
}
}
}
]
, ["runner type", "latexmk"]
]
, "body": {"type": "CALL_EXPRESSION", "name": "call latex"}
}
}
}
|