cargo_gen_config sets required config values and env vars, which
cargo_src_{compile,test,install} rely on.

it should be called as last step of src_unpack normally, so check it did.
Crate sources may have been vendored or cargo is wrapped by other build
system and pre-fetched, so cargo_*unpack may be not used.

In that case we can't guarantee our config will work, so src_ functions
should not be used.

Signed-off-by: Georgy Yakovlev <gyakov...@gentoo.org>
---
 eclass/cargo.eclass | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index dde601ec4e3c..3e08888bb443 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -267,6 +267,7 @@ cargo_gen_config() {
        _EOF_
 
        export CARGO_HOME="${ECARGO_HOME}"
+       _CARGO_GEN_CONFIG_HAS_RUN=1
 }
 
 # @FUNCTION: cargo_src_configure
@@ -323,6 +324,9 @@ cargo_src_configure() {
 cargo_src_compile() {
        debug-print-function ${FUNCNAME} "$@"
 
+       [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
+               die "FATAL: please call cargo_gen_config before using 
${FUNCNAME}"
+
        tc-export AR CC CXX
 
        set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
@@ -340,6 +344,9 @@ cargo_src_compile() {
 cargo_src_install() {
        debug-print-function ${FUNCNAME} "$@"
 
+       [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
+               die "FATAL: please call cargo_gen_config before using 
${FUNCNAME}"
+
        set -- cargo install $(has --path ${@} || echo --path ./) \
                --root "${ED}/usr" \
                $(usex debug --debug "") \
@@ -359,6 +366,9 @@ cargo_src_install() {
 cargo_src_test() {
        debug-print-function ${FUNCNAME} "$@"
 
+       [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
+               die "FATAL: please call cargo_gen_config before using 
${FUNCNAME}"      
+
        set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
        einfo "${@}"
        "${@}" || die "cargo test failed"
-- 
2.28.0


Reply via email to