From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9CEA8158042 for ; Sat, 9 Nov 2024 06:26:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C0513E0883; Sat, 9 Nov 2024 06:26:42 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AA7F2E0883 for ; Sat, 9 Nov 2024 06:26:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DCB17335D7B for ; Sat, 9 Nov 2024 06:26:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 53F1F1AED for ; Sat, 9 Nov 2024 06:26:40 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1731130294.8ba94e73b14d16da3b8154ee468826df34bd61e0.kangie@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cargo.eclass X-VCS-Directories: eclass/ X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 8ba94e73b14d16da3b8154ee468826df34bd61e0 X-VCS-Branch: master Date: Sat, 9 Nov 2024 06:26:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7e2445c1-4ab7-4c14-8507-d598424b41dd X-Archives-Hash: 08cc5e607aec5914b6e581cb14a1bf92 commit: 8ba94e73b14d16da3b8154ee468826df34bd61e0 Author: Matt Jolly gentoo org> AuthorDate: Tue Nov 5 06:26:11 2024 +0000 Commit: Matt Jolly gentoo org> CommitDate: Sat Nov 9 05:31:34 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8ba94e73 cargo: update for rust eclass Inherit the rust eclass and take advantage of eclass features like `RUST_MIN_VER`. `RUST_DEPEND` was moved into the rust eclass in the previous commit and is now prowided via this mechanism `CARGO_OPTIONAL` now sets `RUST_OPTIONAL`, requiring ebuilds to set `RUST_DEPEND` manually and manage both cargo and rust eclass functions. Replace calls to `cargo` with the rust eclass exported ${CARGO}. Signed-off-by: Matt Jolly gentoo.org> eclass/cargo.eclass | 59 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 499fe5498c96..855692b72ec7 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -8,6 +8,7 @@ # Doug Goldstein # Georgy Yakovlev # @SUPPORTED_EAPIS: 8 +# @PROVIDES: rust # @BLURB: common functions and variables for cargo builds case ${EAPI} in @@ -18,25 +19,36 @@ esac if [[ -z ${_CARGO_ECLASS} ]]; then _CARGO_ECLASS=1 -# check and document RUST_DEPEND and options we need below in case conditions. +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 +fi + +if [[ -n ${CARGO_OPTIONAL} ]]; then + RUST_OPTIONAL=1 +fi + +# Either the lowest slot supported by rust.eclass _or_ +# reference the changelog for a particular feature requirement # https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md -RUST_DEPEND="virtual/rust" +_CARGO_ECLASS_RUST_MIN_VER="1.71.1" case ${EAPI} in 8) - # 1.39 added --workspace - # 1.46 added --target dir - # 1.48 added term.progress config option - # 1.51 added split-debuginfo profile option - # 1.52 may need setting RUSTC_BOOTSTRAP envvar for some crates - # 1.53 added cargo update --offline, can be used to update vulnerable crates from pre-fetched registry without editing toml - RUST_DEPEND=">=virtual/rust-1.53" + if [[ -n ${RUST_MIN_VER} ]]; then + # This is _very_ unlikely given that we leverage the rust eclass but just in case cargo requires a newer version + # than the oldest in-tree in future. + if ver_test "${RUST_MIN_VER}" -lt "${_CARGO_ECLASS_RUST_MIN_VER}"; then + die "RUST_MIN_VERSION must be at least ${_CARGO_ECLASS_RUST_MIN_VER}" + fi + else + RUST_MIN_VER="${_CARGO_ECLASS_RUST_MIN_VER}" + fi ;; esac -inherit flag-o-matic multiprocessing rust-toolchain toolchain-funcs - -[[ ! ${CARGO_OPTIONAL} ]] && BDEPEND="${RUST_DEPEND}" +inherit flag-o-matic multiprocessing rust rust-toolchain toolchain-funcs IUSE="${IUSE} debug" @@ -107,9 +119,8 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # be considered optional. No dependencies will be added and no phase # functions will be exported. # -# If you enable CARGO_OPTIONAL, you have to set BDEPEND on virtual/rust -# for your package and call at least cargo_gen_config manually before using -# other src_functions or cargo_env of this eclass. +# If you enable CARGO_OPTIONAL call at least cargo_gen_config manually +# before using other src_functions or cargo_env of this eclass. # Note that cargo_gen_config is automatically called by cargo_src_unpack. # @ECLASS_VARIABLE: myfeatures @@ -129,6 +140,11 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # } # @CODE +# @ECLASS_VARIABLE: ECARGO_HOME +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# Location of the cargo home directory. + # @ECLASS_VARIABLE: ECARGO_REGISTRY_DIR # @USER_VARIABLE # @DEFAULT_UNSET @@ -148,6 +164,11 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # cargo_live_src_unpack. # Inherits value of EVCS_OFFLINE if not set explicitly. +# @ECLASS_VARIABLE: ECARGO_VENDOR +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# Location of the cargo vendor directory. + # @ECLASS_VARIABLE: EVCS_UMASK # @USER_VARIABLE # @DEFAULT_UNSET @@ -531,6 +552,8 @@ cargo_src_configure() { # take affect due to Cargo limitations, so add these to your ebuild's RUSTFLAGS # if they seem important. cargo_env() { + debug-print-function ${FUNCNAME} "$@" + [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" @@ -604,7 +627,7 @@ cargo_env() { cargo_src_compile() { debug-print-function ${FUNCNAME} "$@" - set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" + set -- ${CARGO} build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" cargo_env "${@}" || die "cargo build failed" } @@ -618,7 +641,7 @@ cargo_src_compile() { cargo_src_install() { debug-print-function ${FUNCNAME} "$@" - set -- cargo install $(has --path ${@} || echo --path ./) \ + set -- ${CARGO} install $(has --path ${@} || echo --path ./) \ --root "${ED}/usr" \ ${GIT_CRATES[@]:+--frozen} \ $(usex debug --debug "") \ @@ -636,7 +659,7 @@ cargo_src_install() { cargo_src_test() { debug-print-function ${FUNCNAME} "$@" - set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" + set -- ${CARGO} test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" cargo_env "${@}" || die "cargo test failed" }