aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Kortkamp <tobik@FreeBSD.org>2021-10-26 11:01:27 +0000
committerTobias Kortkamp <tobik@FreeBSD.org>2021-10-26 14:46:00 +0000
commit6180c0b094c839fb16fcd95e3c53f3ca79544f9c (patch)
treea819e59cdf8364a10ecf6c6dc4eef795cbcf0891
parent140cb7a8ef8b40dbf9105c3bd5e1c1f8a011ad32 (diff)
downloadports-6180c0b094c839fb16fcd95e3c53f3ca79544f9c.tar.gz
ports-6180c0b094c839fb16fcd95e3c53f3ca79544f9c.zip
Uses/cargo: Add a cargo-crates-merge maintainer target
It is the in-place version of cargo-crates and updates CARGO_CRATES in the port's Makefile for you via portedit from ports-mgmt/portfmt.
-rw-r--r--Mk/Uses/cargo.mk21
1 files changed, 19 insertions, 2 deletions
diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk
index e1f5544b9c0b..76b44f3f2ba3 100644
--- a/Mk/Uses/cargo.mk
+++ b/Mk/Uses/cargo.mk
@@ -347,14 +347,18 @@ do-test:
# cargo-crates will output the crates list from Cargo.lock. If there
# is no Cargo.lock for some reason, try and generate it first.
-cargo-crates: extract
+cargo-crates: cargo-crates-generate-lockfile
+ @${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK}
+
+# cargo-crates-generate-lockfile will try to generate a Cargo.lock file
+# if it does not exist.
+cargo-crates-generate-lockfile: extract
@if [ ! -r "${CARGO_CARGOLOCK}" ]; then \
${ECHO_MSG} "===> ${CARGO_CARGOLOCK} not found. Trying to generate it..."; \
cd ${WRKSRC}; ${_CARGO_RUN} generate-lockfile \
--manifest-path ${CARGO_CARGOTOML} \
--verbose; \
fi
- @${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK}
# cargo-crates-licenses will try to grab license information from
# all downloaded crates.
@@ -365,4 +369,17 @@ cargo-crates-licenses: configure
-e 's@^${CARGO_VENDOR_DIR}/@@' \
-e 's@/Cargo.toml:license.*= *"@|@' \
-e 's@"$$@@g' | sort | /usr/bin/column -t -s '|'
+
+# cargo-crates-merge will in-place update CARGO_CRATES in the port
+# based on the crates list from Cargo.lock. If there is no Cargo.lock
+# for some reason, try and generate it first.
+cargo-crates-merge: cargo-crates-generate-lockfile
+ @if ! type portedit > /dev/null 2>&1; then \
+ ${ECHO_MSG} "===> Please install \"ports-mgmt/portfmt\""; exit 1; \
+ fi
+ @f="${MASTERDIR}/Makefile"; [ -r "${MASTERDIR}/Makefile.crates" ] && f="${MASTERDIR}/Makefile.crates"; \
+ ${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK} | \
+ portedit merge -i $$f; \
+ ${ECHO_MSG} "CARGO_CRATES in $$f was updated"
+
.endif