
Hello, Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: include-dirs: C:\Program Files\program\include and of course a corresponding library as well. I've tried various methods of escaping the space and quoting, and nothing seems to work. Is this possible at all? I'm using Cabal-1.2.4.0 on Windows. I've tried running with a Windows shell and MSYS bash, with the same results. Thanks, John Lato

On Sun, 27 Jul 2008 03:23:09 +0200, John Lato
Hello,
Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: include-dirs: C:\Program Files\program\include and of course a corresponding library as well. [...]
Have you tried replacing "Program Files" with PROGRA~1? This is the old MS-Dos version of the directory name; you can find the old name with command dir /x C:\ , this displays the old version next to the new version of the name. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ --

Hello Henk-Jan, Sunday, July 27, 2008, 11:36:32 PM, you wrote:
Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: Have you tried replacing "Program Files" with PROGRA~1? This is the old
i don't followed discussion but if this meant for distributable packages, the following problems exist: 1. it may be progra~2 or ~3 2. it's possible to entirely disable short names generation on ntfs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Mon, 2008-07-28 at 00:27 +0400, Bulat Ziganshin wrote:
Hello Henk-Jan,
Sunday, July 27, 2008, 11:36:32 PM, you wrote:
Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: Have you tried replacing "Program Files" with PROGRA~1? This is the old
i don't followed discussion but if this meant for distributable packages, the following problems exist:
1. it may be progra~2 or ~3 2. it's possible to entirely disable short names generation on ntfs
None of this is necessary. Paths with spaces are just fine if you use the Haskell String syntax. Duncan

On Sat, 2008-07-26 at 20:23 -0500, John Lato wrote:
Hello,
Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: include-dirs: C:\Program Files\program\include and of course a corresponding library as well.
Use Haskell String syntax for paths that contain spaces: include-dirs: "C:\\Program Files\\program\\include" Duncan

On Sun, Jul 27, 2008 at 3:25 PM, Duncan Coutts
On Sat, 2008-07-26 at 20:23 -0500, John Lato wrote:
Hello,
Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: include-dirs: C:\Program Files\program\include and of course a corresponding library as well.
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. Is this documented anywhere? I've been poring over the cabal guide trying to find this, with no success. Thank you, John

On Sun, 2008-07-27 at 21:01 -0500, John Lato wrote:
On Sun, Jul 27, 2008 at 3:25 PM, Duncan Coutts
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.
Oh, that must be a bug. Can you file it here please with details of exactly how to reproduce it: http://hackage.haskell.org/trac/hackage/
Is this documented anywhere? I've been poring over the cabal guide trying to find this, with no success.
Yes, though perhaps not very clearly: http://haskell.org/cabal/release/latest/doc/users-guide/authors.html#pkg-des... The syntax of the value depends on the field. Field types include: token , filename , directory Either a sequence of one or more non-space non-comma characters, or a quoted string in Haskell 98 lexical syntax. Unless otherwise stated, relative filenames and directories are interpreted from the package root directory. Suggestions for improvement welcome. Even better would be patches. The user guide is in the Cabal repo in doc/Cabal.xml in docbook format. Duncan

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. Duncan

On Fri, Aug 1, 2008 at 8:39 AM, Duncan Coutts
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
participants (4)
-
Bulat Ziganshin
-
Duncan Coutts
-
Henk-Jan van Tuyl
-
John Lato