From 6554c490d8e75e5784bd29105121dfb7aa0baca7 Mon Sep 17 00:00:00 2001 From: Georgy Yakovlev Date: Sun, 27 Sep 2020 14:27:50 -0700 Subject: 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 --- eclass/cargo.eclass | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'eclass/cargo.eclass') diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index dec56b48fc9c..bbb3d40a6206 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" -- cgit v1.2.3-65-gdbad