[Haskell] OS-dependent cabal file selection

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Jun 16 03:19:08 EDT 2006


Hello Simon,

Friday, June 9, 2006, 7:23:15 PM, 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.
>> what i can do here? only provide two separate cabal files - one for
>> unix, one for windows and give to user text instructions about
>> manual renaming of appropriate file?

> One workaround: your Setup.lhs could distinguish the OS using 
> System.Info, and then invoke the right .cabal file.

i done this, think that this script may be very useful for other
programmers not familiar with Cabal:

#!/usr/bin/runhaskell

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

main = do let isWindows = "mingw" `isPrefixOf` System.Info.os
              cabal = if isWindows
                        then "Streams.cabal.win32"
                        else "Streams.cabal"
          defaultMainNoRead =<< readPackageDescription cabal


may be it can be done better? (more reliable windows detection, more
compatible with various cabal versions)

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



More information about the Haskell mailing list