Rust package guidelines

From ArchWiki
Revision as of 22:00, 14 April 2019 by Doronbehar (talk | contribs) (→‎Package: add now required `--path` argument for cargo install)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Package creation guidelines

32-bitCLRCrossEclipseElectronFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustVCSWebWine

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

General guidelines

Package naming

For Rust binaries 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.

 package() {
   install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
 }

Some packages should install more files such as a man page, so in that case it would be better to use cargo:

 package() {
   cargo install --root "${pkgdir}"/usr --root "${srcdir}/${pkgname}-${pkgver}"
 }