Building individual programs

allan a.d.clark at
Fri Apr 6 09:00:59 EDT 2007

Dear all

I have a cabal package which defines in the cabal package several 
programs to be built such as:

Executable:      prog1
Main-is:         examples/Prog1.hs
Ghc-options:     -Wall

Executable:      prog2
Main-is:         examples/Prog2.hs
Ghc-options:     -Wall

It's actually a library and the individual programs are a bunch of 
examples. When I work on one of these individually it's mildly annoying that
runhaskell Setup.hs build

builds all of them. I'd quite like to be able to do something like:
runhaskell Setup.hs build prog1
or even just
runhaskell Setup.hs prog1

to build only the first example.

I know about the "Buildable" field in the cabal file, but I was kind of 
hoping there was a way to do this such that the cabal file doesn't need 
to be continually modified (and runhaskell Setup.hs configure --..... 

So is there a (standard) way to do this?
If not, I suppose the best way to do it would be in the Setup.hs file, 
ie could do something like:

processArgs :: [ String ] -> IO ()
processArgs [ "prog1" ]  = <Something to build prog1 with all the 
configuration information>  
processArgs _           = defaultMainWithHooks myHooks

if this is the best way, what should I have in the <Something .. > bit?


More information about the cabal-devel mailing list