Announcing cargo-make task runner and build tool for rust


#1

Hi All, I have published a new task runner and build tool for rust named cargo-make.
I am fairly new to rust so when I started working with it I saw I am missing a way to quickly run a set of cargo commands and script commands
to ensure my project works well.
For example, running cargo fmt && cargo build && cargo test and so on…
I took some ideas from tools I am using a lot from other languages such as gruntjs and apache ant of having some sort of task runner with dependencies and created a new rust oriented, toml configuration based, cargo plugin.
Please check it out at: https://sagiegurari.github.io/cargo-make/


#2

Have you looked at https://github.com/casey/just ? How does yours compare?


#3

I did see it and they are very different.
just is very similar to make and I haven’t seen exactly what is the advantage of it over make.
cargo-make is a task runner which is rust aware and it is tightly coupled with rust and cargo to give rust projects added value.
for example,

  1. cargo-make knows to install missing crates that you need for your build process
  2. it give you, your crate info, rust compiler info and git for your build process for you to use
  3. predefined tasks and flows for rust developers, CI services and so on… you don’t really have to write a makefile.toml to use it
  4. the tasks are defined in a toml file which is a lot simpler to write and read.
  5. there is planned workspace support to give you some really cool features when using workspaces
    and lots more.

so… both got many features, but those features are very different.
cargo-make is specifically for rust projects and gives you a lot of quick and powerful tools.
just is more generalized make replacement.


#4

I just now found out about this and would like to say: holy cow, that’s a great README.

I haven’t quite understood how platform overrides work, are “windows”, “linux” and “mac” magic keys to the program?


#5

windows/linux/mac are determined by the cargo-make.
if you want to override some task only for windows you do

[tasks.mytask.windows]
my override stuff here

Same goes for mac and linux.


#6

Hm, have you considered hooking into the target triple instead, like cargo and xargo itself do?

For example, I can see quite some cases where tasks need to be changed based on the linux flavour you target, for example aarch64-linux-android is a linux, but one where I can see quite some additional tasks coming out of that I wouldn’t use in desktop linux. Also, it may help for cross-compile scenarios.


#7

That’s a good idea. I’ll think of something to make it easy to use.


#8

So I have been thinking about your suggestion and to not over complicate things for users, the overrides are still on top os level (windows/mac/linux) to keep it simple.
But now I also provide env vars that will help you in your task script to see what OS you are working on (target_arch, target_env, target_os, target_pointer_width and target_vendor cfg values are now defined as env vars).
So you can write something like this for example:

[tasks.mytask]
script = [
    "if [ "$CARGO_MAKE_RUST_TARGET_ARCH" = "arm" ]; then",
    "echo \"Doing some arm specific stuff....\"",
    "fi"
]

You can also override on OS level and do it only for linux

[tasks.mytask.linux]
script = [
    "if [ "$CARGO_MAKE_RUST_TARGET_ARCH" = "arm" ]; then",
    "echo \"Doing some arm specific stuff....\"",
    "fi"
]

[tasks.mytask]
script = [
    "echo  \"I am on windows or mac!!!! \""
]