diff options
authorTobias Kortkamp <tobik@FreeBSD.org>2021-04-14 11:53:37 +0000
committerTobias Kortkamp <tobik@FreeBSD.org>2021-04-14 12:22:42 +0000
commitffd4db6b940600e78ab01f8ef06bb3e7629f48e6 (patch)
parent5eab5d2691e3290eee56e5c9f6dbe99a1bd8a866 (diff)
Speed up USES=cargo ports ops
MASTER_SITES aliases processing in the framework is very inefficient and the CRATESIO indirection is not worth it. Normally ports only have a handful of sites at most, but USES=cargo currently adds one site for each crate by necessity. The inefficiency suddenly matters a lot. By consuming MASTER_SITE_CRATESIO directly we can sidestep this issue without losing anything. Before: $ time make -C www/zola -V MASTER_SITES >/dev/null 4.21 real 4.14 user 0.03 sys After: $ time make -C www/zola -V MASTER_SITES >/dev/null 0.60 real 0.58 user 0.02 sys
1 files changed, 3 insertions, 2 deletions
diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk
index 69a1ee45c8a4..816b720a2eef 100644
--- a/Mk/Uses/cargo.mk
+++ b/Mk/Uses/cargo.mk
@@ -15,7 +15,7 @@ IGNORE+= USES=cargo takes no arguments
# List of static dependencies. The format is cratename-version.
-# CARGO_CRATES will be downloaded from MASTER_SITES_CRATESIO.
+# CARGO_CRATES will be downloaded from MASTER_SITE_CRATESIO.
# List of features to build (space separated list).
@@ -35,7 +35,8 @@ CARGO_DIST_SUBDIR?= rust/crates
# Generate list of DISTFILES.
.for _crate in ${CARGO_CRATES}
-MASTER_SITES+= CRATESIO/${_crate:C/^([-_a-zA-Z0-9]+)-[0-9].*/\1/}/${_crate:C/^[-_a-zA-Z0-9]+-([0-9].*)/\1/}:cargo_${_crate:C/[^a-zA-Z0-9_]//g}
+# Resolving CRATESIO alias is very inefficient with many MASTER_SITES, consume MASTER_SITE_CRATESIO directly
+MASTER_SITES+= ${MASTER_SITE_CRATESIO:S,%SUBDIR%,${_crate:C/^([-_a-zA-Z0-9]+)-[0-9].*/\1/}/${_crate:C/^[-_a-zA-Z0-9]+-([0-9].*)/\1/},:S,$,:cargo_${_crate:C/[^a-zA-Z0-9_]//g},}
DISTFILES+= ${CARGO_DIST_SUBDIR}/${_crate}.tar.gz:cargo_${_crate:C/[^a-zA-Z0-9_]//g}