User:Jelly/Rust package guidelines

From ArchWiki

This document covers standards and guidelines on writing PKGBUILDs for Rust.

General guidelines

Package naming

For Rust binary's use only the program name.

Note: The package name should be entirely lowercase.

Building

Building a rust package.

 build() {
   cargo build --release --locked
 }

where:

  • --release tells cargo to compile a release build
  • --locked tells cargo to adhere the Cargo.lock file and prevent it from updating dependencies which is important for reproducible builds.

Check

Most Rust projects provide a simple way to run the testsuite.

 check() {
   cargo test --release --locked
 }

Package

Rust builds binaries in target/release and can simply be installed to /usr/bin.

Note: Some packages should install more files such as a man page.
 package() {
   install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
 }