1 |
cargo_gen_config sets required config values and env vars, which |
2 |
cargo_src_{compile,test,install} rely on. |
3 |
|
4 |
it should be called as last step of src_unpack normally, so check it did. |
5 |
Crate sources may have been vendored or cargo is wrapped by other build |
6 |
system and pre-fetched, so cargo_*unpack may be not used. |
7 |
|
8 |
In that case we can't guarantee our config will work, so src_ functions |
9 |
should not be used. |
10 |
|
11 |
Signed-off-by: Georgy Yakovlev <gyakovlev@g.o> |
12 |
--- |
13 |
eclass/cargo.eclass | 10 ++++++++++ |
14 |
1 file changed, 10 insertions(+) |
15 |
|
16 |
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass |
17 |
index dde601ec4e3c..3e08888bb443 100644 |
18 |
--- a/eclass/cargo.eclass |
19 |
+++ b/eclass/cargo.eclass |
20 |
@@ -267,6 +267,7 @@ cargo_gen_config() { |
21 |
_EOF_ |
22 |
|
23 |
export CARGO_HOME="${ECARGO_HOME}" |
24 |
+ _CARGO_GEN_CONFIG_HAS_RUN=1 |
25 |
} |
26 |
|
27 |
# @FUNCTION: cargo_src_configure |
28 |
@@ -323,6 +324,9 @@ cargo_src_configure() { |
29 |
cargo_src_compile() { |
30 |
debug-print-function ${FUNCNAME} "$@" |
31 |
|
32 |
+ [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ |
33 |
+ die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" |
34 |
+ |
35 |
tc-export AR CC CXX |
36 |
|
37 |
set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" |
38 |
@@ -340,6 +344,9 @@ cargo_src_compile() { |
39 |
cargo_src_install() { |
40 |
debug-print-function ${FUNCNAME} "$@" |
41 |
|
42 |
+ [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ |
43 |
+ die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" |
44 |
+ |
45 |
set -- cargo install $(has --path ${@} || echo --path ./) \ |
46 |
--root "${ED}/usr" \ |
47 |
$(usex debug --debug "") \ |
48 |
@@ -359,6 +366,9 @@ cargo_src_install() { |
49 |
cargo_src_test() { |
50 |
debug-print-function ${FUNCNAME} "$@" |
51 |
|
52 |
+ [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ |
53 |
+ die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" |
54 |
+ |
55 |
set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" |
56 |
einfo "${@}" |
57 |
"${@}" || die "cargo test failed" |
58 |
-- |
59 |
2.28.0 |