[Haskell-cafe] Cabal files on Windows

John Lato jwlato at gmail.com
Fri Aug 1 18:59:31 EDT 2008


On Fri, Aug 1, 2008 at 8:39 AM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> On Sun, 2008-07-27 at 21:01 -0500, John Lato wrote:
>
>> > Use Haskell String syntax for paths that contain spaces:
>> >
>> > include-dirs:  "C:\\Program Files\\program\\include"
>>
>> Hi Duncan,
>>
>> Thanks, this worked (mostly).  Although I had to change the line to
>>
>> include-dirs: "\"C:\\Program Files\\program\\include\""
>>
>> so that the path would be passed properly to cpp through c2hs.
>
> Thanks for for filing the ticket John.
>
> http://hackage.haskell.org/trac/hackage/ticket/316#comment:1
>
> Turns out Cabal is doing it right and it's c2hs that we need to fix.
> Shouldn't be too hard. Just need to change the way c2hs invokes cpp in
> Main.hs:
>
>    let cmd  = unwords [cpp, cppOpts, newHeaderFile, ">" ++ preprocFile]
>    tracePreproc cmd
>    exitCode <- liftIO $ system cmd
>
> to something like:
>
>    let args = cppOpts ++ [newHeaderFile]
>    tracePreproc (unwords (cmd : args))
>    exitCode <- liftIO $ do
>      preprocHnd <- openFile WriteMode preprocFile
>      process <- runProcess cpp args
>                   Nothing Nothing
>                   Nothing (Just preprocHnd) Nothing
>      waitForProcess process
>
> Try that, tell me if it works and we can add the patch to the c2hs repo.
>

I got some compilation errors with this patch.  After I changed the
top two lines as follows:

    let args = [cppOpts, newHeaderFile] --cppOpts :: String, not [String]
    tracePreproc (unwords (cpp:args))    --I think you meant cpp
instead of cmd here

c2hs builds, but I think you can see the problem already.  cppOpts
needs to be a list of arguments, rather than one string, to use it
with runProcess.  Now running c2hs yields a cpp error about an invalid
argument, specifically "-x c -IC:\\Program Files\include".

I've added a ticket to trac (#11) for this, and included a patch to
fix the problem.
Thanks,
John


More information about the Haskell-Cafe mailing list