also move install path to config file, so it can be
overriden via command line arg if required.

Signed-off-by: Georgy Yakovlev <gyakov...@gentoo.org>
---
 eclass/cargo.eclass | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 0ab7ee0dc9b2..a7c7bffd3c0c 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -266,10 +266,26 @@ cargo_gen_config() {
        [net]
        offline = true
 
+       [profile.gentoo]
+       # 
https://doc.rust-lang.org/cargo/reference/profiles.html#custom-profiles
+       inherits = "release"
+
+       # emulate dev profile with USE=debug
+       # https://doc.rust-lang.org/cargo/reference/profiles.html#dev
+       debug = $(usex debug true false)
+       debug-assertions = $(usex debug true false)
+       overflow-checks = $(usex debug true false)
+       strip = "none"
+       $(usex debug 'opt-level = 0' '')
+       $(usex debug 'lto = false' '')
+
        [build]
        jobs = $(makeopts_jobs)
        incremental = false
 
+       [install]
+       root = "${ED}/usr"
+
        [term]
        verbose = true
        $([[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo "color = 
'never'")
@@ -506,7 +522,7 @@ cargo_src_compile() {
 
        tc-export AR CC CXX PKG_CONFIG
 
-       set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
+       set -- cargo build --profile gentoo ${ECARGO_ARGS[@]} "$@"
        einfo "${@}"
        "${@}" || die "cargo build failed"
 }
@@ -524,14 +540,17 @@ cargo_src_install() {
                die "FATAL: please call cargo_gen_config before using 
${FUNCNAME}"
 
        set -- cargo install $(has --path ${@} || echo --path ./) \
-               --no-track \
-               --root "${ED}/usr" \
-               ${GIT_CRATES[@]:+--frozen} \
-               $(usex debug --debug "") \
-               ${ECARGO_ARGS[@]} "$@"
+               --profile gentoo --no-track \
+                ${GIT_CRATES[@]:+--frozen} ${ECARGO_ARGS[@]} "$@"
        einfo "${@}"
        "${@}" || die "cargo install failed"
 
+       # HACK: compat symlinks until old ebuilds migrate.
+       # create target/{debug,release} symlinks that some ebuilds rely on.
+       # This only affects ebuilds that pick extra generated files from target 
directory, that's rare.
+       ln -s gentoo "${S}"/target/debug || :
+       ln -s gentoo "${S}"/target/release || :
+
        # it turned out to be non-standard dir, so get rid of it future EAPI
        # and only run for EAPI=7
        # https://bugs.gentoo.org/715890
@@ -553,7 +572,7 @@ cargo_src_test() {
        [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
                die "FATAL: please call cargo_gen_config before using 
${FUNCNAME}"
 
-       set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
+       set -- cargo test --profile gentoo ${ECARGO_ARGS[@]} "$@"
        einfo "${@}"
        "${@}" || die "cargo test failed"
 }
-- 
2.39.1


Reply via email to