[Haskell] Re: OS-dependent cabal file selection

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Jun 16 07:26:49 EDT 2006


Hello Bulat,

Friday, June 16, 2006, 11:19:08 AM, you wrote:

>>> btw, my cabal file contain line:
>>> 
>>> Build-Depends:      base, Win32, template-haskell
>>> 
>>> if i correctly understand, this will not work on unix systems, while
>>> without Win32 package program can't be compiled on my windows box.

sorry if i overfill mail list, but that is another solution, that
don't contain hard-wired name of "Streams.cabal" file and don't
require two separate cabal files - one for windows and one for unix.
instead, it just use the default cabal file and adds "Win32" package
to the list of used packages if we are running windows box:

#!/usr/bin/runhaskell

import qualified System.Info
import Data.List
import Distribution.Simple
import Distribution.Simple.Utils
import Distribution.PackageDescription

main = do pkg_descr_file <- defaultPackageDesc
          pkg_descr      <- readPackageDescription pkg_descr_file
          let isWindows = "mingw" `isPrefixOf` System.Info.os
              config = if isWindows
                         then pkg_descr { buildDepends = Dependency "Win32" AnyVersion
                                                       : buildDepends pkg_descr }
                         else pkg_descr
          defaultMainNoRead config


i hope that it will be useful for other developers

p.s. for language lawyers: the code is in public domain


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell mailing list