git: cf447c2b1a39 - 2024Q1 - Mk/Uses: make it possible to compile gems that need rust to build

From: Matthias Fechner <>
Date: Mon, 15 Jan 2024 12:09:31 UTC
The branch 2024Q1 has been updated by mfechner:


commit cf447c2b1a3905d2ffb186b5db32af03b055dc73
Author:     Matthias Fechner <>
AuthorDate: 2024-01-09 12:04:24 +0000
Commit:     Matthias Fechner <>
CommitDate: 2024-01-15 12:07:02 +0000

    Mk/Uses: make it possible to compile gems that need rust to build
    This commits defines same variables in a way that they can be overwritten
    by a port.
    Refactored the extract target to work together with
    The file will require more work to be easily usable for gems that
    required rust. Most of the work is now outsourced to the port.
    I added comments to parts that needs more love.
    To test these modification, the following commands can be used:
    (make sure you adjust the path to match your environment)
    rm /usr/local/poudriere/ports/gitlab/distfiles/rubygem/gapic-common-*.gem
    rm /usr/local/poudriere/ports/gitlab/distfiles/rubygem/prome*.gem
    rm /usr/local/poudriere/ports/gitlab/distfiles/rust/crates/ahash-*crate
    cd /usr/local/poudriere/ports/gitlab/devel/rubygem-prometheus-client-mmap
    make makesum
    cd /usr/local/poudriere/ports/gitlab/devel/rubygem-gapic-common
    make makesum
    poudriere testport -p gitlab -j 132amd64 devel/rubygem-gapic-common && poudriere testport -p gitlab -j 132amd64 devel/rubygem-prometheus-client-mmap
    (cherry picked from commit 606b37bbf06dcdfb54480aae8fb69135c06fb11a)
 Mk/Uses/ | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/Mk/Uses/ b/Mk/Uses/
index a1e77273932a..8c4539a274ca 100644
--- a/Mk/Uses/
+++ b/Mk/Uses/
@@ -24,8 +24,8 @@ IGNORE= Incorrect 'USES+= gem:${gem_ARGS}' usage: argument [${arg}] is not recog
-DIST_SUBDIR=	rubygem
+# disabled to be able that extract other archives into the gem folder like cargo archives which are required to compile gems that require rust
 BUILD_DEPENDS+=	${RUBYGEMBIN}:devel/ruby-gems
 EXTRACT_DEPENDS+=	${RUBYGEMBIN}:devel/ruby-gems
@@ -67,10 +67,20 @@ PLIST_SUB+=	PORTVERSION="${PORTVERSION}" \
+.  if defined(GEMS_SKIP_SUBDIR)
+# do not define a DIST_SUBDIR, currently required to have cargo archives available in the gem source directory to be able to compile it
+.  else
+DIST_SUBDIR=	rubygem
+.  endif
 .  if defined(DISTFILES)
+# this should maybe be reworked, as if a gem port is used together with cargo archives, the DISTFILES also includes the cargo archives
+# this is currently overwritten in the port that requires this
+# the cargo archives should be filtered out here or better we should only have here gem archives included
+GEMFILES?=	${DISTFILES:C/:[^:]+$//}
 .  else
 .  endif
 RUBYGEM_ARGS=-l --no-update-sources --install-dir ${STAGEDIR}${PREFIX}/lib/ruby/gems/${RUBY_VER} --ignore-dependencies --bindir=${STAGEDIR}${PREFIX}/bin
@@ -81,8 +91,8 @@ RUBYGEM_ARGS+=	--document rdoc,ri
 RUBYGEM_ARGS+=	--no-document
 .  endif
-.  if !target(do-extract)
+_USES_extract+=	590:gem-extract
 	@(cd ${BUILD_WRKSRC}; if ! ${SETENV} ${GEM_ENV} ${RUBYGEMBIN} spec --ruby ${DISTDIR}/${DIST_SUBDIR}/${GEMFILES} > ${GEMSPEC} ; then \
 		if [ -n "${BUILD_FAIL_MESSAGE}" ] ; then \
@@ -91,7 +101,6 @@ do-extract:
 			fi; \
 		${FALSE}; \
-.  endif
 .  if !target(do-build)