forked from uutils/coreutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.toml
436 lines (384 loc) · 10.1 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# spell-checker:ignore (cargo-make) duckscript
[config]
min_version = "0.26.2"
default_to_workspace = false
init_task = "_init_task"
[config.modify_core_tasks]
namespace = "core"
### initialization
### * note: the task executed from 'init_task' ignores dependencies; workaround is to run a secondary task via 'run_task'
[tasks._init_task]
# dependencies are unavailable
# * delegate (via 'run_task') to "real" initialization task ('_init') with full capabilities
private = true
run_task = "_init"
[tasks._init]
private = true
dependencies = [
"_init-vars",
]
[tasks._init-vars]
private = true
script_runner = "@duckscript"
script = [
'''
# reset build/test flags
set_env CARGO_MAKE_CARGO_BUILD_TEST_FLAGS ""
# determine features
env_features = get_env CARGO_FEATURES
if is_empty "${env_features}"
env_features = get_env FEATURES
end_if
if is_empty "${env_features}"
if eq "${CARGO_MAKE_RUST_TARGET_OS}" "macos"
features = set "unix"
else
if eq "${CARGO_MAKE_RUST_TARGET_OS}" "linux"
features = set "unix"
else
if eq "${CARGO_MAKE_RUST_TARGET_OS}" "windows"
features = set "windows"
end_if
end_if
end_if
end_if
if is_empty "${features}"
features = set "${env_features}"
else
if not is_empty "${env_features}"
features = set "${features},${env_features}"
end_if
end_if
# set build flags from features
if not is_empty "${features}"
set_env CARGO_MAKE_VAR_BUILD_TEST_FEATURES "${features}"
set_env CARGO_MAKE_CARGO_BUILD_TEST_FLAGS "--features ${features}"
end_if
# determine show-utils helper script
show_utils = set "util/show-utils.sh"
if eq "${CARGO_MAKE_RUST_TARGET_OS}" "windows"
show_utils = set "util/show-utils.BAT"
end_if
set_env CARGO_MAKE_VAR_SHOW_UTILS "${show_utils}"
# rebuild CARGO_MAKE_TASK_ARGS for various targets
args = set ${CARGO_MAKE_TASK_ARGS}
# * rebuild for 'features' target
args_features = replace ${args} ";" ","
set_env CARGO_MAKE_TASK_BUILD_FEATURES_ARGS "${args_features}"
# * rebuild for 'examples' target
args_examples = replace ${args} ";" " --example "
if is_empty "${args_examples}"
args_examples = set "--examples"
end_if
set_env CARGO_MAKE_TASK_BUILD_EXAMPLES_ARGS "${args_examples}"
# * rebuild for 'utils' target
args_utils_list = split "${args}" ";"
for arg in "${args_utils_list}"
if not is_empty "${arg}"
if not starts_with "${arg}" "uu_"
arg = set "uu_${arg}"
end_if
args_utils = set "${args_utils} -p${arg}"
end_if
end
args_utils = trim "${args_utils}"
set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args_utils}"
'''
]
### tasks
[tasks.default]
description = "## *DEFAULT* Build (debug-mode) and test project"
category = "[project]"
dependencies = [
"action-build-debug",
"test-terse",
]
##
[tasks.build]
description = "## Build (release-mode) project"
category = "[project]"
dependencies = [
"core::pre-build",
"action-build-release",
"core::post-build",
]
[tasks.build-debug]
description = "## Build (debug-mode) project"
category = "[project]"
dependencies = [
"action-build-debug",
]
[tasks.build-examples]
description = "## Build (release-mode) project example(s); usage: `cargo make (build-examples | examples) [EXAMPLE]...`"
category = "[project]"
dependencies = [
"core::pre-build",
"action-build-examples",
"core::post-build",
]
[tasks.build-features]
description = "## Build (with features; release-mode) project; usage: `cargo make (build-features | features) FEATURE...`"
category = "[project]"
dependencies = [
"core::pre-build",
"action-build-features",
"core::post-build",
]
[tasks.build-release]
alias = "build"
[tasks.debug]
alias = "build-debug"
[tasks.example]
description = "hidden singular-form alias for 'examples'"
category = "[project]"
dependencies = [
"examples",
]
[tasks.examples]
alias = "build-examples"
[tasks.features]
alias = "build-features"
[tasks.format]
description = "## Format code files (with `cargo fmt`; includes tests)"
category = "[project]"
dependencies = [
"action-format",
"action-format-tests",
]
[tasks.help]
description = "## Display help"
category = "[project]"
dependencies = [
"action-display-help",
]
[tasks.install]
description = "## Install project binary (to $HOME/.cargo/bin)"
category = "[project]"
command = "cargo"
args = ["install", "--path", "."]
[tasks.lint]
description = "## Display lint report"
category = "[project]"
dependencies = [
"action-clippy",
"action-fmt_report",
]
[tasks.release]
alias = "build"
[tasks.test]
description = "## Run project tests"
category = "[project]"
dependencies = [
"core::pre-test",
"core::test",
"core::post-test",
]
[tasks.test-terse]
description = "## Run project tests (with terse/summary output)"
category = "[project]"
dependencies = [
"core::pre-test",
"action-test_quiet",
"core::post-test",
]
[tasks.test-util]
description = "## Test (individual) utilities; usage: `cargo make (test-util | test-uutil) [UTIL_NAME...]`"
category = "[project]"
dependencies = [
"action-test-utils",
]
[tasks.test-utils]
description = "hidden plural-form alias for 'test-util'"
category = "[project]"
dependencies = [
"test-util",
]
[tasks.test-uutil]
description = "hidden alias for 'test-util'"
category = "[project]"
dependencies = [
"test-util",
]
[tasks.test-uutils]
description = "hidden alias for 'test-util'"
category = "[project]"
dependencies = [
"test-util",
]
[tasks.uninstall]
description = "## Remove project binary (from $HOME/.cargo/bin)"
category = "[project]"
command = "cargo"
args = ["uninstall"]
[tasks.util]
description = "## Build (individual; release-mode) utilities; usage: `cargo make (util | uutil) [UTIL_NAME...]`"
category = "[project]"
dependencies = [
"core::pre-build",
"action-determine-utils",
"action-build-utils",
"core::post-build",
]
[tasks.utils]
description = "hidden plural-form alias for 'util'"
category = "[project]"
dependencies = [
"util",
]
[tasks.uutil]
description = "hidden alias for 'util'"
category = "[project]"
dependencies = [
"util",
]
[tasks.uutils]
description = "hidden plural-form alias for 'util'"
category = "[project]"
dependencies = [
"util",
]
### actions
[tasks.action-build-release]
description = "`cargo build --release`"
command = "cargo"
args = ["build", "--release", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )" ]
[tasks.action-build-debug]
description = "`cargo build`"
command = "cargo"
args = ["build", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )" ]
[tasks.action-build-examples]
description = "`cargo build (--examples|(--example EXAMPLE)...)`"
command = "cargo"
args = ["build", "--release", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )", "${CARGO_MAKE_TASK_BUILD_EXAMPLES_ARGS}" ]
[tasks.action-build-features]
description = "`cargo build --release --features FEATURES`"
command = "cargo"
args = ["build", "--release", "--no-default-features", "--features", "${CARGO_MAKE_TASK_BUILD_FEATURES_ARGS}" ]
[tasks.action-build-utils]
description = "Build individual utilities"
dependencies = [
"action-determine-utils",
]
command = "cargo"
# args = ["build", "@@remove-empty(CARGO_MAKE_TASK_BUILD_UTILS_ARGS)" ]
args = ["build", "--release", "@@split(CARGO_MAKE_TASK_BUILD_UTILS_ARGS, )" ]
[tasks.action-clippy]
description = "`cargo clippy` lint report"
command = "cargo"
args = ["clippy", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.action-determine-utils]
script_runner = "@duckscript"
script = [
'''
package_options = get_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS
if is_empty "${package_options}"
show_utils = get_env CARGO_MAKE_VAR_SHOW_UTILS
features = get_env CARGO_MAKE_VAR_BUILD_TEST_FEATURES
if not is_empty "${features}"
result = exec "${show_utils}" --features "${features}"
else
result = exec "${show_utils}"
endif
set_env CARGO_MAKE_VAR_UTILS ${result.stdout}
utils = array %{result.stdout}
for util in ${utils}
if not is_empty "${util}"
if not starts_with "${util}" "uu_"
util = set "uu_${util}"
end_if
package_options = set "${package_options} -p${util}"
end_if
end
package_options = trim "${package_options}"
end_if
set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${package_options}"
'''
]
[tasks.action-determine-tests]
script_runner = "@duckscript"
script = [
'''
test_files = glob_array tests/**/*.rs
for file in ${test_files}
file = replace "${file}" "\\" "/"
if not is_empty ${file}
if is_empty "${tests}"
tests = set "${file}"
else
tests = set "${tests} ${file}"
end_if
end_if
end
set_env CARGO_MAKE_VAR_TESTS "${tests}"
'''
]
[tasks.action-format]
description = "`cargo fmt`"
command = "cargo"
args = ["fmt"]
[tasks.action-format-tests]
description = "`cargo fmt` tests"
dependencies = [
"action-determine-tests",
]
command = "cargo"
args = ["fmt", "--", "@@split(CARGO_MAKE_VAR_TESTS, )"]
[tasks.action-fmt]
alias = "action-format"
[tasks.action-fmt_report]
description = "`cargo fmt` lint report"
command = "cargo"
args = ["fmt", "--", "--check"]
[tasks.action-spellcheck-codespell]
description = "`codespell` spellcheck repository"
command = "codespell" # (from `pip install codespell`)
args = [".", "--skip=*/.git,./target,./tests/fixtures", "--ignore-words-list=mut,od"]
[tasks.action-test-utils]
description = "Build individual utilities"
dependencies = [
"action-determine-utils",
]
command = "cargo"
# args = ["build", "@@remove-empty(CARGO_MAKE_TASK_BUILD_UTILS_ARGS)" ]
args = ["test", "@@split(CARGO_MAKE_TASK_BUILD_UTILS_ARGS, )" ]
[tasks.action-test_quiet]
description = "Test (in `--quiet` mode)"
command = "cargo"
args = ["test", "--quiet", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.action-display-help]
script_runner = "@duckscript"
script = [
'''
echo ""
echo "usage: `cargo make TARGET [ARGS...]`"
echo ""
echo "TARGETs:"
echo ""
result = exec "cargo" make --list-all-steps
# set_env CARGO_MAKE_VAR_UTILS ${result.stdout}
# echo ${result.stdout}
lines = split ${result.stdout} "\n"
# echo ${lines}
for line in ${lines}
if not is_empty ${line}
if contains ${line} " - ##"
line_segments = split ${line} " - ##"
desc = array_pop ${line_segments}
desc = trim ${desc}
target = array_pop ${line_segments}
target = trim ${target}
l = length ${target}
r = range 0 18
spacing = set ""
for i in ${r}
if greater_than ${i} ${l}
spacing = set "${spacing} "
end_if
end
echo ${target}${spacing}${desc}
end_if
end_if
end
echo ""
'''
]