diff options
author | Matt Jolly <kangie@gentoo.org> | 2024-11-10 10:15:54 +1000 |
---|---|---|
committer | Matt Jolly <kangie@gentoo.org> | 2024-11-11 18:49:15 +1000 |
commit | 9393ba8b683e6a055522d81740f94a11a0abfcb4 (patch) | |
tree | 1bfb06251a302d8f6529ac3727f24ed634db07bf /eclass | |
parent | app-admin/ansible-lint: drop 24.2.2, 24.6.0 (diff) | |
download | gentoo-9393ba8b683e6a055522d81740f94a11a0abfcb4.tar.gz gentoo-9393ba8b683e6a055522d81740f94a11a0abfcb4.tar.bz2 gentoo-9393ba8b683e6a055522d81740f94a11a0abfcb4.zip |
cargo.eclass: check for and quote `CARGO`
A quick sanity check that `CARGO` is set in appropriate cargo_src_*
phase functions will make it easier for users to catch occurrences
where pkg_setup does not call rust_pkg_setup.
Also inherit llvm-r1 if required and let it die instead of us if
the environment is not properly setup.
Closes: https://bugs.gentoo.org/943147
Signed-off-by: Matt Jolly <kangie@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/cargo.eclass | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 855692b72ec7..95ff317e1f21 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -20,9 +20,7 @@ if [[ -z ${_CARGO_ECLASS} ]]; then _CARGO_ECLASS=1 if [[ -n ${RUST_NEEDS_LLVM} ]]; then - if [[ -z ${_LLVM_R1_ECLASS} ]]; then - die "Please inherit llvm-r1.eclass before cargo.eclass when using RUST_NEEDS_LLVM" - fi + inherit llvm-r1 fi if [[ -n ${CARGO_OPTIONAL} ]]; then @@ -627,7 +625,11 @@ cargo_env() { cargo_src_compile() { debug-print-function ${FUNCNAME} "$@" - set -- ${CARGO} build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" + if [[ -z "${CARGO}" ]]; then + die "CARGO is not set; was rust_pkg_setup run?" + fi + + set -- "${CARGO}" build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" cargo_env "${@}" || die "cargo build failed" } @@ -641,7 +643,11 @@ cargo_src_compile() { cargo_src_install() { debug-print-function ${FUNCNAME} "$@" - set -- ${CARGO} install $(has --path ${@} || echo --path ./) \ + if [[ -z "${CARGO}" ]]; then + die "CARGO is not set; was rust_pkg_setup run?" + fi + + set -- "${CARGO}" install $(has --path ${@} || echo --path ./) \ --root "${ED}/usr" \ ${GIT_CRATES[@]:+--frozen} \ $(usex debug --debug "") \ @@ -659,7 +665,11 @@ cargo_src_install() { cargo_src_test() { debug-print-function ${FUNCNAME} "$@" - set -- ${CARGO} test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" + if [[ -z "${CARGO}" ]]; then + die "CARGO is not set; was rust_pkg_setup run?" + fi + + set -- "${CARGO}" test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" cargo_env "${@}" || die "cargo test failed" } |