/[gentoo-x86]/eclass/haskell-cabal.eclass
Gentoo

Diff of /eclass/haskell-cabal.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.46 Revision 1.47
1# Copyright 1999-2014 Gentoo Foundation 1# Copyright 1999-2015 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.46 2014/06/27 07:26:18 slyfox Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.47 2015/01/01 21:23:03 slyfox Exp $
4 4
5# @ECLASS: haskell-cabal.eclass 5# @ECLASS: haskell-cabal.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Haskell herd <haskell@gentoo.org> 7# Haskell herd <haskell@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
29# bin -- the package installs binaries 29# bin -- the package installs binaries
30# lib -- the package installs libraries 30# lib -- the package installs libraries
31# nocabaldep -- don't add dependency on cabal. 31# nocabaldep -- don't add dependency on cabal.
32# only used for packages that _must_ not pull the dependency 32# only used for packages that _must_ not pull the dependency
33# on cabal, but still use this eclass (e.g. haskell-updater). 33# on cabal, but still use this eclass (e.g. haskell-updater).
34# ghcdeps -- constraint dependency on package to ghc onces
35# only used for packages that use libghc internally and _must_
36# not pull upper versions
34# test-suite -- add support for cabal test-suites (introduced in Cabal-1.8) 37# test-suite -- add support for cabal test-suites (introduced in Cabal-1.8)
35 38
36inherit eutils ghc-package multilib multiprocessing 39inherit eutils ghc-package multilib multiprocessing
37 40
38# @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS 41# @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS
59# @DESCRIPTION: 62# @DESCRIPTION:
60# Show debug output for 'cabal_chdeps' function if set. 63# Show debug output for 'cabal_chdeps' function if set.
61# Needs working 'diff'. 64# Needs working 'diff'.
62: ${CABAL_DEBUG_LOOSENING:=} 65: ${CABAL_DEBUG_LOOSENING:=}
63 66
64HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" 67HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install pkg_postinst pkg_postrm"
65 68
66# 'dev-haskell/cabal' passes those options with ./configure-based 69# 'dev-haskell/cabal' passes those options with ./configure-based
67# configuration, but most packages don't need/don't accept it: 70# configuration, but most packages don't need/don't accept it:
68# #515362, #515362 71# #515362, #515362
69QA_CONFIGURE_OPTIONS+=" --with-compiler --with-hc --with-hc-pkg --with-gcc" 72QA_CONFIGURE_OPTIONS+=" --with-compiler --with-hc --with-hc-pkg --with-gcc"
87 profile) CABAL_USE_PROFILE=yes;; 90 profile) CABAL_USE_PROFILE=yes;;
88 bootstrap) CABAL_BOOTSTRAP=yes;; 91 bootstrap) CABAL_BOOTSTRAP=yes;;
89 bin) CABAL_HAS_BINARIES=yes;; 92 bin) CABAL_HAS_BINARIES=yes;;
90 lib) CABAL_HAS_LIBRARIES=yes;; 93 lib) CABAL_HAS_LIBRARIES=yes;;
91 nocabaldep) CABAL_FROM_GHC=yes;; 94 nocabaldep) CABAL_FROM_GHC=yes;;
95 ghcdeps) CABAL_GHC_CONSTRAINT=yes;;
92 test-suite) CABAL_TEST_SUITE=yes;; 96 test-suite) CABAL_TEST_SUITE=yes;;
93 *) CABAL_UNKNOWN="${CABAL_UNKNOWN} ${feature}";; 97 *) CABAL_UNKNOWN="${CABAL_UNKNOWN} ${feature}";;
94 esac 98 esac
95done 99done
96 100
102fi 106fi
103 107
104if [[ -n "${CABAL_USE_HSCOLOUR}" ]]; then 108if [[ -n "${CABAL_USE_HSCOLOUR}" ]]; then
105 IUSE="${IUSE} hscolour" 109 IUSE="${IUSE} hscolour"
106 DEPEND="${DEPEND} hscolour? ( dev-haskell/hscolour )" 110 DEPEND="${DEPEND} hscolour? ( dev-haskell/hscolour )"
111fi
112
113if [[ -n "${CABAL_USE_HOOGLE}" ]]; then
114 # enabled only in ::gentoo-haskell
115 :
107fi 116fi
108 117
109if [[ -n "${CABAL_USE_ALEX}" ]]; then 118if [[ -n "${CABAL_USE_ALEX}" ]]; then
110 DEPEND="${DEPEND} dev-haskell/alex" 119 DEPEND="${DEPEND} dev-haskell/alex"
111fi 120fi
146 if [[ "${CABAL_BOOTSTRAP}" ]]; then 155 if [[ "${CABAL_BOOTSTRAP}" ]]; then
147 # We're bootstrapping cabal, so the cabal version is the version 156 # We're bootstrapping cabal, so the cabal version is the version
148 # of this package itself. 157 # of this package itself.
149 _CABAL_VERSION_CACHE="${PV}" 158 _CABAL_VERSION_CACHE="${PV}"
150 elif [[ "${CABAL_FROM_GHC}" ]]; then 159 elif [[ "${CABAL_FROM_GHC}" ]]; then
151 local cabal_package=$(echo "$(ghc-libdir)"/Cabal-*) 160 _CABAL_VERSION_CACHE="$(ghc-cabal-version)"
152 # /path/to/ghc/Cabal-${VER} -> ${VER}
153 _CABAL_VERSION_CACHE="${cabal_package/*Cabal-/}"
154 else 161 else
155 # We ask portage, not ghc, so that we only pick up 162 # We ask portage, not ghc, so that we only pick up
156 # portage-installed cabal versions. 163 # portage-installed cabal versions.
157 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)" 164 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)"
158 fi 165 fi
235 set -- haddock "$@" 242 set -- haddock "$@"
236 echo ./setup "$@" 243 echo ./setup "$@"
237 ./setup "$@" || die "setup haddock failed" 244 ./setup "$@" || die "setup haddock failed"
238} 245}
239 246
247cabal-hoogle() {
248 ewarn "hoogle USE flag requires doc USE flag, building without hoogle"
249}
250
240cabal-hscolour-haddock() { 251cabal-hscolour-haddock() {
241 # --hyperlink-source implies calling 'setup hscolour' 252 # --hyperlink-source implies calling 'setup hscolour'
242 set -- haddock --hyperlink-source 253 set -- haddock --hyperlink-source
243 echo ./setup "$@" 254 echo ./setup "$@"
244 ./setup "$@" --hyperlink-source || die "setup haddock --hyperlink-source failed" 255 ./setup "$@" --hyperlink-source || die "setup haddock --hyperlink-source failed"
256}
257
258cabal-hoogle-haddock() {
259 set -- haddock --hoogle
260 echo ./setup "$@"
261 ./setup "$@" || die "setup haddock --hoogle failed"
262}
263
264cabal-hoogle-hscolour-haddock() {
265 cabal-hscolour-haddock
266 cabal-hoogle-haddock
267}
268
269cabal-hoogle-hscolour() {
270 ewarn "hoogle USE flag requires doc USE flag, building without hoogle"
271 cabal-hscolour
245} 272}
246 273
247cabal-die-if-nonempty() { 274cabal-die-if-nonempty() {
248 local breakage_type=$1 275 local breakage_type=$1
249 shift 276 shift
301 if [[ -n "${CABAL_USE_CPPHS}" ]]; then 328 if [[ -n "${CABAL_USE_CPPHS}" ]]; then
302 cabalconf+=(--with-cpphs=${EPREFIX}/usr/bin/cpphs) 329 cabalconf+=(--with-cpphs=${EPREFIX}/usr/bin/cpphs)
303 fi 330 fi
304 if [[ -n "${CABAL_TEST_SUITE}" ]]; then 331 if [[ -n "${CABAL_TEST_SUITE}" ]]; then
305 cabalconf+=($(use_enable test tests)) 332 cabalconf+=($(use_enable test tests))
333 fi
334
335 if [[ -n "${CABAL_GHC_CONSTRAINT}" ]]; then
336 cabalconf+=($(cabal-constraint "ghc"))
306 fi 337 fi
307 338
308 local option 339 local option
309 for option in ${HCFLAGS} 340 for option in ${HCFLAGS}
310 do 341 do
411 # register that ourselves (if it exists). 442 # register that ourselves (if it exists).
412 443
413 if [[ -n ${CABAL_HAS_LIBRARIES} ]]; then 444 if [[ -n ${CABAL_HAS_LIBRARIES} ]]; then
414 # Newer cabal can generate a package conf for us: 445 # Newer cabal can generate a package conf for us:
415 ./setup register --gen-pkg-config="${T}/${P}.conf" 446 ./setup register --gen-pkg-config="${T}/${P}.conf"
416 ghc-setup-pkg "${T}/${P}.conf" 447 ghc-install-pkg "${T}/${P}.conf"
417 ghc-install-pkg
418 fi 448 fi
419} 449}
420 450
421# Some cabal libs are bundled along with some versions of ghc 451# Some cabal libs are bundled along with some versions of ghc
422# eg filepath-1.0 comes with ghc-6.6.1 452# eg filepath-1.0 comes with ghc-6.6.1
485 has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@" 515 has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@"
486 cabal-build 516 cabal-build
487 517
488 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 518 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
489 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then 519 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then
520 if [[ -n "${CABAL_USE_HOOGLE}" ]] && use hoogle; then
490 # hscolour and haddock 521 # hoogle, hscolour and haddock
522 cabal-hoogle-hscolour-haddock
523 else
524 # haddock and hscolour
491 cabal-hscolour-haddock 525 cabal-hscolour-haddock
526 fi
492 else 527 else
528 if [[ -n "${CABAL_USE_HOOGLE}" ]] && use hoogle; then
529 # hoogle and haddock
530 cabal-hoogle-haddock
531 else
493 # just haddock 532 # just haddock
494 cabal-haddock 533 cabal-haddock
534 fi
495 fi 535 fi
496 else 536 else
497 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then 537 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then
538 if [[ -n "${CABAL_USE_HOOGLE}" ]] && use hoogle; then
539 # hoogle and hscolour
540 cabal-hoogle-hscolour
541 else
498 # just hscolour 542 # just hscolour
499 cabal-hscolour 543 cabal-hscolour
544 fi
545 else
546 if [[ -n "${CABAL_USE_HOOGLE}" ]] && use hoogle; then
547 # just hoogle
548 cabal-hoogle
549 fi
500 fi 550 fi
501 fi 551 fi
502} 552}
503 553
504haskell-cabal_src_compile() { 554haskell-cabal_src_compile() {
536 # create a dummy local package conf file for haskell-updater 586 # create a dummy local package conf file for haskell-updater
537 # if it does not exist (dummy libraries and binaries w/o libraries) 587 # if it does not exist (dummy libraries and binaries w/o libraries)
538 local ghc_confdir_with_prefix="$(ghc-confdir)" 588 local ghc_confdir_with_prefix="$(ghc-confdir)"
539 # remove EPREFIX 589 # remove EPREFIX
540 dodir ${ghc_confdir_with_prefix#${EPREFIX}} 590 dodir ${ghc_confdir_with_prefix#${EPREFIX}}
541 local conf_file="${D}/$(ghc-confdir)/$(ghc-localpkgconf)" 591 local hint_db="${D}/$(ghc-confdir)"
542 [[ -e $conf_file ]] || echo '[]' > "$conf_file" || die 592 local hint_file="${hint_db}/${PF}.conf"
543 593 mkdir -p "${hint_db}" || die
544 # make sure installed packages do not destroy ghc's 594 touch "${hint_file}" || die
545 # bundled packages
546 local initial_pkg_db=${ROOT}/$(ghc-libdir)/package.conf.d.initial
547 if [[ -e ${initial_pkg_db} ]]; then
548 local checked_pkg
549 for checked_pkg in $(ghc-listpkg "${conf_file}")
550 do
551 local initial_pkg
552 for initial_pkg in $(ghc-listpkg "${initial_pkg_db}"); do
553 if [[ ${checked_pkg} = ${initial_pkg} ]]; then
554 eerror "Package ${checked_pkg} is shipped with $(ghc-version)."
555 eerror "Ebuild author forgot CABAL_CORE_LIB_GHC_PV entry."
556 eerror "Found in ${initial_pkg_db}."
557 die
558 fi
559 done
560 done
561 fi
562} 595}
563 596
564haskell-cabal_src_install() { 597haskell-cabal_src_install() {
565 pushd "${S}" > /dev/null 598 pushd "${S}" > /dev/null
566 599
567 cabal_src_install 600 cabal_src_install
568 601
569 popd > /dev/null 602 popd > /dev/null
603}
604
605haskell-cabal_pkg_postinst() {
606 ghc-package_pkg_postinst
607}
608
609haskell-cabal_pkg_postrm() {
610 ghc-package_pkg_postrm
570} 611}
571 612
572# @FUNCTION: cabal_flag 613# @FUNCTION: cabal_flag
573# @DESCRIPTION: 614# @DESCRIPTION:
574# ebuild.sh:use_enable() taken as base 615# ebuild.sh:use_enable() taken as base
664 705
665 echo "${new_c}" > "$cf" || 706 echo "${new_c}" > "$cf" ||
666 die "failed to update" 707 die "failed to update"
667} 708}
668 709
710# @FUNCTION: cabal-constraint
711# @DESCRIPTION:
712# Allowes to set contraint to the libraries that are
713# used by specified package
714cabal-constraint() {
715 while read p v ; do
716 echo "--constraint \"$p == $v\""
717 done < $(ghc-pkgdeps ${1})
718}
719
669# @FUNCTION: replace-hcflags 720# @FUNCTION: replace-hcflags
670# @USAGE: <old> <new> 721# @USAGE: <old> <new>
671# @DESCRIPTION: 722# @DESCRIPTION:
672# Replace the <old> flag with <new> in HCFLAGS. Accepts shell globs for <old>. 723# Replace the <old> flag with <new> in HCFLAGS. Accepts shell globs for <old>.
673# The implementation is picked from flag-o-matic.eclass:replace-flags() 724# The implementation is picked from flag-o-matic.eclass:replace-flags()

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.20