Commit 1adec4be authored by Iustin Pop's avatar Iustin Pop

htools: add a compatibility module

When compiling with the parallel-3.x library, we get a deprecation
warning, which makes understanding any other error messages
harder. This patch adds a compatibility module that will hold such
code for transitioning libraries.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent a5f248ac
......@@ -324,6 +324,7 @@ HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC \
HS_LIB_SRCS = \
htools/Ganeti/HTools/CLI.hs \
htools/Ganeti/HTools/Cluster.hs \
htools/Ganeti/HTools/Compat.hs \
htools/Ganeti/HTools/Container.hs \
htools/Ganeti/HTools/ExtLoader.hs \
htools/Ganeti/HTools/Group.hs \
......@@ -462,7 +463,8 @@ $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
exit 1; \
fi
BINARY=$(@:htools/%=%); $(GHC) --make \
$(HFLAGS) $(HEXTRA) $(HTOOLS_NOCURL) \
$(HFLAGS) $(HEXTRA) \
$(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
-osuf $$BINARY.o -hisuf $$BINARY.hi $@
# for the htools/test binary, we need to enable profiling/coverage
......@@ -1113,6 +1115,9 @@ hs-apidoc: $(HS_BUILT_SRCS)
then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
else OPTGHC=""; \
fi; \
if [ "$(HTOOLS_PARALLEL3)" ]; \
then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
fi; \
RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(HS_BUILT_SRCS:htools/%=%)"; \
for file in $$RELSRCS; do \
hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
......
......@@ -360,8 +360,10 @@ else
AC_SUBST(HTOOLS_NOCURL)
AC_MSG_CHECKING([parallel])
GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-3.*')
if test -z "$GHC_PKG_PARALLEL"
if test -n "$GHC_PKG_PARALLEL"
then
HTOOLS_PARALLEL3=-DPARALLEL3
else
GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-2.*')
fi
if test -z "$GHC_PKG_PARALLEL"
......@@ -369,6 +371,7 @@ else
GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-1.*')
fi
AC_SUBST(GHC_PKG_PARALLEL)
AC_SUBST(HTOOLS_PARALLEL3)
AC_MSG_RESULT($GHC_PKG_PARALLEL)
AC_MSG_CHECKING([json])
GHC_PKG_JSON=$($GHC_PKG latest json)
......
......@@ -82,7 +82,6 @@ import Data.Maybe (fromJust)
import Data.Ord (comparing)
import Text.Printf (printf)
import Control.Monad
import Control.Parallel.Strategies
import qualified Ganeti.HTools.Container as Container
import qualified Ganeti.HTools.Instance as Instance
......@@ -90,6 +89,7 @@ import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Group as Group
import Ganeti.HTools.Types
import Ganeti.HTools.Utils
import Ganeti.HTools.Compat
import qualified Ganeti.OpCodes as OpCodes
-- * Types
......
{-# LANGUAGE CPP #-}
{- | Compatibility helper module.
This module holds definitions that help with supporting multiple library versions or transitions between versions.
-}
{-
Copyright (C) 2011 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
-}
module Ganeti.HTools.Compat
( rwhnf
, Control.Parallel.Strategies.parMap
) where
import qualified Control.Parallel.Strategies
rwhnf :: Control.Parallel.Strategies.Strategy a
#ifdef PARALLEL3
rwhnf = Control.Parallel.Strategies.rseq
#else
rwhnf = Control.Parallel.Strategies.rwhnf
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment