From 1adec4be3a01259e75800c93e1749c182b426d64 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 7 Jul 2011 23:00:45 +0200 Subject: [PATCH] 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: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- Makefile.am | 7 +++++- configure.ac | 5 +++- htools/Ganeti/HTools/Cluster.hs | 2 +- htools/Ganeti/HTools/Compat.hs | 42 +++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 htools/Ganeti/HTools/Compat.hs diff --git a/Makefile.am b/Makefile.am index 3c9e9f69f..8efd02790 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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; \ diff --git a/configure.ac b/configure.ac index 1886facd7..75d551375 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 5cb0c8045..2b5a4b895 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -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 diff --git a/htools/Ganeti/HTools/Compat.hs b/htools/Ganeti/HTools/Compat.hs new file mode 100644 index 000000000..2a35d37c6 --- /dev/null +++ b/htools/Ganeti/HTools/Compat.hs @@ -0,0 +1,42 @@ +{-# 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 -- GitLab