Hi,
I have been trying to build a Cabal package that uses c2hs under mingw and have run into some problems.
1) c2hs needed its own options because it has to pass a flag to its invocation of the CPP. I have already submitted this patch. (I also noticed a request for cppOptions in the
Cabal.cabal file, so I added that)
2) When c2hs generates the
foreign import ccall unsafe "path/to/include.h function" :: Type
it doesn't insert the appropriate number of path separators for windows (
i.e. \\ not \)
I have this patch sitting in my copy of c2hs. But what I did is really ugly:
at around line 567 (process :: FilePath -> FilePath -> CST s ())
I inserted:
> outFName' <- getSwitch outputSB
> -- on windows the path separator needs to be "\\" not "\"
> let outFName = replaceFileSeparator outFName'
where replaceFileSeparator is defined as:
> replaceFileSeparator :: String -> String
> replaceFileSeparator [] = []
> replaceFileSeparator (x:xs)
> | x == '\\' = "\\\\" ++ (replaceFileSeparator xs)
> | otherwise = x : (replaceFileSeparator xs)
this fixes the problem but stinks.
3) when compiling my c2hs generated .hs file, the c2hs generated .h file is not being found.
$ ./Setup.lhs -v build
Reading parameters from D:\Apps\MSYS\1.0\local\src\mingw-c2hs-cabal-test\cabal-root\mingw-
c2hs-cabal-test.buildinfo
Preprocessing library Mingw-c2hs-cabal-test-0.0.1...
D:\Apps\MSYS\1.0\local\bin\c2hs.exe -C -D__GLASGOW_HASKELL__=606 -C -I..\include --cppopts=-I../include --include=src -o src\Cabal\MingwTest.hs src\Cabal\MingwTest.chs
D:\Apps\MSYS\1.0\local\bin\c2hs.exe -C -D__GLASGOW_HASKELL__=606 -C -I..\include --cppopts=-I../include --include=src -o src\Cabal\MingwTest2.hs src\Cabal\MingwTest2.chs
Building Mingw-c2hs-cabal-test-0.0.1...
d:\Apps\ghc\ghc-
6.6\bin\ghc.exe -package-name Mingw-c2hs-cabal-test-0.0.1 --make -hide-all-packages -i -idist\build\autogen -i. -isrc -I..\include -#include "test.h" -odir dist\build -hidir dist\build -package base-2.0 -O -package haskell98 -fglasgow-exts -fffi
Cabal.MingwTest Cabal.MingwTest2 C2HS
[1 of 3] Compiling C2HS ( src/C2HS.hs, dist\build/C2HS.o )
[2 of 3] Compiling Cabal.MingwTest ( src/Cabal/MingwTest.hs, dist\build/Cabal/MingwTest.o )
C:\DOCUME~1\vivian\LOCALS~1\Temp\ghc31772_0\ghc31772_0.hc:6:33: src\Cabal\MingwTest.h: No such file or directory
I have attached a set of files that will generate the errors I have mentioned on mingw.
Cheers,
Vivian