cargo-make rust 任务执行以及构建工具

再学习nakago 框架的时候发现其使用了cargo-make 这个工具,但是很方便,类似make 的构建模式

包含的特性

依赖管理,别名支持,支持workspace

简单使用

  • 安装
cargo install --force cargo-make
  • 参考使用
    创建一个cargo 项目
 
cargo new appdemo

Makefile.toml 文件

[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"
]

效果

  • 运行
cargo make my-flow

效果

说明

对于golang 开发有一些实践是基于make cargo-make 工具可以让我们基于make 类似的模式进行开发管理,很值得使用下

参考资料

https://sagiegurari.github.io/cargo-make/
https://github.com/sagiegurari/cargo-make
https://github.com/bkonkle/nakago-simple-template/blob/main/template/Makefile.toml
https://sagiegurari.github.io/cargo-make/#usage-workspace-support

posted on   荣锋亮  阅读(361)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-12-18 hydra snowflake 可选的olap postgres 数据库
2021-12-18 k8s集群部署几种方式
2021-12-18 webservice 动态调用使用技巧
2020-12-18 mojolicious perl web 框架简单试用
2020-12-18 explain.depesz.com 在线pg查询计划查看工具
2020-12-18 Vertically Scaling PostgreSQL
2020-12-18 gitpod 强大的快速提供开发环境的工具

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示