git: 606b37bbf06d - main - Mk/Uses: make it possible to compile gems that need rust to build
Date: Tue, 09 Jan 2024 12:13:07 UTC
The branch main has been updated by mfechner:
URL: https://cgit.FreeBSD.org/ports/commit/?id=606b37bbf06dcdfb54480aae8fb69135c06fb11a
commit 606b37bbf06dcdfb54480aae8fb69135c06fb11a
Author: Matthias Fechner <mfechner@FreeBSD.org>
AuthorDate: 2024-01-09 12:04:24 +0000
Commit: Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-01-09 12:12:47 +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 cargo.mk.
The gem.mk 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
/usr/local/poudriere/ports/gitlab/distfiles/*.gem
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
---
Mk/Uses/gem.mk | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/Mk/Uses/gem.mk b/Mk/Uses/gem.mk
index a1e77273932a..8c4539a274ca 100644
--- a/Mk/Uses/gem.mk
+++ b/Mk/Uses/gem.mk
@@ -24,8 +24,8 @@ IGNORE= Incorrect 'USES+= gem:${gem_ARGS}' usage: argument [${arg}] is not recog
PKGNAMEPREFIX?= rubygem-
EXTRACT_SUFX= .gem
-EXTRACT_ONLY=
-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
+#EXTRACT_ONLY?=
BUILD_DEPENDS+= ${RUBYGEMBIN}:devel/ruby-gems
EXTRACT_DEPENDS+= ${RUBYGEMBIN}:devel/ruby-gems
@@ -67,10 +67,20 @@ PLIST_SUB+= PORTVERSION="${PORTVERSION}" \
RUBYGEMBIN= ${LOCALBASE}/bin/gem
+. 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
+#DIST_SUBDIR=
+. else
+DIST_SUBDIR= rubygem
+. endif
+
. if defined(DISTFILES)
-GEMFILES= ${DISTFILES:C/:[^:]+$//}
+# 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
-GEMFILES= ${DISTNAME}${EXTRACT_SUFX}
+GEMFILES?= ${DISTNAME}${EXTRACT_SUFX}
. 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)
-do-extract:
+_USES_extract+= 590:gem-extract
+gem-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 \
if [ -n "${BUILD_FAIL_MESSAGE}" ] ; then \
@@ -91,7 +101,6 @@ do-extract:
fi; \
${FALSE}; \
fi)
-. endif
. if !target(do-build)
do-build: