Cabal and c2hs
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sat Apr 30 13:22:40 EDT 2005
On Saturday 30 Apr 2005 4:17 pm, Isaac Jones wrote:
> Dominic Steinitz <dominic.steinitz at blueyonder.co.uk> writes:
> > I've made some progress. I've installed c2hs. I'm still puzzled as to why
> > ./Setup configure didn't complain.
>
> (snip)
>
> > And cabal magically finds the IP_ICMP.chs file and preprocesses it.
> > However, I need to execute the following:
> >
> > c2hs ip_icmp.h IP_ICMP.chs
> >
> > not just
> >
> > c2hs IP_ICMP.chs
> >
> > How do I get cabal to do this? I saw this
> > http://www.haskell.org//pipermail/haskell/2005-April/015728.html. Does
> > that mean I need to modify cabal? Or can I use UserHooks? Are there any
> > examples?
>
> You can do this in a UserHook by either just calling hsc2hs on your .h
> file in the preBuild phase, or you can override the c2hs preprocessor.
> As I mention here:
>
> http://www.haskell.org//pipermail/haskell/2005-April/015730.html
>
> There's an example of using UserHooks to override a preprocessor.
> Setup.lhs is the right place for the fix until we add more tags to the
> .cabal file for stuff like this.
>
> http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/libraries/Caba
>l/tests/withHooks/Setup.lhs?rev=1.2;content-type=text%2Fplain
>
> peace,
>
> isaac
Isaac,
Thanks for your prompt response. I did have a look at these references before
I posted and didn't find them very enlightening. I've now looked at the
sources and come up with this which works. Is this the right way to do it?
BTW I discovered a bug in the .chs handler. You have "-o " rather than "-o". I
can try and send a patch but it might be easier if you edit the file
yourself.
Dominic.
import Distribution.Simple
import Distribution.Simple.Utils(rawSystemPath)
main =
defaultMainWithHooks
defaultUserHooks {
hookedPreProcessors =
[("chs", \_ _ -> myPpC2hs)]
}
myPpC2hs inFile outFile verbose
= rawSystemPath verbose "c2hs" ["-o" ++ outFile, "ip_icmp.h", inFile]
More information about the Libraries
mailing list