mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
cargo.eclass: Pull check for rust_pkg_setup into its own function
This reduces repetitiveness and allows for easier maintainability in the future. Bug: https://bugs.gentoo.org/953515 Bug: https://bugs.gentoo.org/953532 Signed-off-by: Christopher Fore <csfore@posteo.net> Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
committed by
Sam James
parent
ace8b37ca2
commit
e7aa0ac74a
@@ -245,6 +245,16 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
|
||||
# @DESCRIPTION:
|
||||
# List of URIs to put in SRC_URI created from CRATES variable.
|
||||
|
||||
# @FUNCTION: _cargo_check_initialized
|
||||
# @INTERNAL
|
||||
# @DESCRIPTION:
|
||||
# Checks if rust_pkg_setup has been run.
|
||||
_cargo_check_initialized() {
|
||||
if [[ -z "${CARGO}" ]]; then
|
||||
die "CARGO is not set; was rust_pkg_setup run?"
|
||||
fi
|
||||
}
|
||||
|
||||
# @FUNCTION: _cargo_set_crate_uris
|
||||
# @USAGE: <crates>
|
||||
# @DESCRIPTION:
|
||||
@@ -468,9 +478,7 @@ cargo_target_dir() {
|
||||
cargo_update_crates () {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
|
||||
if [[ -z ${CARGO} ]]; then
|
||||
die "CARGO is not set; was rust_pkg_setup run?"
|
||||
fi
|
||||
_cargo_check_initialized
|
||||
|
||||
local path=${1:-"${S}/Cargo.toml"}
|
||||
if [[ $# -gt 1 ]]; then
|
||||
@@ -778,9 +786,7 @@ cargo_env() {
|
||||
cargo_src_compile() {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
|
||||
if [[ -z "${CARGO}" ]]; then
|
||||
die "CARGO is not set; was rust_pkg_setup run?"
|
||||
fi
|
||||
_cargo_check_initialized
|
||||
|
||||
set -- "${CARGO}" build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
|
||||
einfo "${@}"
|
||||
@@ -796,9 +802,7 @@ cargo_src_compile() {
|
||||
cargo_src_install() {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
|
||||
if [[ -z "${CARGO}" ]]; then
|
||||
die "CARGO is not set; was rust_pkg_setup run?"
|
||||
fi
|
||||
_cargo_check_initialized
|
||||
|
||||
set -- "${CARGO}" install $(has --path ${@} || echo --path ./) \
|
||||
--root "${ED}/usr" \
|
||||
@@ -818,9 +822,7 @@ cargo_src_install() {
|
||||
cargo_src_test() {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
|
||||
if [[ -z "${CARGO}" ]]; then
|
||||
die "CARGO is not set; was rust_pkg_setup run?"
|
||||
fi
|
||||
_cargo_check_initialized
|
||||
|
||||
set -- "${CARGO}" test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
|
||||
einfo "${@}"
|
||||
|
||||
Reference in New Issue
Block a user