Cargo Profile 介绍

发布时间: 更新时间: 总字数:239 阅读时间:1m 作者: IP上海 分享 网址

Rust 支持使用 profile 自定义构建,Profile 是预定义的,可使用不同的配置,对代码编译拥有更多的控制

介绍

Profile 分类:

  • release profile:发布环境通过 cargo build --release 使用
  • dev profile:开发环境通过 cargo build 使用

支持自定义profile

Cargo.toml 中,添加 [profile.xxx] section,在里面覆盖默认配置的子集

[profile.dev]
opt-level = 1

[profile.release]
opt-level = 3

说明:

  • opt-level 指定优化程度,值 [0~3,s,z],越大编译时间越长
  • 更多参数配置参考:https://doc.rust-lang.org/stable/cargo/reference/profiles.html
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数