Rust 任务运行程序和构建工具。
Rust task runner and build tool.
The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.
A task is a command, script, rust code, or other sub tasks to execute.
Tasks can have dependencies which are also tasks that will be executed before the task itself.
With a simple toml based configuration file, you can define a multi platform build script that can run build, test, generate documentation, run bench tests, run security validations and more, executed by running a single command.
In order to install, just run the following command
cargo install --force cargo-make
This will install cargo-make in your ~/.cargo/bin.
Make sure to add ~/.cargo/bin directory to your PATH variable.
You will have two executables available: cargo-make and makers
See Cli Options section for full CLI instructions.
In order to install with minimal features (for example, no TLS support), run the following:
cargo install --no-default-features --force cargo-make
sudo pacman -S cargo-make
Binary releases are available in the github releases page.
The following binaries are available for each release:
When using cargo-make, all tasks are defined and configured via toml files.
Below are simple instructions to get you started off quickly.
In order to run a set of tasks, you first must define them in a toml file.
For example, if we would like to have a script which:
By default, cargo-make reads tasks from Makefile.toml if it exists.
We will create a Makefile.toml file as follows:
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
[tasks.clean]
command = "cargo"
args = ["clean"]
[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["clean"]
[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["clean"]
[tasks.my-flow]
dependencies = [
"format",
"build",
"test"
]
We would execute the flow with the following command:
cargo make my-flow
The output would look something like this:
…
We now created a build script that can run on any platform.
The tasks can be stored in any toml file. Invoke cargo-make with --makefile other-filename.toml
to start processing using other-filename.toml.
cargo-make can be invoked as a cargo plugin via cargo make command, or as a standalone executable via makers command.
Important Note: if you are running this example in a cargo workspace, you will need to add the following to the top of the file:
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
More on workspace support in the relevant sections in this document.
In many cases, certain tasks depend on other tasks.
For example you would like to format the code before running build and run the build before running tests.
Such flow can be defined as follows:
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["format"]
[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["build"]
When you run:
cargo make --makefile ./my_build.toml test
It will try to run test, see that it has dependencies and those have other depend
暂无开放 Issues,或尚未同步最近议题。