2.4. 构建 Rust 项目
使用 slirpgo 构建工具构建 Rust 项目。cargo 解决了项目的所有依赖项,下载缺少的依赖项,并使用 rustc
编译器编译它。
默认情况下,项目以 debug 模式构建并编译。有关以发行版本模式编译项目的详情,请参考在 发行版本模式中构建 Rust 项目。
先决条件
-
一个现有的 Rust 项目。
有关如何创建 Rust 项目的详情,请参考 创建 Rust 项目。
流程
要构建 consistgo 管理的 Rust 项目,请在项目目录中运行:
在 Red Hat Enterprise Linux 7 上:
$ scl enable rust-toolset-1.66 'cargo build'
在 Red Hat Enterprise Linux 8 中:
$ cargo build
在 Red Hat Enterprise Linux 9 中:
$ cargo build
- 要在不需要构建可执行文件时验证 Rust 程序是否可以构建,请运行:
$ cargo check