Skip to content

Commit

Permalink
haskell-cabal.eclass: add basic support for ROOT!=/, bug #534194
Browse files Browse the repository at this point in the history
Reported-by: Dennis Schridde
Bug: https://bugs.gentoo.org/534194
Signed-off-by: Sergei Trofimovich <[email protected]>
  • Loading branch information
Sergei Trofimovich committed May 31, 2016
1 parent 1b1ccef commit 2db4176
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
12 changes: 11 additions & 1 deletion eclass/ghc-package.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ ghc-getghcpkgbin() {
fi
}

# @FUNCTION: ghc-host-prefix
# @DESCRIPTION:
# Returns root of installed ghc.
# Some helpers (like best_version) require reference
# host system as they are tied to compiler bing executed.
ghc-host-root() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
echo "${EPREFIX}/"
}

# @FUNCTION: ghc-version
# @DESCRIPTION:
# returns upstream version of ghc
Expand All @@ -85,7 +95,7 @@ ghc-pm-version() {
local pm_ghc_p

if [[ -z "${_GHC_PM_VERSION_CACHE}" ]]; then
pm_ghc_p=$(best_version dev-lang/ghc)
pm_ghc_p=$(ROOT=$(ghc-host-root) best_version dev-lang/ghc)
_GHC_PM_VERSION_CACHE="PM:${pm_ghc_p#dev-lang/ghc-}"
fi
echo "${_GHC_PM_VERSION_CACHE}"
Expand Down
26 changes: 22 additions & 4 deletions eclass/haskell-cabal.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ inherit eutils ghc-package multilib multiprocessing
# linking 'setup' faster.
: ${GHC_BOOTSTRAP_FLAGS:=}

# @ECLASS-VARIABLE: CABAL_EXTRA_TEST_FLAGS
# @DESCRIPTION:
# User-specified additional parameters passed to 'setup test'.
# example: /etc/portage/make.conf:
# CABAL_EXTRA_TEST_FLAGS="-v3 --show-details=streaming"
: ${CABAL_EXTRA_TEST_FLAGS:=}

# @ECLASS-VARIABLE: CABAL_DEBUG_LOOSENING
# @DESCRIPTION:
# Show debug output for 'cabal_chdeps' function if set.
Expand Down Expand Up @@ -118,8 +125,7 @@ if [[ -n "${CABAL_USE_HSCOLOUR}" ]]; then
fi

if [[ -n "${CABAL_USE_HOOGLE}" ]]; then
# enabled only in ::haskell
CABAL_USE_HOOGLE=
IUSE="${IUSE} hoogle"
fi

if [[ -n "${CABAL_USE_ALEX}" ]]; then
Expand Down Expand Up @@ -169,7 +175,7 @@ cabal-version() {
else
# We ask portage, not ghc, so that we only pick up
# portage-installed cabal versions.
_CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)"
_CABAL_VERSION_CACHE="$(ROOT=$(ghc-host-root) ghc-extractportageversion dev-haskell/cabal)"
fi
fi
echo "${_CABAL_VERSION_CACHE}"
Expand Down Expand Up @@ -602,13 +608,25 @@ haskell-cabal_src_compile() {
}

haskell-cabal_src_test() {
local cabaltest=()

pushd "${S}" > /dev/null || die

if cabal-is-dummy-lib; then
einfo ">>> No tests for dummy library: ${CATEGORY}/${PF}"
else
einfo ">>> Test phase [cabal test]: ${CATEGORY}/${PF}"
set -- test "$@"

# '--show-details=streaming' appeared in Cabal-1.20
if ./setup test --help | grep -q -- "'streaming'"; then
cabaltest+=(--show-details=streaming)
fi

set -- test \
"${cabaltest[@]}" \
${CABAL_TEST_FLAGS} \
${CABAL_EXTRA_TEST_FLAGS} \
"$@"
echo ./setup "$@"
./setup "$@" || die "cabal test failed"
fi
Expand Down

0 comments on commit 2db4176

Please sign in to comment.