summaryrefslogtreecommitdiff
path: root/Mk
diff options
context:
space:
mode:
authorGleb Popov <arrowd@FreeBSD.org>2022-11-20 19:35:05 +0300
committerGleb Popov <arrowd@FreeBSD.org>2022-11-20 20:39:29 +0300
commit934c0a2d759fe09a92739e4ed84e154b6d8e1970 (patch)
tree53f739160a2a9279f7b6a5f952af4d18ea17c82c /Mk
parentb203b2caf8ac5b26183cfec11c2c08252145c688 (diff)
downloadfreebsd-ports-934c0a2d759fe09a92739e4ed84e154b6d8e1970.zip
Uses/cabal.mk: Add support for building multi-repository cabal.projects.
To build such projects a port must add the repository to MASTER_SITES under some group and then use this group in USE_CABAL. Cabal2Tuple (ports-mgmt/hs-cabal2tuple) supports this feature starting with version 2.0. Running `make make-use-cabal` will automatically pass necessary flags to it.
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Uses/cabal.mk45
1 files changed, 34 insertions, 11 deletions
diff --git a/Mk/Uses/cabal.mk b/Mk/Uses/cabal.mk
index 7d2aafc1534a..27237bde3974 100644
--- a/Mk/Uses/cabal.mk
+++ b/Mk/Uses/cabal.mk
@@ -145,12 +145,21 @@ BUILD_TARGET?= ${CABAL_EXECUTABLES:S/^/exe:&/}
_use_cabal= ${USE_CABAL:O:u}
. for package in ${_use_cabal}
-. for pkg_name xrev in ${package:C/_[0-9]+//} x${package:C/[^_]*//:S/_//}
+. for pkg_without_group xgroup in ${package:C/:.*$$//} x${package:S/${package:C/:.*$$//}//:C/^.*://}
+. for pkg_name xrev in ${pkg_without_group:C/_[0-9]+//} x${pkg_without_group:C/[^_]*//:S/_//}
+. if ${xgroup} == "x"
DISTFILES+= ${pkg_name}/${pkg_name}${CABAL_EXTRACT_SUFX}${_hackage_group}
-. if ${xrev} != "x"
-DISTFILES+= ${pkg_name}/revision/${xrev:S/x//}.cabal${_hackage_group}
-. endif
+. if ${xrev} != "x"
+DISTFILES+= ${pkg_name}/revision/${xrev:S/^x//}.cabal${_hackage_group}
+. endif
+. else
+DISTFILES+= ${pkg_name}${CABAL_EXTRACT_SUFX}:${xgroup:S/^x//}
+. if ${xrev} != "x"
+DISTFILES+= ${pkg_name}/revision/${xrev:S/^x//}.cabal:${xgroup:S/^x//}
+. endif
+. endif # ${xgroup} == "x"
_CABAL_EXTRACT_ONLY+= ${pkg_name}/${pkg_name}${CABAL_EXTRACT_SUFX}
+. endfor
. endfor
. endfor
@@ -162,6 +171,11 @@ EXTRACT_ONLY+= ${_CABAL_EXTRACT_ONLY}
. endif
. endif
+. if defined(CABAL_REPOSITORIES) && !empty(CABAL_REPOSITORIES)
+. for r in ${CABAL_REPOSITORIES}
+CABAL2TUPLE_ARGS+= --group=${r} --master-site=${MASTER_SITES:M*\:${r}:[1]:S/:${r}//}
+. endfor
+. endif
# Auxiliary targets used during port creation/updating.
@@ -175,7 +189,7 @@ cabal-extract: check-cabal
@${MAKE} -C ${.CURDIR} extract SKIP_CABAL_EXTRACT=yes USE_CABAL=
${RM} -rf ${CABAL_HOME}
. endif
- @${ECHO_MSG} "===> Fetching Cabal package index into ${CABAL_HOME}/.cabal"
+ @${ECHO_MSG} "===> Fetching Hackage index into ${CABAL_HOME}/.cabal"
@${SETENV} HOME=${CABAL_HOME} ${CABAL_CMD} update
. if ${_hackage_is_default} == yes
@cd ${WRKDIR} && \
@@ -188,6 +202,11 @@ cabal-extract: check-cabal
. endif
# Remove Haskell dependencies that come from GH_TUPLE
@${RM} -r ${WRKSRC}/dist-newstyle
+. ifdef CABAL_REPOSITORIES
+ @${ECHO_MSG} "===> Fetching additional Cabal repositories index into ${CABAL_HOME}/.cabal"
+ @cd ${WRKSRC} && \
+ ${SETENV} HOME=${CABAL_HOME} ${CABAL_CMD} update
+. endif
# Create a cookie for cabal-post-patch
@${TOUCH} ${EXTRACT_COOKIE} ${CABAL_COOKIE}
@@ -206,7 +225,7 @@ cabal-build: check-cabal
# Generates USE_CABAL= ... line ready to be pasted into the port based on the plan.json file generated by cabal configure.
make-use-cabal: check-cabal2tuple
@${ECHO_MSG} "===> Processing plan.json"
- @${_CABAL2TUPLE_CMD} ${WRKSRC} || (${ECHO_CMD} "Did you forget to make cabal-configure ?" ; exit 1)
+ @${_CABAL2TUPLE_CMD} ${CABAL2TUPLE_ARGS} ${WRKSRC} || (${ECHO_CMD} "Did you forget to make cabal-configure ?" ; exit 1)
. if ${_hackage_is_default} == yes
@if ${GREP} -q 'x-revision' ${WRKSRC}/*.cabal; then \
${ECHO_MSG} "Downloaded .cabal file contains x-revision, make sure to add CABAL_REVISION=" `${GREP} 'x-revision' ${WRKSRC}/*.cabal | ${SED} -e s/x-revision://`; \
@@ -244,14 +263,16 @@ cabal-post-extract:
# Move extracted dependencies into ${CABAL_DEPSDIR} directory
${MKDIR} ${CABAL_DEPSDIR}
. for package in ${_use_cabal}
-. for pkg_name xrev in ${package:C/_[0-9]+//} x${package:C/[^_]*//:S/_//}
+. for pkg_without_group in ${package:C/:.*$$//}
+. for pkg_name xrev in ${pkg_without_group:C/_[0-9]+//} x${pkg_without_group:C/[^_]*//:S/_//}
# Copy revised .cabal file if present
-. if ${xrev} != "x"
- ${CP} ${DISTDIR}/${DIST_SUBDIR}/${pkg_name}/revision/${xrev:S/x//}.cabal `find ${WRKDIR}/${pkg_name} -name '*.cabal' -depth 1`
-. endif
+. if ${xrev} != "x"
+ ${CP} ${DISTDIR}/${DIST_SUBDIR}/${pkg_name}/revision/${xrev:S/^x//}.cabal `find ${WRKDIR}/${pkg_name} -name '*.cabal' -depth 1`
+. endif
# Move the dependency source itself
cd ${WRKDIR} && \
${MV} ${pkg_name} ${CABAL_DEPSDIR}/
+. endfor
. endfor
. endfor
# Create the cabal-install config
@@ -268,8 +289,10 @@ cabal-post-patch:
${ECHO_CMD} "-- added by USES=cabal" >> ${WRKSRC}/cabal.project.local
${ECHO_CMD} "packages:" >> ${WRKSRC}/cabal.project.local
. for package in ${_use_cabal}
-. for pkg_name in ${package:C/_[0-9]+//}
+. for pkg_without_group in ${package:C/:.*$$//}
+. for pkg_name in ${pkg_without_group:C/_[0-9]+//}
${ECHO_CMD} " ${CABAL_DEPS_SUBDIR}/${pkg_name}" >> ${WRKSRC}/cabal.project.local
+. endfor
. endfor
. endfor
. endif # SKIP_CABAL_EXTRACT && !CABAL_COOKIE