void-packages/common/build-style/cargo.sh
Johannes 3aa797cb3a build-style cargo: move cargo config from wrksrc to home
since cargo 0.31.0 ${wrksrc}/.cargo/config is ignored for cargo install
fixes: https://github.com/void-linux/void-packages/issues/4328
2018-11-02 13:39:53 +01:00

35 lines
643 B
Bash

#
# This helper is for building rust projects which use cargo for building
#
do_configure() {
mkdir -p ${HOME}/.cargo
# respect makejobs, do cross stuff
cat > ${HOME}/.cargo/config <<EOF
[build]
jobs = ${makejobs#*j}
[target.${RUST_TARGET}]
linker = "${CC}"
EOF
}
do_build() {
: ${make_cmd:=cargo}
${make_cmd} build --release --target ${RUST_TARGET} ${configure_args}
}
do_check() {
: ${make_cmd:=cargo}
${make_cmd} test --release ${make_check_args}
}
do_install() {
: ${make_cmd:=cargo}
${make_cmd} install --path . --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
${make_install_args}
rm "${DESTDIR}"/usr/.crates.toml
}