Tue Dec 3 02:09:06 2019 UTC ()
lang/rust/cargo.mk: Set default values for cargo package variables

With these values, a Rust package downloads its own distfile from
crates.io by default, and shares dependancy crate distfiles with other
Rust packages to avoid multiple downloads.


(minskim)
diff -r1.8 -r1.9 pkgsrc/lang/rust/cargo.mk

cvs diff -r1.8 -r1.9 pkgsrc/lang/rust/cargo.mk (expand / switch to unified diff)

--- pkgsrc/lang/rust/cargo.mk 2019/11/03 19:04:07 1.8
+++ pkgsrc/lang/rust/cargo.mk 2019/12/03 02:09:06 1.9
@@ -1,35 +1,38 @@ @@ -1,35 +1,38 @@
1# $NetBSD: cargo.mk,v 1.8 2019/11/03 19:04:07 rillig Exp $ 1# $NetBSD: cargo.mk,v 1.9 2019/12/03 02:09:06 minskim Exp $
2# 2#
3# Common logic that can be used by packages that depend on cargo crates 3# Common logic that can be used by packages that depend on cargo crates
4# from crates.io. This lets existing pkgsrc infrastructure fetch and verify 4# from crates.io. This lets existing pkgsrc infrastructure fetch and verify
5# cargo crates instead of using the rust package manager in the build phase. 5# cargo crates instead of using the rust package manager in the build phase.
6# Inspired by cargo.mk from FreeBSD ports. 6# Inspired by cargo.mk from FreeBSD ports.
7# 7#
8# Usage example: 8# Usage example:
9# 9#
10# CARGO_CRATE_DEPENDS+= sha1-0.20 10# CARGO_CRATE_DEPENDS+= sha1-0.20
11# .include "../../lang/rust/cargo.mk" 11# .include "../../lang/rust/cargo.mk"
12# do-build: 12# do-build:
13# cargo build --locked --frozen 13# cargo build --locked --frozen
14# 14#
15# 15#
16# If modifying the list of dependencies, re-run the build once without 16# If modifying the list of dependencies, re-run the build once without
17# --locked --frozen to generate a new valid Cargo.lock. 17# --locked --frozen to generate a new valid Cargo.lock.
18# 18#
19# a list of CARGO_CRATE_DEPENDS can be generated via "make show-cargo-depends". 19# a list of CARGO_CRATE_DEPENDS can be generated via "make show-cargo-depends".
20# 20#
21# See also www/geckodriver for a full example. 21# See also www/geckodriver for a full example.
22 22
 23MASTER_SITES?= -${MASTER_SITE_CRATESIO}${PKGBASE}/${PKGVERSION_NOREV}/download
 24DIST_SUBDIR?= crates.io
 25
23BUILD_DEPENDS+= rust-[0-9]*:../../lang/rust 26BUILD_DEPENDS+= rust-[0-9]*:../../lang/rust
24 27
25USE_TOOLS+= bsdtar digest 28USE_TOOLS+= bsdtar digest
26CARGO_VENDOR_DIR= ${WRKDIR}/vendor 29CARGO_VENDOR_DIR= ${WRKDIR}/vendor
27 30
28DISTFILES?= ${DEFAULT_DISTFILES} 31DISTFILES?= ${DEFAULT_DISTFILES}
29.for _crate in ${CARGO_CRATE_DEPENDS} 32.for _crate in ${CARGO_CRATE_DEPENDS}
30DISTFILES+= ${_crate}.crate 33DISTFILES+= ${_crate}.crate
31SITES.${_crate}.crate+= -${MASTER_SITE_CRATESIO}${_crate:C/-[0-9]+\.[0-9.]+.*$//}/${_crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download 34SITES.${_crate}.crate+= -${MASTER_SITE_CRATESIO}${_crate:C/-[0-9]+\.[0-9.]+.*$//}/${_crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download
32EXTRACT_DIR.${_crate}.crate?= ${CARGO_VENDOR_DIR} 35EXTRACT_DIR.${_crate}.crate?= ${CARGO_VENDOR_DIR}
33.endfor 36.endfor
34 37
35post-extract: cargo-vendor-crates 38post-extract: cargo-vendor-crates