Rust编程语言入门之cargo、crates.io

打印 上一主题 下一主题

主题 897|帖子 897|积分 2691

cargo、crates.io

本章内容


  • 通过 release profile 来自定义构建
  • https://crates.io/上发布库
  • 通过 workspaces 组织大工程
  • https://crates.io/来安装库
  • 使用自定义命令扩展 cargo
一、通过 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] 区域,在里面覆盖默认配置的子集

  1. [package]
  2. name = "closure"
  3. version = "0.1.0"
  4. edition = "2021"
  5. # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  6. [dependencies]
  7. [profile.dev]
  8. opt-level = 1
  9. [profile.release]
  10. opt-level = 3
复制代码
执行
[code]closure on  master [?] is
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

风雨同行

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表