From d5368d94915e6e8922ce1bf0d021d232abe3f64d Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Tue, 28 Apr 2020 13:55:36 -0500 Subject: [PATCH 1/7] maint/build ~ add 'uutil' task as alias to 'util' for least surprise --- Makefile.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index f2d063720..b96c624bb 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,5 +1,6 @@ # spell-checker:ignore (cargo-make) duckscript macos # spell-checker:ignore (rust) clippy +# spell-checker:ignore (uutils) uutil uutils [config] min_version = "0.26.2" @@ -155,7 +156,7 @@ dependencies = [ alias = "utils" [tasks.utils] -description = "Build (individual) utilities; usage: `cargo make (util | utils) [UTIL_NAME..]`" +description = "Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME..]`" category = "[project]" dependencies = [ "core::pre-build", @@ -164,6 +165,12 @@ dependencies = [ "core::post-build", ] +[tasks.uutil] +alias = "utils" + +[tasks.uutils] +alias = "utils" + ### actions [tasks.action-build] From 969964aade792670bf39a2f8f367e2ac56993bcf Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 29 Apr 2020 01:06:04 -0500 Subject: [PATCH 2/7] maint/build ~ add `cargo make` install/uninstall targets --- Makefile.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile.toml b/Makefile.toml index b96c624bb..1a696a6b6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -121,6 +121,12 @@ category = "[project]" command = "cargo" args = [ "make", "--list-all-steps" ] +[tasks.install] +description = "Install project binary (to \"$HOME/.cargo/bin\")" +category = "[project]" +command = "cargo" +args = ["install", "--path", "."] + [tasks.lint] description = "Lint report" category = "[project]" @@ -152,6 +158,12 @@ dependencies = [ "core::post-test", ] +[tasks.uninstall] +description = "Remove project binary (from \"$HOME/.cargo/bin\")" +category = "[project]" +command = "cargo" +args = ["uninstall"] + [tasks.util] alias = "utils" From f16e2261fc6a13bb5396291e62f735124fc71acf Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 2 May 2020 00:12:29 -0500 Subject: [PATCH 3/7] maint/build ~ improve `cargo make format` to include test formatting --- Makefile.toml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 1a696a6b6..275fcd2e9 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -113,6 +113,8 @@ description = "Format" category = "[project]" dependencies = [ "action-format", + "action-determine-tests", + "action-format-tests", ] [tasks.help] @@ -230,15 +232,34 @@ 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} + if is_empty "${tests}" + tests = set "${file}" + else + tests = set "${tests} ${file}" + end_if +end +set_env CARGO_MAKE_VAR_TESTS "${tests}" +''' +] + [tasks.action-format] description = "`cargo fmt`" command = "cargo" args = ["fmt"] -[tasks.action-fmt] -description = "`cargo fmt`" +[tasks.action-format-tests] +description = "`cargo fmt` tests" command = "cargo" -args = ["fmt"] +args = ["fmt", "--", "@@split(CARGO_MAKE_VAR_TESTS, )"] + +[tasks.action-fmt] +alias = "action-format" [tasks.action-fmt_report] description = "`cargo fmt` lint report" From 39cea3a15992e3d27454e0bc38aef0561a11b35a Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 2 May 2020 12:38:25 -0500 Subject: [PATCH 4/7] maint/build ~ add 'action-spellcheck-codespell' `cargo-make` target; prelim to a 'spellcheck' target --- Makefile.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.toml b/Makefile.toml index 275fcd2e9..9ab3961d1 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -266,6 +266,11 @@ 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_quiet] description = "Test (in `--quiet` mode)" command = "cargo" From d7b6626f70b2163e82cf95273fe39813aa817e4d Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 2 May 2020 12:36:27 -0500 Subject: [PATCH 5/7] maint/build ~ polish and add commentary for initialization workaround --- Makefile.toml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 9ab3961d1..2088989d2 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -5,18 +5,22 @@ [config] min_version = "0.26.2" default_to_workspace = false -init_task = "_init" +init_task = "_init_task" [config.modify_core_tasks] namespace = "core" ### initialization -[tasks._init] -private = true -run_task = "_init_" +### * note: the task executed from 'init_task' ignores dependencies; workaround is to run a secondary task via 'run_task' -[tasks._init_] +[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", From d752d9880b754a45ff3529d284772e7913f8fe1b Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 2 May 2020 17:37:02 -0500 Subject: [PATCH 6/7] maint/build ~ improve format and readability of (`cargo make`) 'help' target --- Makefile.toml | 67 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 2088989d2..959cbf8ec 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -84,7 +84,7 @@ set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args}" ### tasks [tasks.default] -description = "Build and Test" +description = "## *DEFAULT* Build and test project" category = "[project]" dependencies = [ "action-build-debug", @@ -92,7 +92,7 @@ dependencies = [ ] [tasks.build] -description = "Build" +description = "## Build project" category = "[project]" dependencies = [ "core::pre-build", @@ -101,7 +101,7 @@ dependencies = [ ] [tasks.build-features] -description = "Build (with features); usage: `cargo make (build-features | features) FEATURE..`" +description = "## Build (with features); usage: `cargo make (build-features | features) FEATURE...`" category = "[project]" dependencies = [ "core::pre-build", @@ -113,7 +113,7 @@ dependencies = [ alias = "build-features" [tasks.format] -description = "Format" +description = "## Format code files (with `cargo fmt`)" category = "[project]" dependencies = [ "action-format", @@ -122,19 +122,20 @@ dependencies = [ ] [tasks.help] -description = "Help" +description = "## Display help" category = "[project]" -command = "cargo" -args = [ "make", "--list-all-steps" ] +dependencies = [ + "action-display-help", +] [tasks.install] -description = "Install project binary (to \"$HOME/.cargo/bin\")" +description = "## Install project binary (to $HOME/.cargo/bin)" category = "[project]" command = "cargo" args = ["install", "--path", "."] [tasks.lint] -description = "Lint report" +description = "## Display lint report" category = "[project]" dependencies = [ "action-clippy", @@ -143,11 +144,9 @@ dependencies = [ [tasks.release] alias = "build" -description = "Build" -category = "[project]" [tasks.test] -description = "Test" +description = "## Run project tests" category = "[project]" dependencies = [ "core::pre-test", @@ -156,7 +155,7 @@ dependencies = [ ] [tasks.test-terse] -description = "Test (with terse/summary output)" +description = "## Run project tests (with terse/summary output)" category = "[project]" dependencies = [ "core::pre-test", @@ -165,7 +164,7 @@ dependencies = [ ] [tasks.uninstall] -description = "Remove project binary (from \"$HOME/.cargo/bin\")" +description = "## Remove project binary (from $HOME/.cargo/bin)" category = "[project]" command = "cargo" args = ["uninstall"] @@ -174,7 +173,7 @@ args = ["uninstall"] alias = "utils" [tasks.utils] -description = "Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME..]`" +description = "## Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME...]`" category = "[project]" dependencies = [ "core::pre-build", @@ -279,3 +278,41 @@ args = [".", "--skip=*/.git,./target,./tests/fixtures", "--ignore-words-list=mut 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 20 + 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 "" +''' +] From 78d4bb42e97a0b1218398f1a9fadb9202400cadc Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 3 May 2020 10:41:52 -0500 Subject: [PATCH 7/7] maint/build ~ add 'release' and 'debug' mode notations to tasks and help --- Makefile.toml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 959cbf8ec..00345410b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -84,24 +84,33 @@ set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args}" ### tasks [tasks.default] -description = "## *DEFAULT* Build and test project" +description = "## *DEFAULT* Build (debug-mode) and test project" category = "[project]" dependencies = [ "action-build-debug", "test-terse", ] +## + [tasks.build] -description = "## Build project" +description = "## Build (release-mode) project" category = "[project]" dependencies = [ "core::pre-build", - "action-build", + "action-build-release", "core::post-build", ] +[tasks.build-debug] +description = "## Build (debug-mode) project" +category = "[project]" +dependencies = [ + "action-build-debug", +] + [tasks.build-features] -description = "## Build (with features); usage: `cargo make (build-features | features) FEATURE...`" +description = "## Build (with features; release-mode) project; usage: `cargo make (build-features | features) FEATURE...`" category = "[project]" dependencies = [ "core::pre-build", @@ -109,6 +118,9 @@ dependencies = [ "core::post-build", ] +[tasks.debug] +alias = "build-debug" + [tasks.features] alias = "build-features" @@ -173,7 +185,7 @@ args = ["uninstall"] alias = "utils" [tasks.utils] -description = "## Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME...]`" +description = "## Build (individual; release-mode) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME...]`" category = "[project]" dependencies = [ "core::pre-build", @@ -190,7 +202,7 @@ alias = "utils" ### actions -[tasks.action-build] +[tasks.action-build-release] description = "`cargo build --release`" command = "cargo" args = ["build", "--release", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )" ]