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 <
[email protected]>
---
eclass/cargo.eclass | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index d93ae1723470..ad15da2b51a9 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -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
@