John Millikin  committed b2d5461

Add a "gtk" flag to Criterion's .cabal file

By enabling charts but disabling GTK+ support, users can generate
useful charts without dragging in all of gtk2hs. This makes it much
easier to use in automated build environments, which might not have
GTK+ or X11 development libraries installed.

  • Participants
  • Parent commits 69c2b38

Comments (0)

Files changed (2)

File Criterion/Plot.hs

 import System.IO (IOMode(..), Handle, hPutStr, withBinaryFile)
 import Text.Printf (printf)
 import qualified Criterion.MultiMap as M
+import Criterion.IO (printError)
 #ifdef HAVE_CHART
 import Data.Accessor ((^=))
 import Graphics.Rendering.Chart hiding (Plot,c)
+#ifdef HAVE_GTK
 import Graphics.Rendering.Chart.Gtk (renderableToWindow)
-import Criterion.IO (printError)
 plotWith :: Plot -> (PlotOutput -> IO ()) -> Criterion ()
   renderableToSVGFile (renderTiming desc times) x y
                       (mangle $ printf "%s timings %dx%d.svg" desc x y)
+#ifdef HAVE_GTK
 plotTiming (Window x y) desc times =
   renderableToWindow (renderTiming desc times) x y
 plotTiming output _desc _times =
   printError "ERROR: output type %s not supported on this platform\n"
              (show output)
 -- | Plot kernel density estimate.
 plotKDE :: PlotOutput           -- ^ The kind of output desired.
   renderableToSVGFile (renderKDE desc exs points pdf) x y
                       (mangle $ printf "%s densities %dx%d.svg" desc x y)
+#ifdef HAVE_GTK
 plotKDE (Window x y) desc exs points pdf =
     renderableToWindow (renderKDE desc exs points pdf) x y
 plotKDE output _desc _exs _points _pdf =
   printError "ERROR: output type %s not supported on this platform\n"
              (show output)
 #ifdef HAVE_CHART
 renderTiming :: String -> Sample -> Renderable ()

File criterion.cabal

   -- Broken under GHC 6.12 so far.
   default: False
+flag gtk
+  description: enable displaying charts in GTK+ windows
+  default: False
   if flag(chart)
-      Chart >= 0.13 && < 0.14,
+      Chart >= 0.13 && < 0.15,
     cpp-options: -DHAVE_CHART
+  if flag(gtk)
+    cpp-options: -DHAVE_GTK
   -- gather extensive profiling data for now
   ghc-prof-options: -auto-all