-
Notifications
You must be signed in to change notification settings - Fork 155
/
Makefile.toml
357 lines (287 loc) · 11 KB
/
Makefile.toml
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
[config]
default_to_workspace = false
min_version = "0.32.1"
[config.modify_core_tasks]
private = true
namespace = "default"
[env]
# Reset rustup recursion limit because otherwise `cargo make clippy_all` fails.
# https://github.com/rust-lang/rustup.rs/blob/d35f94183601a81489bce025c2abc35cd395c909/src/toolchain.rs#L296
RUST_RECURSION_COUNT = "0"
# ---- SCRIPTS ----
[tasks.populate_all]
description = "Populate styles, tags, attributes, etc."
dependencies = ["populate_styles"]
[tasks.populate_styles]
description = "Populate styles"
env = { STYLES_ENDPOINT = "https://seed-rs.github.io/html-css-db/css_properties.json", STYLE_NAMES_FILE = "./src/dom_entity_names/styles/style_names.rs" }
script = [
'''
#!@duckscript
# fetch styles
styles_txt = http_client ${STYLES_ENDPOINT}
styles = json_parse ${styles_txt}
# generate content for style names
arr_range = range 0 ${styles.length}
style_pairs = set ""
for index in ${arr_range}
original = get_by_name styles[${index}].name.original
pascal_case = get_by_name styles[${index}].name.pascal_case
if not is_empty ${pascal_case}
style_pairs = concat ${style_pairs} " ${pascal_case} => \"${original}\",\n"
end
end
style_pairs = trim ${style_pairs}
trim_end_comma = ends_with ${style_pairs} ,
if ${trim_end_comma}
style_pairs = substring ${style_pairs} -1
end
content_for_style_names_file = set "//! This file is generated automatically by `cargo make ${CARGO_MAKE_CURRENT_TASK_NAME}`.\n"
content_for_style_names_file = concat ${content_for_style_names_file} "//! It's not meant to be edited directly.\n\n"
content_for_style_names_file = concat ${content_for_style_names_file} "make_styles! {\n"
content_for_style_names_file = concat ${content_for_style_names_file} " ${style_pairs}\n"
content_for_style_names_file = concat ${content_for_style_names_file} "}\n"
# write rust file
writefile ${STYLE_NAMES_FILE} ${content_for_style_names_file}
'''
]
# ---- GENERAL ----
[tasks.verify]
description = "Format, lint with Clippy, build, run tests, simulate publish"
dependencies = ["fmt_all", "clippy_all", "test_h_firefox", "test_examples_firefox", "publish_dry_run"]
[tasks.verify_for_ci]
description = "Like `verify`, but fails if the code isn't formatted and you should run tests with other commands."
dependencies = ["fmt_all_check", "clippy_all", "publish_dry_run"]
# ---- BUILD ----
[tasks.build]
description = "Build only Seed"
command = "cargo"
args = ["build"]
[tasks.build_release]
extend = "build"
description = "Build only Seed in relase mode"
args = ["build", "--release"]
[tasks.all]
description = "Build Seed and examples"
dependencies = ["build", "build_examples"]
[tasks.all_release]
extend = "all"
description = "Build Seed and examples in release mode"
dependencies = ["build_release", "build_examples_release"]
[tasks.one]
description = "Build Seed and chosen example. Ex: 'cargo make one counter'"
command = "cargo"
args = ["make", "--cwd", "./examples/${@}", "build"]
dependencies = ["build"]
[tasks.one_release]
extend = "one"
description = "Build Seed and chosen example in release mode. Ex: 'cargo make one counter'"
args = ["make", "--cwd", "./examples/${@}", "build_release"]
dependencies = ["build_release"]
# ---- LINT ----
[tasks.fmt_all]
description = "Format Seed and all examples with rustfmt"
dependencies = ["fmt", "fmt_examples"]
[tasks.fmt_all_check]
description = "Check format of Seed and all examples with rustfmt"
dependencies = ["fmt_check", "fmt_examples_check"]
[tasks.clippy]
description = "Lint only Seed with Clippy"
command = "cargo"
args = ["clippy", "--all-features", "--",
"--deny", "warnings",
# "--deny", "clippy::pedantic",
# "--deny", "clippy::nursery",
"--allow", "clippy::vec_init_then_push", # Vec::new() + push are used in macros in shortcuts.rs
]
dependencies = ["default::install-clippy"]
[tasks.clippy_one]
description = "Lint Seed and chosen example with Clippy. Ex: 'cargo make clippy_one counter'"
command = "cargo"
args = ["make", "--cwd", "./examples/${@}", "clippy"]
dependencies = ["clippy"]
[tasks.clippy_all]
description = "Lint Seed and all examples with Clippy"
dependencies = ["clippy", "clippy_examples"]
[tasks.publish_dry_run]
description = "Check the crate can be published"
command = "cargo"
args = ["publish", "--dry-run", "--allow-dirty"]
# ---- TEST ----
# wasm-pack test docs:
# https://rustwasm.github.io/wasm-pack/book/commands/test.html
[tasks.test]
description = "Run Seed's tests. Ex: 'cargo make test firefox'. Test envs: [chrome, firefox, safari]"
command = "wasm-pack"
args = ["test", "--${@}"]
dependencies = ["default::install-wasm-pack"]
[tasks.test_release]
extend = "test"
description = "Run Seed's tests in release mode. Ex: 'cargo make test firefox'. Test envs: [chrome, firefox, safari]"
args = ["test", "--${@}", "--release"]
[tasks.test_h]
description = "Run headless Seed's tests. Ex: 'cargo make test_h firefox'. Test envs: [chrome, firefox, safari]"
extend = "test"
args = ["test", "--headless", "--${@}"]
[tasks.test_h_firefox]
description = "Run headless Seed's tests with Firefox."
extend = "test"
args = ["test", "--headless", "--firefox"]
[tasks.test_h_firefox_serde_wasm_bindgen]
description = "Run headless Seed's tests with Firefox."
extend = "test"
args = ["test", "--headless", "--firefox", "--features", "serde-wasm-bindgen"]
[tasks.test_h_release]
extend = "test_h"
description = "Run headless Seed's tests in release mode. Ex: 'cargo make test_h firefox'. Test envs: [chrome, firefox, safari]"
args = ["test", "--headless", "--${@}", "--release"]
[tasks.test_one]
description = "Run a single test in Firefox. Ex 'cargo make test_one my_test'"
command = "wasm-pack"
args = ["test", "--firefox", "--", "--lib", "${@}"]
dependencies = ["default::install-wasm-pack"]
[tasks.test_one_h]
description = "Run a single test in headless Firefox. Ex 'cargo make test_one_h my_test'"
command = "wasm-pack"
args = ["test", "--firefox", "--headless", "--", "--lib", "${@}"]
dependencies = ["default::install-wasm-pack"]
[tasks.test_examples_firefox]
description = "Run tests in all examples in headless Firefox. Ex 'cargo make test_examples_firefox'"
command = "cargo"
args = ["make", "for_each", "test_firefox"]
# ---- START ----
[tasks.start]
description = "Start chosen example. Ex: 'cargo make start counter'"
command = "cargo"
args = ["make", "--cwd", "./examples/${@}", "start"]
[tasks.start_release]
extend = "start"
description = "Start chosen example in release mode. Ex: 'cargo make start counter'"
args = ["make", "--cwd", "./examples/${@}", "start_release"]
[tasks.start_server]
description = "Start server of chosen example (only a few have one). Ex: 'cargo make start_server websocket'"
command = "cargo"
args = ["make", "--cwd", "./examples/${@}", "start_server"]
[tasks.start_server_release]
extend = "start_server"
description = "Start server of chosen example (only a few have one) in release mode. Ex: 'cargo make start_server websocket'"
args = ["make", "--cwd", "./examples/${@}", "start_server_release"]
# ---- DEFAULT TASKS FOR EXAMPLES ----
# These tasks should be run only from the example root
# and example's Makefile.toml should override all tasks in dependencies.
[tasks.default_build]
description = "Build with wasm-pack"
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["default::install-wasm-pack"]
[tasks.default_build_release]
extend = "default_build"
description = "Build with wasm-pack in release mode"
args = ["build", "--target", "web", "--out-name", "package", "--release"]
[tasks.default_start]
description = "Build and start microserver"
install_crate = { crate_name = "microserver", binary = "microserver", test_arg = "-h" }
command = "microserver"
args = ["--port", "8000"]
dependencies = ["build"]
[tasks.default_start_release]
extend = "default_start"
description = "Build and start microserver in release mode"
dependencies = ["build_release"]
[tasks.default_test_firefox]
description = "Test with wasm-pack in Firefox"
command = "wasm-pack"
args = ["test", "--firefox", "--headless"]
dependencies = ["default::install-wasm-pack"]
[tasks.default_clippy]
description = "Lint with Clippy"
command = "cargo"
args = ["clippy", "--all-features", "--",
"--deny", "warnings",
# "--deny", "clippy::pedantic",
# "--deny", "clippy::nursery",
"--allow", "clippy::wildcard_imports", # for `use seed::{prelude::*, *};`
"--allow", "clippy::future_not_send", # JS/WASM is single threaded
"--allow", "clippy::used_underscore_binding", # some libraries break this rule
"--allow", "clippy::mixed_read_write_in_expression", # false positives
"--allow", "clippy::vec_init_then_push", # Vec::new() + push are used in macros in shortcuts.rs
]
dependencies = ["default::install-clippy"]
# ---- HELPERS -----
[tasks.build_examples]
description = "Build examples"
command = "cargo"
args = ["make", "for_each", "build"]
[tasks.build_examples_release]
extend = "build_examples"
description = "Build examples in release mode"
args = ["make", "for_each", "build_release"]
[tasks.fmt]
description = "Format with rustfmt"
command = "cargo"
args = ["fmt", "--all"]
dependencies = [ "default::install-rustfmt" ]
[tasks.fmt_check]
extend = "fmt"
description = "Check format with rustfmt"
args = ["fmt", "--all", "--", "--check"]
[tasks.fmt_examples]
description = "Format all examples with rustfmt"
command = "cargo"
args = ["make", "for_each", "fmt"]
[tasks.fmt_examples_check]
description = "Check format of all examples with rustfmt"
command = "cargo"
args = ["make", "for_each", "fmt_check"]
[tasks.clippy_examples]
description = "Lint examples with Clippy"
command = "cargo"
args = ["make", "for_each", "clippy"]
# ---- CLEAN----
[tasks.clean]
description = "Clean only Seed"
command = "cargo"
args = ["clean"]
[tasks.clean_pkg]
description = "Generic Clean command"
command = "cargo"
args = ["clean","--target-dir" ,"pkg"]
[tasks.clean_examples]
description = "Clean all examples pkg"
command = "cargo"
args = ["make", "for_each", "clean_pkg"]
[tasks.clean_all]
description = "Clean all artifact in seed and examples"
dependencies = ["clean", "clean_examples"]
[tasks.for_each]
description = "Run chosen task for each example in its root. Ex: 'cargo make for_each build'"
script = [
'''
#!@duckscript
defined = is_defined 1
assert ${defined} "Wrong number of arguments! Correct example: 'cargo make for_each build'"
task = set ${1}
handle = glob_array examples/*/Makefile.toml
for path in ${handle}
example_root = dirname ${path}
echo Example root: ${example_root}
exec --fail-on-error cargo make --cwd ${example_root} ${task}
end
'''
]
[tasks.for_each_pkg]
description = "Run chosen task for each example in its root. Ex: 'cargo make for_each build'"
script = [
'''
#!@duckscript
defined = is_defined 1
assert ${defined} "Wrong number of arguments! Correct example: 'cargo make for_each build'"
task = set ${1}
handle = glob_array examples/*/Makefile.toml
for path in ${handle}
example_root = dirname ${path}
echo Example root: ${example_root}
exec --fail-on-error cargo make --cwd ${example_root} ${task}
end
'''
]