[Haskell] RE: OS-dependent cabal file selection

Simon Marlow simonmar at microsoft.com
Fri Jun 16 07:56:15 EDT 2006


On 16 June 2006 12:27, Bulat Ziganshin wrote:

> 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

This is fine for now, but the drawback of both of these solutions is
that external tools can't collect information about the package by
reading the .cabal file.  The Win32 dependency won't show up if you load
the .cabal file into Visual Haskell, for example.

Cheers,
	Simon


More information about the Haskell mailing list