百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cargo-make

> DevOps
开源

Rust 任务运行程序和构建工具。

2.9K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Rust 任务运行程序和构建工具。

cargo-make

Rust task runner and build tool.

  • Overview
  • Installation
    • Arch Linux
    • Binary Release
  • Usage
    • Simple Example
    • Tasks, Dependencies, and Aliases
    • Commands, Scripts, and Sub Tasks
      • Sub Task
      • Command
      • Script
      • Duckscript
      • Rust Code
      • Cross Platform Shell
      • Other Programming Languages
      • Shebang Support
    • Default Tasks and Extending
      • Extending External Makefiles
      • Automatically Extend Workspace Makefile
      • Load Scripts
      • Predefined Makefiles
      • The Default Task
    • Extending Tasks
      • Task Override
      • Platform Override
      • Extend Attribute
    • Environment Variables
      • Declaration
      • Global Configuration
      • Task
      • Command Line
      • Env File
      • Env Setup Scripts
      • Loading Order
      • Note about Ordering
      • Global
    • Setting Up Working Directory
    • Ignoring Errors
    • Conditions
      • Criteria
      • Scripts
      • And/Or/Group Or
      • Combining Conditions and Sub Tasks
      • Running Tasks Only If Sources Changed
    • Installing Dependencies
      • Cargo Plugins
      • Crates
      • Rustup Components
      • Native Dependencies
      • Defining Version
      • Global Lock Of Versions
      • Alternate Cargo Install Commands
      • Installation Priorities
      • Multiple Installations
    • Workspace Support
      • Disabling Workspace Support
      • Composite Flow
      • Profiles
      • Skipping/Including Specific Members
      • Workspace Emulation
    • Toolchain
    • Init and End tasks
    • Catching Errors
    • Cargo Alias Tasks
    • Profiles
      • Environment Variables
      • Conditions
      • Built In Profiles
    • Private Tasks
    • Deprecated Tasks
    • Watch
      • Running Multiple Blocking Watches
    • Functions
      • Split
      • GetAt
      • Remove Empty
      • Trim
      • Decode
    • Continuous Integration
      • Github Actions
      • Travis
      • AppVeyor
      • GitLab
      • CircleCI
      • Azure Pipelines
      • drone.io
      • Cirrus CI
    • Predefined Flows
      • Coverage
      • Full List
      • Disabling Predefined Tasks/Flows
      • Modifying Predefined Tasks/Flows
    • Minimal Version
    • Performance Tuning
    • Command Groups (Subcommands)
    • Diff Changes
    • Unstable Features
    • CLI Options
    • Plugins
      • Defining Plugins
      • Plugin SDK
      • Plugin Example - Docker Integration
      • Plugin Example - Run workspace members in parallel
      • Plugin Example - load Env From Rust Script
      • Plugin Example - Adding Simpler Windows Powershell Support
    • Shell Completion
      • Bash
      • zsh
      • Zsh Task Completion
      • Fig / Amazon CodeWhisperer for command line
    • Global Configuration
  • Makefile Definition
  • Task Naming Conventions
  • Articles
    • Introduction and Basics
    • Extending Tasks, Platform Overrides, and Aliases
    • Environment Variables, Conditions, Sub Tasks, and Mixing
    • Workspace Support, Init/End Tasks, and Makefiles
    • Predefined Tasks, CI Support, and Conventions
  • Badge
  • Roadmap
  • Editor Support
    • vim
    • vs-code
  • Contributing
  • Release History
  • License

Overview

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.

Installation

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

  • cargo-make - This is a cargo plugin invoked using cargo make ...
  • makers - A standalone executable which provides same features and cli arguments as cargo-make, but is invoked directly and not as a cargo plugin.

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

Arch Linux

sudo pacman -S cargo-make

Binary Release

Binary releases are available in the github releases page.
The following binaries are available for each release:

  • x86_64-unknown-linux-gnu
  • x86_64-unknown-linux-musl
  • x86_64-apple-darwin
  • x86_64-pc-windows-msvc
  • aarch64-apple-darwin

Usage

When using cargo-make, all tasks are defined and configured via toml files.
Below are simple instructions to get you started off quickly.

Simple Example

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:

  • Formats the code
  • Cleans old target directory
  • Runs build
  • Runs tests

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.

Tasks, Dependencies, and Aliases

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

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustappveyorazure-pipelinesbuildbuild-automation

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理