
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
Is there some way of getting hold of the BuildInfo and LocalBuildInfo to pass into runSimplePreProcessor? Thanks, Dominic.

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@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@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~ -rw-r--r-- 1 dom users 250 2008-07-05 06:50 ping.cabal -rw-r--r-- 1 dom users 591 2008-07-05 06:50 Makefile -rw-r--r-- 1 dom users 787 2008-07-05 06:50 ip_icmp.h -rw-r--r-- 1 dom users 212 2008-07-05 06:50 IP_ICMP.chs -rw-r--r-- 1 dom users 18011 2008-07-05 06:50 gpl.txt -rw-r--r-- 1 dom users 487 2008-07-05 08:03 Setup.hi -rw-r--r-- 1 dom users 3684 2008-07-05 08:16 Setup.o -rwxr-xr-x 1 dom users 3048919 2008-07-05 08:16 Setup -rw-r--r-- 1 dom users 195 2008-07-05 08:17 Setup.hs drwxr-xr-x 3 dom users 4096 2008-07-05 08:22 dist -rw-r--r-- 1 dom users 128 2008-07-05 08:26 IP_ICMP.i
How do I tell cabal that ip_icmp.h is in the current directory not buried somewhere? Thanks, Dominic.

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@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?
Use: include-dirs: . Duncan
participants (2)
-
Dominic Steinitz
-
Duncan Coutts