git: 4ad8bbf22f2b - main - Uses/cabal.mk: Use cabal2tuple in the make-use-cabal target.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Jul 2022 14:56:47 UTC
The branch main has been updated by arrowd: URL: https://cgit.FreeBSD.org/ports/commit/?id=4ad8bbf22f2b9aaa79caccba7559b058245e12a7 commit 4ad8bbf22f2b9aaa79caccba7559b058245e12a7 Author: Gleb Popov <arrowd@FreeBSD.org> AuthorDate: 2022-07-16 11:56:49 +0000 Commit: Gleb Popov <arrowd@FreeBSD.org> CommitDate: 2022-07-27 14:55:49 +0000 Uses/cabal.mk: Use cabal2tuple in the make-use-cabal target. --- Mk/Uses/cabal.mk | 71 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/Mk/Uses/cabal.mk b/Mk/Uses/cabal.mk index 3abd74489fac..dd7f0d917dbe 100644 --- a/Mk/Uses/cabal.mk +++ b/Mk/Uses/cabal.mk @@ -66,6 +66,8 @@ PKGNAMEPREFIX?= hs- EXECUTABLES?= ${PORTNAME} +CABAL_CMD?= cabal +CABAL_PORT= devel/hs-cabal-install CABAL_HOME= ${WRKDIR}/cabal-home CABAL_LIBEXEC= libexec/cabal CABAL_EXTRACT_SUFX= .tar.gz @@ -73,6 +75,9 @@ CABAL_ARCH= ${ARCH:S/amd64/x86_64/:C/armv.*/arm/:S/powerpc64/ppc64/} CABAL_DEPSDIR= ${WRKSRC}/${CABAL_DEPS_SUBDIR} CABAL_DEPS_SUBDIR= _cabal_deps +HPACK_CMD?= hpack +_CABAL2TUPLE_CMD= cabal2tuple + . if defined(BUILD_DEPENDS) && ${BUILD_DEPENDS:Mghc?*\:lang/ghc?*} CABAL_WITH_ARGS= --with-compiler=${BUILD_DEPENDS:Mghc?*\:lang/ghc?*:C/\:.*//} \ --with-hsc2hs=${LOCALBASE}/bin/hsc2hs-${BUILD_DEPENDS:Mghc?*\:lang/ghc?*:C/\:.*//} @@ -81,16 +86,14 @@ BUILD_DEPENDS+= ghc:lang/ghc . endif . if !defined(CABAL_BOOTSTRAP) -BUILD_DEPENDS+= cabal:devel/hs-cabal-install +BUILD_DEPENDS+= cabal:${CABAL_PORT} . endif . if ${cabal_ARGS:Mhpack} EXTRACT_DEPENDS+= hpack:devel/hs-hpack . endif -# Inherited via lang/ghc we need to depend on iconv and libgmp.so (stage q/a) -iconv_ARGS= translit -.include "${USESDIR}/iconv.mk" +# Inherited via lang/ghc we need to depend on libffi.so and libgmp.so (stage q/a) LIB_DEPENDS+= libgmp.so:math/gmp \ libffi.so:devel/libffi @@ -152,50 +155,50 @@ DISTFILES+= ${package:C/_[0-9]+//}/revision/${package:C/[^_]*//:S/_//}.cabal:${p # Auxiliary targets used during port creation/updating. # Fetches and unpacks package source from Hackage using only PORTNAME and PORTVERSION. -cabal-extract: ${WRKDIR} +cabal-extract: check-cabal ${WRKDIR} + @${ECHO_MSG} "===> Fetching Cabal package index into ${CABAL_HOME}/.cabal" ${RM} -rf ${CABAL_HOME}/.cabal - ${SETENV} HOME=${CABAL_HOME} cabal new-update + ${SETENV} HOME=${CABAL_HOME} ${CABAL_CMD} update . if ${_hackage_is_default} == yes cd ${WRKDIR} && \ - ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} cabal get ${PORTNAME}-${PORTVERSION} + ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} get ${PORTNAME}-${PORTVERSION} . else ${MV} ${CABAL_HOME} /tmp/${PORTNAME}-cabal-home cd ${.CURDIR} && ${MAKE} extract CABAL_BOOTSTRAP=yes ${RM} -rf ${CABAL_HOME} ${MV} /tmp/${PORTNAME}-cabal-home ${CABAL_HOME} -. endif - -# Fetches and unpacks dependencies sources for a cabal-extract'ed package. -# Builds them as side-effect. -. if !target(cabal-extract-deps) -cabal-extract-deps: . if ${cabal_ARGS:Mhpack} - cd ${WRKSRC} && ${SETENV} HOME=${CABAL_HOME} hpack + @${ECHO_MSG} "===> Running ${HPACK_CMD} to generate .cabal file" + cd ${WRKSRC} && ${SETENV} HOME=${CABAL_HOME} ${HPACK_CMD} . endif +. endif + +# Calls cabal configure on the Haskell package located in ${WRKSRC} +cabal-configure: check-cabal cd ${WRKSRC} && \ - ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} cabal new-configure --disable-benchmarks --disable-tests --flags="${CABAL_FLAGS}" ${CABAL_WITH_ARGS} ${CONFIGURE_ARGS} + ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} configure --disable-benchmarks --disable-tests --flags="${CABAL_FLAGS}" ${CABAL_WITH_ARGS} ${CONFIGURE_ARGS} + +# Calls cabal build on the Haskell package located in ${WRKSRC} +cabal-build: check-cabal cd ${WRKSRC} && \ - ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} cabal new-build --disable-benchmarks --disable-tests --dependencies-only ${CABAL_WITH_ARGS} ${BUILD_ARGS} ${BUILD_TARGET} -. endif + ${SETENV} ${LOCALE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} build --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} ${BUILD_ARGS} ${BUILD_TARGET} -# Generates USE_CABAL= ... line ready to be pasted into the port based on artifacts of cabal-extract-deps. -make-use-cabal: - @echo ==================== - @echo -n USE_CABAL= - @find ${CABAL_HOME} -name '*.conf' -exec basename {} + | sed -E 's|-[0-9a-z]{64}\.conf||' | sort | sed 's/$$/ \\/' - @find ${CABAL_HOME} -name 'hsc2hs*.tar.gz' -exec basename {} + | sed -E 's|\.tar\.gz||' | sed 's/$$/ \\/' - @find ${CABAL_HOME} -name 'alex*.tar.gz' -exec basename {} + | sed -E 's|\.tar\.gz||' | sed 's/$$/ \\/' - @find ${CABAL_HOME} -name 'happy*.tar.gz' -exec basename {} + | sed -E 's|\.tar\.gz||' | sed 's/$$/ \\/' - -# Re-generates USE_CABAL items to have revision numbers. -make-use-cabal-revs: -. for package in ${_use_cabal} - @(${SETENV} HTTP_ACCEPT="application/json" fetch -q -o - http://hackage.haskell.org/package/${package:C/_[0-9]+//}/revisions/ | python3 -c "import sys, json; print(('${package:C/_[0-9]+//}_' + str(json.load(sys.stdin)[-1]['number'])).replace('_0',''), end='')") - @echo ' \' -. endfor +# 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) -. if !defined(CABAL_BOOTSTRAP) +check-cabal: + @if ! type ${CABAL_CMD} > /dev/null 2>&1; then \ + ${ECHO_MSG} "===> cabal executable not found, install ${CABAL_PORT} or set CABAL_CMD"; exit 1; \ + fi; \ + +check-cabal2tuple: + @if ! type ${_CABAL2TUPLE_CMD} > /dev/null 2>&1; then \ + ${ECHO_MSG} "===> cabal2tuple executable not found, install \"ports-mgmt/hs-cabal2tuple\""; exit 1; \ + fi +. if !defined(CABAL_BOOTSTRAP) # Main targets implementation. cabal-post-extract: @@ -245,7 +248,7 @@ cabal-pre-configure: . if !target(do-build) do-build: cd ${WRKSRC} && \ - ${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} cabal new-build --offline --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} --flags "${CABAL_FLAGS}" ${BUILD_ARGS} ${BUILD_TARGET} + ${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} ${CABAL_CMD} new-build --offline --disable-benchmarks --disable-tests ${CABAL_WITH_ARGS} --flags "${CABAL_FLAGS}" ${BUILD_ARGS} ${BUILD_TARGET} . endif . if !target(do-install)