From 94f25b87247d3e5c8ef94a52eea867f2bac04d77 Mon Sep 17 00:00:00 2001 From: Valentine Valyaeff Date: Fri, 20 Sep 2019 18:30:35 +0300 Subject: [PATCH] First public release --- Cargo.lock | 112 +++++++++--------- Cargo.toml | 5 +- Justfile | 14 ++- README.md | 28 ++++- README.tpl | 3 +- config/Cargo.toml | 3 +- rust-toolchain | 2 +- src/bmp.rs | 13 +- src/cli.rs | 3 + src/device.rs | 22 ++++ src/lib.rs | 26 +++- src/new.rs | 70 +++++++---- src/templates/layout.ld.hbs | 2 +- src/templates/mod.rs | 35 ++++-- src/templates/new/Cargo.toml.hbs | 10 +- src/templates/new/Drone.toml.hbs | 4 +- src/templates/new/Justfile.hbs | 1 + src/templates/new/rust-toolchain.hbs | 2 +- .../new/src/{main.rs.hbs => bin.rs.hbs} | 8 +- src/templates/new/src/lib.rs.hbs | 2 +- src/templates/new/src/tasks/mod.rs.hbs | 5 + .../{thr/trunk.rs.hbs => tasks/root.rs.hbs} | 10 +- .../new/src/{thr/mod.rs.hbs => thr.rs.hbs} | 4 +- src/utils.rs | 13 +- 24 files changed, 268 insertions(+), 129 deletions(-) rename src/templates/new/src/{main.rs.hbs => bin.rs.hbs} (78%) create mode 100644 src/templates/new/src/tasks/mod.rs.hbs rename src/templates/new/src/{thr/trunk.rs.hbs => tasks/root.rs.hbs} (51%) rename src/templates/new/src/{thr/mod.rs.hbs => thr.rs.hbs} (88%) diff --git a/Cargo.lock b/Cargo.lock index 215bbea..43eedf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.35" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -41,7 +41,7 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.41" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -122,17 +122,17 @@ dependencies = [ [[package]] name = "drone" -version = "0.9.0" +version = "0.10.0" dependencies = [ - "drone-config 0.9.0", + "drone-config 0.10.0", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "exitfailure 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "handlebars 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "handlebars 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -140,10 +140,10 @@ dependencies = [ [[package]] name = "drone-config" -version = "0.9.0" +version = "0.10.0" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -153,9 +153,9 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -172,7 +172,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -202,27 +202,25 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "handlebars" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -232,7 +230,7 @@ name = "hashbrown" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -245,7 +243,7 @@ dependencies = [ [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -313,7 +311,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest_meta 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -338,7 +336,7 @@ name = "proc-macro-error" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -353,7 +351,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -377,15 +375,15 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -406,7 +404,7 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -424,18 +422,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -466,18 +464,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.99" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.99" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -489,7 +487,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -510,21 +508,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -544,7 +542,7 @@ name = "syn" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -567,7 +565,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -602,7 +600,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -652,7 +650,7 @@ dependencies = [ [[package]] name = "wasi" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -695,7 +693,7 @@ dependencies = [ "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" +"checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" @@ -703,7 +701,7 @@ dependencies = [ "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" +"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" @@ -713,11 +711,11 @@ dependencies = [ "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" -"checksum handlebars 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "df044dd42cdb7e32f28557b661406fc0f2494be75199779998810dbc35030e0d" +"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +"checksum handlebars 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "91ef1ac30f2eaaa2b835fce73c57091cb6b9fc62b7eef285efbf980b0f20001b" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" @@ -732,28 +730,28 @@ dependencies = [ "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "175a40b9cf564ce9bf050654633dbf339978706b8ead1a907bb970b63185dd95" +"checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" -"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" +"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" -"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" -"checksum serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "cb4dc18c61206b08dc98216c98faa0232f4337e1e1b8574551d5bad29ea1b425" +"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" +"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48399718b3ad695558b979b08a9056a5272ec573cd3070f5ca34165bd4a5bf35" -"checksum structopt-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2558075232402034384db060831349fb2d1303479593177cc84c25febbebbc6d" +"checksum structopt 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe8d3289b63ef2f196d89e7701f986583c0895e764b78f052a55b9b5d34d84a" +"checksum structopt-derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f3add731f5b4fb85931d362a3c92deb1ad7113649a8d51701fb257673705f122" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" @@ -770,7 +768,7 @@ dependencies = [ "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" -"checksum wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd5442abcac6525a045cc8c795aedb60da7a2e5e89c7bf18a0d5357849bb23c7" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" diff --git a/Cargo.toml b/Cargo.toml index d9552bc..833cd34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,12 @@ members = ["config"] [package] name = "drone" -version = "0.9.0" +version = "0.10.0" authors = ["Valentine Valyaeff "] edition = "2018" default-run = "drone" repository = "https://github.com/drone-os/drone" +homepage = "https://www.drone-os.com/" readme = "README.md" license = "MIT OR Apache-2.0" keywords = [ @@ -32,7 +33,7 @@ CLI utility for Drone, an Embedded Operating System. maintenance = { status = "actively-developed" } [dependencies.drone-config] -version = "=0.9.0" +version = "=0.10.0" path = "config" [dependencies] diff --git a/Justfile b/Justfile index cf91b1c..e219b52 100644 --- a/Justfile +++ b/Justfile @@ -25,15 +25,23 @@ doc-open: doc test: cargo test +# Install the binaries +install: + cargo install --path . --debug --force + # Update README.md readme: cargo readme -o README.md -# Install the binaries -install: - cargo install --path . --debug --force +# Bump crate versions +version-bump version: + sed -i '/\[.*\]/h;/version = ".*"/{x;s/\[package\]/version = "{{version}}"/;t;x}' \ + Cargo.toml config/Cargo.toml + sed -i '/\[.*\]/h;/version = "=.*"/{x;s/\[.*drone-.*\]/version = "={{version}}"/;t;x}' \ + Cargo.toml # Publish to crates.io publish: cd config && cargo publish + sleep 5 cargo publish diff --git a/README.md b/README.md index 2aeec79..6f99022 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,35 @@ -[![Crates.io](https://img.shields.io/crates/v/drone.svg)](https://crates.io/crates/drone) +[![crates.io](https://img.shields.io/crates/v/drone.svg)](https://crates.io/crates/drone) +![maintenance](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg) # drone CLI utility for Drone, an Embedded Operating System. +## Documentation + +Refer to the [Drone Book](https://book.drone-os.com/) for documentation. + +## Usage + +The program requires Nightly channel of Rust. Make sure you have it +installed: + +```shell +$ rustup toolchain install nightly +``` + +Install the latest version from crates.io: + +```shell +$ cargo +nightly install drone +``` + +Check the built-in help: + +```shell +$ drone help +``` + ## License Licensed under either of diff --git a/README.tpl b/README.tpl index 4af0a00..488edb2 100644 --- a/README.tpl +++ b/README.tpl @@ -1,4 +1,5 @@ -[![Crates.io](https://img.shields.io/crates/v/{{crate}}.svg)](https://crates.io/crates/{{crate}}) +[![crates.io](https://img.shields.io/crates/v/{{crate}}.svg)](https://crates.io/crates/{{crate}}) +![maintenance](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg) # {{crate}} diff --git a/config/Cargo.toml b/config/Cargo.toml index a97394b..fa3b1d0 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -1,9 +1,10 @@ [package] name = "drone-config" -version = "0.9.0" +version = "0.10.0" authors = ["Valentine Valyaeff "] edition = "2018" repository = "https://github.com/drone-os/drone" +homepage = "https://www.drone-os.com/" license = "MIT OR Apache-2.0" description = """ Configuration for Drone, an Embedded Operating System. diff --git a/rust-toolchain b/rust-toolchain index 9106e22..e608779 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2019-08-26 +nightly-2019-09-13 diff --git a/src/bmp.rs b/src/bmp.rs index 601273f..9fe6695 100644 --- a/src/bmp.rs +++ b/src/bmp.rs @@ -6,7 +6,7 @@ use crate::{ utils::{mask_signals, run_command, temp_dir}, }; use drone_config as config; -use failure::Error; +use failure::{format_err, Error}; use std::{ ffi::CString, fs::OpenOptions, @@ -101,11 +101,14 @@ impl BmpItmCmd { let dir = tempdir_in(temp_dir())?; let pipe = make_fifo(&dir)?; let script = registry.bmp_itm(&config, ports, *reset, &pipe)?; - let mut gdb = Command::new(&config.bmp()?.gdb_command); + let gdb_command = &config.bmp()?.gdb_command; + let mut gdb = Command::new(gdb_command); gdb.arg("--nx"); gdb.arg("--batch"); gdb.arg("--command").arg(script.path()); - let mut gdb = gdb.spawn()?; + let mut gdb = gdb + .spawn() + .map_err(|err| format_err!("`{}` command failed to start: {}", gdb_command, err))?; let mut packet = [0]; OpenOptions::new() @@ -117,7 +120,9 @@ impl BmpItmCmd { let mut itmsink = Command::new("itmsink"); itmsink.arg("--input").arg(&config.bmp()?.uart_endpoint); itmsink.args(itmsink_args); - let mut itmsink = itmsink.spawn()?; + let mut itmsink = itmsink + .spawn() + .map_err(|err| format_err!("`itmsink` command failed to start: {}", err))?; shell.set_color(ColorSpec::new().set_bold(true).set_fg(Some(Color::Cyan)))?; writeln!(shell)?; diff --git a/src/cli.rs b/src/cli.rs index 26ca31a..5daf0c7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -52,6 +52,9 @@ pub struct NewCmd { /// Set the resulting package name, defaults to the directory name #[structopt(long)] pub name: Option, + /// Toolchain name, such as 'nightly' or 'nightly-2019-09-05' + #[structopt(long, default_value = "nightly")] + pub toolchain: String, } #[derive(Debug, StructOpt)] diff --git a/src/device.rs b/src/device.rs index 1c82b7d..6c0e399 100644 --- a/src/device.rs +++ b/src/device.rs @@ -215,4 +215,26 @@ impl Device { | Self::Stm32L4S9 => 0x2000_0000, } } + + /// Returns a list of features for the `drone-stm32-map` dependency. + pub fn drone_stm32_map_features(&self) -> &[&str] { + match self { + Self::Stm32F100 + | Self::Stm32F101 + | Self::Stm32F102 + | Self::Stm32F103 + | Self::Stm32F107 => &[], + Self::Stm32L4X1 + | Self::Stm32L4X2 + | Self::Stm32L4X3 + | Self::Stm32L4X5 + | Self::Stm32L4X6 + | Self::Stm32L4R5 + | Self::Stm32L4R7 + | Self::Stm32L4R9 + | Self::Stm32L4S5 + | Self::Stm32L4S7 + | Self::Stm32L4S9 => &["fpu"], + } + } } diff --git a/src/lib.rs b/src/lib.rs index 19f21c6..1bbb978 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,29 @@ //! CLI utility for Drone, an Embedded Operating System. +//! +//! # Documentation +//! +//! Refer to the [Drone Book](https://book.drone-os.com/) for documentation. +//! +//! # Usage +//! +//! The program requires Nightly channel of Rust. Make sure you have it +//! installed: +//! +//! ```shell +//! $ rustup toolchain install nightly +//! ``` +//! +//! Install the latest version from crates.io: +//! +//! ```shell +//! $ cargo +nightly install drone +//! ``` +//! +//! Check the built-in help: +//! +//! ```shell +//! $ drone help +//! ``` #![feature(generator_trait)] #![feature(generators)] @@ -10,7 +35,6 @@ clippy::cast_possible_truncation, clippy::cast_precision_loss, clippy::cast_sign_loss, - clippy::module_name_repetitions, clippy::similar_names )] diff --git a/src/new.rs b/src/new.rs index c293f92..2d8bfbc 100644 --- a/src/new.rs +++ b/src/new.rs @@ -8,7 +8,7 @@ use crate::{ }; use failure::{bail, format_err, Error}; use std::{ - fs::{create_dir, read_to_string, File, OpenOptions}, + fs::{create_dir, read_to_string, remove_file, File, OpenOptions}, io::Write, path::Path, }; @@ -23,6 +23,7 @@ impl NewCmd { flash_size, ram_size, name, + toolchain, } = self; let registry = Registry::new()?; let name = name.as_ref().map(String::as_str).map_or_else( @@ -49,15 +50,17 @@ impl NewCmd { .collect::(); mask_signals(); - cargo_new(path)?; - src_main_rs(path, &underscore_name, ®istry, shell)?; + cargo_new(path, &toolchain)?; + src_main_rs(path, shell)?; + src_bin_rs(path, &underscore_name, ®istry, shell)?; src_lib_rs(path, ®istry, shell)?; - src_thr_mod_rs(path, ®istry, shell)?; - src_thr_trunk_rs(path, ®istry, shell)?; + src_thr_rs(path, ®istry, shell)?; + src_tasks_mod_rs(path, ®istry, shell)?; + src_tasks_root_rs(path, ®istry, shell)?; cargo_toml(path, &name, &device, ®istry, shell)?; drone_toml(path, &device, *flash_size, *ram_size, ®istry, shell)?; justfile(path, &device, ®istry, shell)?; - rust_toolchain(path, ®istry, shell)?; + rust_toolchain(path, &toolchain, ®istry, shell)?; cargo_config(path, ®istry, shell)?; gitignore(path, ®istry, shell)?; @@ -65,22 +68,29 @@ impl NewCmd { } } -fn cargo_new(path: &Path) -> Result<(), Error> { - run_command(Path::new("cargo"), |cargo| { - cargo.arg("+nightly").arg("new").arg("--bin").arg(path); +fn cargo_new(path: &Path, toolchain: &str) -> Result<(), Error> { + run_command(Path::new("rustup"), |rustup| { + rustup.arg("run").arg(toolchain); + rustup.arg("cargo").arg("new").arg("--bin").arg(path); }) } -fn src_main_rs( +fn src_main_rs(path: &Path, shell: &mut StandardStream) -> Result<(), Error> { + let path = path.join("src/main.rs"); + remove_file(path)?; + print_removed(shell, "src/main.rs") +} + +fn src_bin_rs( path: &Path, name: &str, registry: &Registry, shell: &mut StandardStream, ) -> Result<(), Error> { - let path = path.join("src/main.rs"); + let path = path.join("src/bin.rs"); let mut file = File::create(&path)?; - file.write_all(registry.new_src_main_rs(name)?.as_bytes())?; - print_patched(shell, "src/main.rs") + file.write_all(registry.new_src_bin_rs(name)?.as_bytes())?; + print_created(shell, "src/bin.rs") } fn src_lib_rs(path: &Path, registry: &Registry, shell: &mut StandardStream) -> Result<(), Error> { @@ -90,28 +100,35 @@ fn src_lib_rs(path: &Path, registry: &Registry, shell: &mut StandardStream) -> R print_created(shell, "src/lib.rs") } -fn src_thr_mod_rs( +fn src_thr_rs(path: &Path, registry: &Registry, shell: &mut StandardStream) -> Result<(), Error> { + let path = path.join("src/thr.rs"); + let mut file = File::create(&path)?; + file.write_all(registry.new_src_thr_rs()?.as_bytes())?; + print_created(shell, "src/thr.rs") +} + +fn src_tasks_mod_rs( path: &Path, registry: &Registry, shell: &mut StandardStream, ) -> Result<(), Error> { - let path = path.join("src/thr"); + let path = path.join("src/tasks"); create_dir(&path)?; let path = path.join("mod.rs"); let mut file = File::create(&path)?; - file.write_all(registry.new_src_thr_mod_rs()?.as_bytes())?; - print_created(shell, "src/thr/mod.rs") + file.write_all(registry.new_src_tasks_mod_rs()?.as_bytes())?; + print_created(shell, "src/tasks/mod.rs") } -fn src_thr_trunk_rs( +fn src_tasks_root_rs( path: &Path, registry: &Registry, shell: &mut StandardStream, ) -> Result<(), Error> { - let path = path.join("src/thr/trunk.rs"); + let path = path.join("src/tasks/root.rs"); let mut file = File::create(&path)?; - file.write_all(registry.new_src_thr_trunk_rs()?.as_bytes())?; - print_created(shell, "src/thr/trunk.rs") + file.write_all(registry.new_src_tasks_root_rs()?.as_bytes())?; + print_created(shell, "src/tasks/root.rs") } fn cargo_toml( @@ -166,12 +183,13 @@ fn justfile( fn rust_toolchain( path: &Path, + toolchain: &str, registry: &Registry, shell: &mut StandardStream, ) -> Result<(), Error> { let path = path.join("rust-toolchain"); let mut file = File::create(&path)?; - file.write_all(registry.new_rust_toolchain()?.as_bytes())?; + file.write_all(registry.new_rust_toolchain(toolchain)?.as_bytes())?; print_created(shell, "rust-toolchain") } @@ -206,3 +224,11 @@ fn print_patched(shell: &mut StandardStream, message: &str) -> Result<(), Error> writeln!(shell, " {}", message)?; Ok(()) } + +fn print_removed(shell: &mut StandardStream, message: &str) -> Result<(), Error> { + shell.set_color(ColorSpec::new().set_bold(true).set_fg(Some(Color::Green)))?; + write!(shell, " Removed")?; + shell.reset()?; + writeln!(shell, " {}", message)?; + Ok(()) +} diff --git a/src/templates/layout.ld.hbs b/src/templates/layout.ld.hbs index 25011a8..0f0e2a0 100644 --- a/src/templates/layout.ld.hbs +++ b/src/templates/layout.ld.hbs @@ -41,7 +41,7 @@ SECTIONS .data ADDR(.bss) + SIZEOF(.bss) : { - DATA_CONST = LOADADDR(.data); + DATA_LOAD = LOADADDR(.data); DATA_START = .; *(.data.*); . = ALIGN(4); diff --git a/src/templates/mod.rs b/src/templates/mod.rs index 412cd58..3f83a19 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -29,10 +29,11 @@ impl Registry { } template!("layout.ld")?; - template!("new/src/main.rs")?; + template!("new/src/bin.rs")?; template!("new/src/lib.rs")?; - template!("new/src/thr/mod.rs")?; - template!("new/src/thr/trunk.rs")?; + template!("new/src/thr.rs")?; + template!("new/src/tasks/mod.rs")?; + template!("new/src/tasks/root.rs")?; template!("new/Cargo.toml")?; template!("new/Drone.toml")?; template!("new/Justfile")?; @@ -57,25 +58,34 @@ impl Registry { with_temp_file(|file| self.0.render_to_write("layout.ld", &data, file)) } - pub fn new_src_main_rs(&self, crate_name: &str) -> Result { + pub fn new_src_bin_rs(&self, crate_name: &str) -> Result { let data = json!({ "crate_name": crate_name }); - Ok(self.0.render("new/src/main.rs", &data)?) + Ok(self.0.render("new/src/bin.rs", &data)?) } pub fn new_src_lib_rs(&self) -> Result { Ok(self.0.render("new/src/lib.rs", &())?) } - pub fn new_src_thr_mod_rs(&self) -> Result { - Ok(self.0.render("new/src/thr/mod.rs", &())?) + pub fn new_src_thr_rs(&self) -> Result { + Ok(self.0.render("new/src/thr.rs", &())?) } - pub fn new_src_thr_trunk_rs(&self) -> Result { - Ok(self.0.render("new/src/thr/trunk.rs", &())?) + pub fn new_src_tasks_mod_rs(&self) -> Result { + Ok(self.0.render("new/src/tasks/mod.rs", &())?) + } + + pub fn new_src_tasks_root_rs(&self) -> Result { + Ok(self.0.render("new/src/tasks/root.rs", &())?) } pub fn new_cargo_toml(&self, device: &Device, crate_name: &str) -> Result { - let data = json!({ "device_ident": device.ident(), "crate_name": crate_name }); + let mut drone_stm32_map_features = vec![device.ident()]; + drone_stm32_map_features.extend_from_slice(device.drone_stm32_map_features()); + let data = json!({ + "crate_name": crate_name, + "drone-stm32-map-features": drone_stm32_map_features, + }); Ok(self.0.render("new/Cargo.toml", &data)?) } @@ -105,8 +115,9 @@ impl Registry { Ok(self.0.render("new/Justfile", &data)?) } - pub fn new_rust_toolchain(&self) -> Result { - Ok(self.0.render("new/rust-toolchain", &())?) + pub fn new_rust_toolchain(&self, toolchain: &str) -> Result { + let data = json!({ "toolchain": toolchain }); + Ok(self.0.render("new/rust-toolchain", &data)?) } pub fn new_cargo_config(&self) -> Result { diff --git a/src/templates/new/Cargo.toml.hbs b/src/templates/new/Cargo.toml.hbs index 1078b3f..7670b5f 100644 --- a/src/templates/new/Cargo.toml.hbs +++ b/src/templates/new/Cargo.toml.hbs @@ -1,6 +1,6 @@ [[bin]] name = "{{crate_name}}" -path = "src/main.rs" +path = "src/bin.rs" test = false doc = false @@ -10,10 +10,10 @@ std = ["drone-core/std", "drone-cortex-m/std", "futures-preview/std"] heaptrace = [] [dependencies] -core = { version = "0.9", package = "drone-async-await" } -drone-core = { version = "0.9" } -drone-cortex-m = { version = "0.9" } -drone-stm32-map = { version = "0.9", features = ["{{device_ident}}"] } +core = { version = "0.10.0", package = "libcore-drone" } +drone-core = { version = "0.10.0" } +drone-cortex-m = { version = "0.10.0" } +drone-stm32-map = { version = "0.10.0", features = [{{#each drone-stm32-map-features}}"{{this}}"{{#unless @last}}, {{/unless}}{{/each}}] } futures-preview = { version = "0.3.0-alpha", default-features = false } [profile.release] diff --git a/src/templates/new/Drone.toml.hbs b/src/templates/new/Drone.toml.hbs index 2d16cee..c6bdf2e 100644 --- a/src/templates/new/Drone.toml.hbs +++ b/src/templates/new/Drone.toml.hbs @@ -11,6 +11,6 @@ origin = {{addr device_ram_origin}} [bmp] device = "{{device_ident}}" gdb_command = "gdb-multiarch" -gdb_endpoint = "/dev/ttyACM0" -uart_endpoint = "/dev/ttyACM1" +gdb_endpoint = "/dev/ttyBmpGdb" +uart_endpoint = "/dev/ttyBmpTarg" uart_baudrate = 115200 diff --git a/src/templates/new/Justfile.hbs b/src/templates/new/Justfile.hbs index f54b30d..0bb1a0e 100644 --- a/src/templates/new/Justfile.hbs +++ b/src/templates/new/Justfile.hbs @@ -6,6 +6,7 @@ features := '' # Install dependencies deps: rustup target add \{{build_target}} + rustup component add rust-src rustup component add rustfmt rustup component add clippy rustup component add llvm-tools-preview diff --git a/src/templates/new/rust-toolchain.hbs b/src/templates/new/rust-toolchain.hbs index bf867e0..57f1793 100644 --- a/src/templates/new/rust-toolchain.hbs +++ b/src/templates/new/rust-toolchain.hbs @@ -1 +1 @@ -nightly +{{toolchain}} diff --git a/src/templates/new/src/main.rs.hbs b/src/templates/new/src/bin.rs.hbs similarity index 78% rename from src/templates/new/src/main.rs.hbs rename to src/templates/new/src/bin.rs.hbs index 61b8d2b..43c98f4 100644 --- a/src/templates/new/src/main.rs.hbs +++ b/src/templates/new/src/bin.rs.hbs @@ -5,7 +5,8 @@ use drone_core::{future, mem, token::Token}; use drone_cortex_m::processor; use {{crate_name}}::{ - thr::{trunk, Handlers, Thr, Vtable}, + tasks, + thr::{Handlers, Thr, Vtable}, Regs, }; @@ -17,9 +18,10 @@ pub static VTABLE: Vtable = Vtable::new(Handlers { reset }); #[no_mangle] #[naked] pub unsafe extern "C" fn reset() -> ! { - mem::init!(); + mem::bss_init(); + mem::data_init(); future::init::(); - trunk::handler(Regs::take()); + tasks::root(Regs::take()); loop { processor::wait_for_int(); } diff --git a/src/templates/new/src/lib.rs.hbs b/src/templates/new/src/lib.rs.hbs index 80e75f0..a235ffd 100644 --- a/src/templates/new/src/lib.rs.hbs +++ b/src/templates/new/src/lib.rs.hbs @@ -1,12 +1,12 @@ #![feature(allocator_api)] #![feature(const_fn)] -#![feature(generators)] #![feature(prelude_import)] #![feature(proc_macro_hygiene)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; +pub mod tasks; pub mod thr; #[prelude_import] diff --git a/src/templates/new/src/tasks/mod.rs.hbs b/src/templates/new/src/tasks/mod.rs.hbs new file mode 100644 index 0000000..0b7f48f --- /dev/null +++ b/src/templates/new/src/tasks/mod.rs.hbs @@ -0,0 +1,5 @@ +//! The tasks. + +pub mod root; + +pub use self::root::handler as root; diff --git a/src/templates/new/src/thr/trunk.rs.hbs b/src/templates/new/src/tasks/root.rs.hbs similarity index 51% rename from src/templates/new/src/thr/trunk.rs.hbs rename to src/templates/new/src/tasks/root.rs.hbs index f4e0e8a..4a7ed5a 100644 --- a/src/templates/new/src/thr/trunk.rs.hbs +++ b/src/templates/new/src/tasks/root.rs.hbs @@ -1,14 +1,14 @@ -//! The trunk thread. +//! The root task. -use crate::{thr::Thrs, Regs}; -use drone_cortex_m::{reg::prelude::*, thr, thr::prelude::*}; +use crate::{thr, thr::Thrs, Regs}; +use drone_cortex_m::{reg::prelude::*, thr::prelude::*}; -/// The trunk thread handler. +/// The root task handler. #[inline(never)] pub fn handler(reg: Regs) { let (thr, _) = thr::init!(reg, Thrs); - thr.hard_fault.add_fn(|| panic!("Hard Fault")); + thr.hard_fault.add_once(|| panic!("Hard Fault")); println!("Hello, world!"); diff --git a/src/templates/new/src/thr/mod.rs.hbs b/src/templates/new/src/thr.rs.hbs similarity index 88% rename from src/templates/new/src/thr/mod.rs.hbs rename to src/templates/new/src/thr.rs.hbs index 9f50d25..9635259 100644 --- a/src/templates/new/src/thr/mod.rs.hbs +++ b/src/templates/new/src/thr.rs.hbs @@ -1,9 +1,9 @@ //! The threads. -pub mod trunk; +pub use drone_cortex_m::thr::init; +pub use drone_stm32_map::thr::*; use drone_cortex_m::thr; -use drone_stm32_map::thr::*; thr::vtable! { use Thr; diff --git a/src/utils.rs b/src/utils.rs index b6b1c5e..6070993 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ //! Utility functions. -use failure::{bail, Error}; +use failure::{bail, format_err, Error}; use std::{ env, mem::MaybeUninit, @@ -28,10 +28,15 @@ pub fn search_rust_tool(tool: &str) -> Result { pub fn run_command(program: &Path, f: impl FnOnce(&mut Command)) -> Result<(), Error> { let mut command = Command::new(program); f(&mut command); - if !command.status()?.success() { - bail!("`{}` exited with error", program.display()); + match command.status() { + Ok(status) if status.success() => Ok(()), + Ok(_) => Err(format_err!("`{}` exited with error", program.display())), + Err(err) => Err(format_err!( + "`{}` command failed to start: {}", + program.display(), + err + )), } - Ok(()) } /// Returns the directory for temporary files.