Rust:- Build Using Cargo

Background

In Rust, one can build and target one of four profiles.

The available profiles are dev, release, test, and bench.

Cargo

We will use Rust’s Cargo tool to build.

Commands

  1. clean
  2. build
    • target
      • dev
      • release
      • test
      • bench

Clean

Outline

Removes previously built artifacts.

Syntax


cargo clean

Sample


cargo clean

Build

Syntax


cargo build

Sample – Development


cargo build -- profile dev

Output
Image
Textual
 

>cargo build --profile dev
   Compiling kjvonly v0.1.0 (R:\spirituality\christianity\scripture\bible\KJVOnly)
    Finished dev [unoptimized + debuginfo] target(s) in 0.60s

>

Sample – Release


cargo build -- profile release

Output
Image
Textual
 


>cargo build --profile release
   Compiling kjvonly v0.1.0 (R:\spirituality\christianity\scripture\bible\KJVOnly)
    Finished release [optimized] target(s) in 0.56s

>

Artifacts

Outline

  1. Artifacts
    • List

List

Dir

Syntax


dir

Sample

List executable files ( *.exe) from the target\debug and target\release folders.


dir /A-D target\debug\*.exe target\release\*.exe

Output

Image

Text


>dir /A-D target\debug\*.exe target\release\*.exe


 Directory of R:\spirituality\christianity\scripture\bible\KJVOnly\target\debug

04/17/2023  01:45 PM           198,656 kjvonly.exe
               1 File(s)        198,656 bytes

 Directory of R:\spirituality\christianity\scripture\bible\KJVOnly\target\release

04/17/2023  01:52 PM           167,936 kjvonly.exe
               1 File(s)        167,936 bytes
               0 Dir(s)  602,755,371,008 bytes free

>

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s