git: 87916ecbfac7 - main - gem: make it possible to generate gems that require rust/cargo

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 08:18:44 UTC
The branch main has been updated by mfechner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=87916ecbfac7532b4d3de63efa36ed8f8e637e36

commit 87916ecbfac7532b4d3de63efa36ed8f8e637e36
Author:     Matthias Fechner <mfechner@FreeBSD.org>
AuthorDate: 2024-01-03 09:32:55 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-01-06 08:18:36 +0000

    gem: make it possible to generate gems that require rust/cargo
    
    Make sure cargo.mk and gem.mk can work together.
    If you want to use rust for your gem, have a look on
    devel/rubygem-prometheus-client-mmap as an example.
    
    Differential Revision:  https://reviews.freebsd.org/D43292
---
 Mk/Uses/gem.mk | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/Mk/Uses/gem.mk b/Mk/Uses/gem.mk
index a1e77273932a..69924ae3d172 100644
--- a/Mk/Uses/gem.mk
+++ b/Mk/Uses/gem.mk
@@ -23,9 +23,10 @@ IGNORE= Incorrect 'USES+= gem:${gem_ARGS}' usage: argument [${arg}] is not recog
 .include "${USESDIR}/ruby.mk"
 
 PKGNAMEPREFIX?=	rubygem-
-EXTRACT_SUFX=	.gem
-EXTRACT_ONLY=
-DIST_SUBDIR=	rubygem
+GEM_EXT=	.gem
+# needs to be disabled that rust cargo directories are correctly extracted
+#EXTRACT_ONLY=
+GEM_DIST_SUBDIR?=	rubygem
 
 BUILD_DEPENDS+=	${RUBYGEMBIN}:devel/ruby-gems
 EXTRACT_DEPENDS+=	${RUBYGEMBIN}:devel/ruby-gems
@@ -63,15 +64,16 @@ PLIST_SUB+=	PORTVERSION="${PORTVERSION}" \
 		GEM_DOC_DIR="${GEM_DOC_DIR}" \
 		GEM_SPEC="${GEM_SPEC}" \
 		GEM_CACHE="${GEM_CACHE}" \
-		EXTRACT_SUFX="${EXTRACT_SUFX}"
+		GEM_EXT="${GEM_EXT}"
 
 RUBYGEMBIN=	${LOCALBASE}/bin/gem
 
 .  if defined(DISTFILES)
-GEMFILES=	${DISTFILES:C/:[^:]+$//}
+GEMFILES?=	${DISTFILES:C/:[^:]+$//}
 .  else
-GEMFILES=	${DISTNAME}${EXTRACT_SUFX}
+GEMFILES?=	${DISTNAME}${GEM_EXT}
 .  endif
+DISTFILES+=	${GEM_DIST_SUBDIR}/${GEMFILES}
 
 RUBYGEM_ARGS=-l --no-update-sources --install-dir ${STAGEDIR}${PREFIX}/lib/ruby/gems/${RUBY_VER} --ignore-dependencies --bindir=${STAGEDIR}${PREFIX}/bin
 
@@ -81,17 +83,16 @@ RUBYGEM_ARGS+=	--document rdoc,ri
 RUBYGEM_ARGS+=	--no-document
 .  endif
 
-.  if !target(do-extract)
-do-extract:
-	@${SETENV} ${GEM_ENV} ${RUBYGEMBIN} unpack --target=${WRKDIR} ${DISTDIR}/${DIST_SUBDIR}/${GEMFILES}
-	@(cd ${BUILD_WRKSRC}; if ! ${SETENV} ${GEM_ENV} ${RUBYGEMBIN} spec --ruby ${DISTDIR}/${DIST_SUBDIR}/${GEMFILES} > ${GEMSPEC} ; then \
+_USES_extract+=		590:gem-extract
+gem-extract:
+	@${SETENV} ${GEM_ENV} ${RUBYGEMBIN} unpack --target=${WRKDIR} ${DISTDIR}/${GEM_DIST_SUBDIR}/${GEMFILES}
+	@(cd ${BUILD_WRKSRC}; if ! ${SETENV} ${GEM_ENV} ${RUBYGEMBIN} spec --ruby ${DISTDIR}/${GEM_DIST_SUBDIR}/${GEMFILES} > ${GEMSPEC} ; then \
 		if [ -n "${BUILD_FAIL_MESSAGE}" ] ; then \
 			${ECHO_MSG} "===> Extraction failed unexpectedly."; \
 			(${ECHO_CMD} "${BUILD_FAIL_MESSAGE}") | ${FMT_80} ; \
 			fi; \
 		${FALSE}; \
 		fi)
-.  endif
 
 .  if !target(do-build)
 do-build: