git: d2eb03d1c0d3 - main - Uses/cargo: Make it easier to build ports with out-of-tree toolchain

From: Tobias Kortkamp <tobik_at_FreeBSD.org>
Date: Sun, 07 Nov 2021 15:28:26 UTC
The branch main has been updated by tobik:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d2eb03d1c0d343b2fe350b9079f6c54dfcfbaa1f

commit d2eb03d1c0d343b2fe350b9079f6c54dfcfbaa1f
Author:     Tobias Kortkamp <tobik@FreeBSD.org>
AuthorDate: 2021-11-07 14:08:57 +0000
Commit:     Tobias Kortkamp <tobik@FreeBSD.org>
CommitDate: 2021-11-07 15:24:13 +0000

    Uses/cargo: Make it easier to build ports with out-of-tree toolchain
    
    - CARGO_CARGO_BIN -> CARGO
    - Add RUSTC and RUSTDOC for overriding rustc and rustdoc
---
 Mk/Uses/cargo.mk | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk
index 76b44f3f2ba3..1da833d29c4f 100644
--- a/Mk/Uses/cargo.mk
+++ b/Mk/Uses/cargo.mk
@@ -100,8 +100,10 @@ CARGO_BUILDDEP?=	yes
 BUILD_DEPENDS+=	${RUST_DEFAULT}>=1.56.0:lang/${RUST_DEFAULT}
 .endif
 
-# Location of cargo binary (default to lang/rust's Cargo binary)
-CARGO_CARGO_BIN?=	${LOCALBASE}/bin/cargo
+# Location of toolchain (default to lang/rust's toolchain)
+CARGO?=		${LOCALBASE}/bin/cargo
+RUSTC?=		${LOCALBASE}/bin/rustc
+RUSTDOC?=	${LOCALBASE}/bin/rustdoc
 
 # Location of the cargo output directory.
 CARGO_TARGET_DIR?=	${WRKDIR}/target
@@ -124,8 +126,8 @@ CARGO_ENV+= \
 	CARGO_TARGET_DIR=${CARGO_TARGET_DIR} \
 	CARGO_TARGET_${CARGO_BUILD_TARGET:S/-/_/g:tu}_LINKER="${CC}" \
 	RUST_BACKTRACE=1 \
-	RUSTC=${LOCALBASE}/bin/rustc \
-	RUSTDOC=${LOCALBASE}/bin/rustdoc \
+	RUSTC=${RUSTC} \
+	RUSTDOC=${RUSTDOC} \
 	RUSTFLAGS="${RUSTFLAGS} ${LDFLAGS:C/.+/-C link-arg=&/}"
 
 # Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk
@@ -143,7 +145,7 @@ STRIP_CMD=	${LOCALBASE}/bin/strip # unsupported e_type with base strip
 .endif
 
 # Helper to shorten cargo calls.
-_CARGO_RUN=		${SETENV} ${MAKE_ENV} ${CARGO_ENV} ${CARGO_CARGO_BIN}
+_CARGO_RUN=		${SETENV} ${MAKE_ENV} ${CARGO_ENV} ${CARGO}
 CARGO_CARGO_RUN=	cd ${WRKSRC}; ${SETENV} CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE=1 ${_CARGO_RUN}
 
 # User arguments for cargo targets.