From nobody Tue Oct 26 14:47:13 2021 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A71F0181BA08; Tue, 26 Oct 2021 14:47:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdvmd3YMjz4QxN; Tue, 26 Oct 2021 14:47:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4CA371E7A4; Tue, 26 Oct 2021 14:47:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QElDDh011876; Tue, 26 Oct 2021 14:47:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QElDJE011875; Tue, 26 Oct 2021 14:47:13 GMT (envelope-from git) Date: Tue, 26 Oct 2021 14:47:13 GMT Message-Id: <202110261447.19QElDJE011875@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Tobias Kortkamp Subject: git: 6180c0b094c8 - main - Uses/cargo: Add a cargo-crates-merge maintainer target List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tobik X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6180c0b094c839fb16fcd95e3c53f3ca79544f9c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tobik: URL: https://cgit.FreeBSD.org/ports/commit/?id=6180c0b094c839fb16fcd95e3c53f3ca79544f9c commit 6180c0b094c839fb16fcd95e3c53f3ca79544f9c Author: Tobias Kortkamp AuthorDate: 2021-10-26 11:01:27 +0000 Commit: Tobias Kortkamp CommitDate: 2021-10-26 14:46:00 +0000 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. --- Mk/Uses/cargo.mk | 21 +++++++++++++++++++-- 1 file 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