[prev in list] [next in list] [prev in thread] [next in thread]
List: gentoo-dev
Subject: [gentoo-dev] [PATCH 2/2] eclass/cargo.eclass: require cargo_gen_config in cargo_src* functions
From: Georgy Yakovlev <gyakovlev () gentoo ! org>
Date: 2020-09-27 21:44:32
Message-ID: 20200927214432.342806-2-gyakovlev () gentoo ! org
[Download RAW message or body]
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 <gyakovlev@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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic