Dominic Steinitz | 5 Jul 09:04

Cabal and c2hs

Way back in 2005, I was able to build my haskell version of ping with
this Setup.hs

> import Distribution.Simple
> import Distribution.Simple.Utils(rawSystemPath)
> 
> main = 
>    defaultMainWithHooks 
>       defaultUserHooks {
>          hookedPreProcessors =  
>             [("chs", \_ _ -> myPpC2hs)]
>       }
> 
> myPpC2hs inFile outFile verbose
>     = rawSystemPath verbose "c2hs" ["-o", outFile, inFile]

rawSystemPath no longer seems to exist (in Distribution.Simple.Utils at
any rate).

Looking at the latest haddock, there does seem to be

> runSimplePreProcessor :: PreProcessor -> FilePath -> FilePath -> Verbosity -> IO ()

> ppC2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor

but I'm struggling to see what I put in BuildInfo and LocalBuildInfo.

I presume I put "." as the FilePath?

> main = runSimplePreProcessor (ppC2hs undefined undefined) "." "." deafening
(Continue reading)

Dominic Steinitz | 5 Jul 09:18

Re: Cabal and c2hs

Ignore my previous message, it was a lot simpler than I thought it was

> import Distribution.Simple
> import Distribution.Simple.PreProcess
> 
> main = 
>    defaultMainWithHooks 
>       defaultUserHooks {
>          hookedPreProcessors =  
>             [("chs", ppC2hs)]
>       }

Dominic.
Dominic Steinitz | 5 Jul 09:30

Re: Cabal and c2hs

Dominic Steinitz wrote:
> Ignore my previous message, it was a lot simpler than I thought it was
> 
>> import Distribution.Simple
>> import Distribution.Simple.PreProcess
>>
>> main = 
>>    defaultMainWithHooks 
>>       defaultUserHooks {
>>          hookedPreProcessors =  
>>             [("chs", ppC2hs)]
>>       }
> 
> Dominic.
> 

But now I get a build error

> dom <at> lagrange:~/networktools/ping> ./Setup build
> Preprocessing executables for Ping-0.0...
> dist/build/ping/ping-tmp/IP_ICMP.chs.h:1:21: error: ip_icmp.h: No such file or directory
> c2hs: Error during preprocessing custom header file

But ip_icmp.h is there!

> dom <at> lagrange:~/networktools/ping> ls -ltr
> total 3104
> drwxr-xr-x 7 dom users    4096 2008-07-05 06:50 _darcs
> -rw-r--r-- 1 dom users    5487 2008-07-05 06:50 test.hs
> -rw-r--r-- 1 dom users     307 2008-07-05 06:50 Setup.hs~
(Continue reading)

Duncan Coutts | 12 Jul 02:08

Re: Cabal and c2hs

Late reply I know, but in case you're still having trouble:

On Sat, 2008-07-05 at 08:30 +0100, Dominic Steinitz wrote:
> Dominic Steinitz wrote:
> > Ignore my previous message, it was a lot simpler than I thought it was
> > 
> >> import Distribution.Simple
> >> import Distribution.Simple.PreProcess
> >>
> >> main = 
> >>    defaultMainWithHooks 
> >>       defaultUserHooks {
> >>          hookedPreProcessors =  
> >>             [("chs", ppC2hs)]
> >>       }

There is no need to use a custom Setup.hs script for this. Cabal already
knows that .chs files are processed by c2hs.

> But now I get a build error
> 
> > dom <at> lagrange:~/networktools/ping> ./Setup build
> > Preprocessing executables for Ping-0.0...
> > dist/build/ping/ping-tmp/IP_ICMP.chs.h:1:21: error: ip_icmp.h: No such file or directory
> > c2hs: Error during preprocessing custom header file
> 
> But ip_icmp.h is there!

> How do I tell cabal that ip_icmp.h is in the current directory not
> buried somewhere?
(Continue reading)


Gmane