On Thu, Jun 13, 2024 at 04:03:44PM +0100, James Le Cuirot wrote:
> Several Cargo-based ebuilds cannot use cargo_src_install for various
> reasons and manually install binaries from within the target directory
> instead. It is common to see `target/$(usex debug debug release)`, but
> this lacks the target ABI when cross-compiling, so provide a helper
> function.
> 
> There are some multilib Cargo-based ebuilds that always set the target
> ABI, even when not cross-compiling. It would be simpler to do this in
> general, so once ebuilds have been updated to use this new helper, I
> might change the eclass again accordingly.
> 
> Signed-off-by: James Le Cuirot <ch...@gentoo.org>
> ---
>  eclass/cargo.eclass | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
> index 40d98211ce7f9..2036fb635d569 100644
> --- a/eclass/cargo.eclass
> +++ b/eclass/cargo.eclass
> @@ -319,6 +319,16 @@ _cargo_gen_git_config() {
>       fi
>  }
>  
> +# @FUNCTION: cargo_target_dir
> +# @DESCRIPTION:
> +# Return the directory within target that contains the build, e.g.
> +# target/aarch64-unknown-linux-gnu/release.
> +cargo_target_dir() {
> +     local abi
> +     tc-is-cross-compiler && abi=$(rust_abi)
> +     echo "${CARGO_TARGET_DIR:-target}${abi+/}${abi}/$(usex debug debug 
> release)"
> +}
> +
How about giving this function an optional parameter that gets passed to
rust_abi so that you can get the build directory for targets other than
CHOST?

What initially motivated this suggestion is a quirk in app-misc/anki's
build system together with your recent change to cargo.eclass 375da3684,
which enables cross-compilation by setting environment variables.
Here, I first build the 'build system runner' for CBUILD, which then
compiles the actual package for CHOST. I think I can avoid explicitly
setting --target $(rust ${CBUILD}) for the runner for now, but it would
be handy to easily get the build directory for CBUILD in the future!

-- 
Lucio Sauer
>  # @FUNCTION: cargo_src_unpack
>  # @DESCRIPTION:
>  # Unpacks the package and the cargo registry.
> -- 
> 2.45.1
> 
> 

Attachment: signature.asc
Description: PGP signature

Reply via email to