Building a Rust package#
We're using rattler-build to build a Rust package for the cargo-edit utility.
This utility manages Cargo dependencies from the command line.
recipe.yaml
context:
version: "0.11.9"
package:
name: cargo-edit
version: ${{ version }}
source:
url: https://github.com/killercup/cargo-edit/archive/refs/tags/v${{ version }}.tar.gz
sha256: 46670295e2323fc2f826750cdcfb2692fbdbea87122fe530a07c50c8dba1d3d7
build:
script:
- cargo-bundle-licenses --format yaml --output ${SRC_DIR}/THIRDPARTY.yml # !(1)
- $BUILD_PREFIX/bin/cargo install --locked --bins --root ${PREFIX} --path .
requirements:
build:
- ${{ compiler('rust') }}
- cargo-bundle-licenses
tests:
- script:
- cargo-upgrade --help # !(2)
about:
homepage: https://github.com/killercup/cargo-edit
license: MIT
license_file:
- LICENSE
- THIRDPARTY.yml
description: "A utility for managing cargo dependencies from the command line."
summary: "A utility for managing cargo dependencies from the command line."
Note
The ${{ compiler(...) }} functions are very useful in the context of cross-compilation.
When the function is evaluated it will insert the correct compiler (as selected with the variant config) as well the target_platform.
The "rendered" compiler will look like rust_linux-64 when you are targeting the linux-64 platform.
You can read more about this in the cross-compilation section.
- The
cargo-bundle-licensesutility is used to bundle all the licenses of the dependencies into aTHIRDPARTY.ymlfile. This file is then included in the package. You should always include this file in your package when you are redistributing it. - Running scripts in
bashorcmd.exeto test the package build well, expects an exit code of0to pass the test.
To build this recipe, simply run: