commit:     6554c490d8e75e5784bd29105121dfb7aa0baca7
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 27 21:27:50 2020 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Tue Sep 29 01:58:47 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6554c490

eclass/cargo.eclass: require cargo_gen_config in cargo_src* functions

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 not have been used.

In that case our config does not work for external build system,
our cargo_src_ functions should not be used.

Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 eclass/cargo.eclass | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index dec56b48fc9..bbb3d40a620 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -265,6 +265,7 @@ cargo_gen_config() {
        _EOF_
 
        export CARGO_HOME="${ECARGO_HOME}"
+       _CARGO_GEN_CONFIG_HAS_RUN=1
 }
 
 # @FUNCTION: cargo_src_configure
@@ -321,6 +322,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[@]} "$@"
@@ -338,6 +342,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 "") \
@@ -357,6 +364,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"

Reply via email to