cargo、crates.io
本章内容
一、通过 release profile 来自定义构建
release profile (发布配置)
- release profile:
- 是预定义的
- 可自定义:可使用不同的配置,对代码编译拥有更多的控制
- 每个 profile 的配置都独立于其它的 profile
- cargo 主要的两个 profile:
- dev profile:适用于开发,cargo build
- release profile:适用于发布,cargo build --release
自定义 profile
- 针对每个 profile,Cargo 都提供了默认的配置
- 如果想自定义 xxxx profile 的配置:
- 可以在 Cargo.toml 里添加 [profile.xxxx] 区域,在里面覆盖默认配置的子集
- [package]
- name = "closure"
- version = "0.1.0"
- edition = "2021"
- # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
- [dependencies]
- [profile.dev]
- opt-level = 1
- [profile.release]
- opt-level = 3
复制代码 执行
[code]closure on master [?] is
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |