
Hi Cabal hackers, For c2hs we've run into a problem. See the thread about c2hs on window over on the haskell list. c2hs wants to install a data file (actually a .hs source file) and wants to know where it's been installed so that c2hs --copy-library can find and copy said file. So how do we do this? At the moment c2hs's Setup.hs calls a postInst script which installs a wrapper script (much like all the little ghc wrapper scripts which specifies the path where things can be found). Of course this doesn't work on Windows. I recall some talk about making this sort of thing easier? Where did we get with that? Duncan

On Thu, 2006-07-06 at 10:43 +0100, Duncan Coutts wrote:
Hi Cabal hackers,
For c2hs we've run into a problem. See the thread about c2hs on window over on the haskell list.
c2hs wants to install a data file (actually a .hs source file) and wants to know where it's been installed so that c2hs --copy-library can find and copy said file.
So how do we do this? At the moment c2hs's Setup.hs calls a postInst script which installs a wrapper script (much like all the little ghc wrapper scripts which specifies the path where things can be found). Of course this doesn't work on Windows.
I recall some talk about making this sort of thing easier? Where did we get with that?
Ah, I think I can answer my own question. There is a "data-files" field one can add to the cabal file and the recent Paths_${projname}.hs thing allows us to find the data files at runtime. So I'll go try to hack that into c2hs so it'll work on win32. Duncan

On Thu, 2006-07-06 at 12:12 +0100, Duncan Coutts wrote:
On Thu, 2006-07-06 at 10:43 +0100, Duncan Coutts wrote:
Hi Cabal hackers,
For c2hs we've run into a problem. See the thread about c2hs on window over on the haskell list.
c2hs wants to install a data file (actually a .hs source file) and wants to know where it's been installed so that c2hs --copy-library can find and copy said file.
So how do we do this? At the moment c2hs's Setup.hs calls a postInst script which installs a wrapper script (much like all the little ghc wrapper scripts which specifies the path where things can be found). Of course this doesn't work on Windows.
I recall some talk about making this sort of thing easier? Where did we get with that?
Ah, I think I can answer my own question.
There is a "data-files" field one can add to the cabal file and the recent Paths_${projname}.hs thing allows us to find the data files at runtime.
So I'll go try to hack that into c2hs so it'll work on win32.
Ok, along a similar theme... We provide the Paths_${projname}.hs module, as a little extra there it provides the current version number. Perhaps we could generalise that and provide the whole cabal file (using the normal Cabal types). My motivation in this case is that c2hs currently gets more fields from the .cabal file than it conveniently provides. The c2hs Version.hs.in file: name = "C->Haskell Compiler" versnum = @C2HS_VERSION@ versnick = @C2HS_NICK@ date = @C2HS_DATE@ version = name ++ ", version " ++ versnum ++ " " ++ versnick ++ ", " ++ date copyright = "@C2HS_COPYRIGHT@" disclaimer = "This software is distributed under the \ these @@ var substitutions are done by configure, which actually gets the values of the vars by grepping c2hs.cabal ! dnl This is far from elegant, but works for extracting the plain version number C2HS_VERSION=`$GREP '^Version:' c2hs.cabal \ | $SED '-e s/Version:[[ ]]*//'` C2HS_NICK=`$GREP '^--Versnick:' c2hs.cabal \ | $SED '-e s/--Versnick:[[ ]]*//'` C2HS_DATE=`$GREP '^--Versdate:' c2hs.cabal \ | $SED '-e s/--Versdate:[[ ]]*//'` C2HS_COPYRIGHT=`$GREP '^Copyright:' c2hs.cabal \ | $SED '-e s/Copyright:[[ ]]*//'` note that this includes two pseudo fields which are kept as comments in the .cabal file: Name: c2hs Version: 0.14.6 --Versnick: "Travelling Lightly" --Versdate: "28 Apr 2006" License: GPL etc... Now we already allow extra extension fields in the .cabal files without complaining (of the form "x-foo:"). Perhaps we could include these extension fields in the cabal ADT as just a simple string key->value mapping. Or perhaps it should be [String] as the value type, parsing using the normal ',' as seperator and using "" quotes to make things single items. That way, the app could keep this kind of info in one place and extract it at runtime for things like version messages and about boxes etc. Duncan

On Thu, 2006-07-06 at 15:59 +0100, Duncan Coutts wrote:
Ok, along a similar theme...
We provide the Paths_${projname}.hs module, as a little extra there it provides the current version number. Perhaps we could generalise that and provide the whole cabal file (using the normal Cabal types).
More monologue... Actually perhaps this isn't such a good idea. It'd tie the version of cabal more strongly to the app it's installing. Suppose we generate a module using the current version of cabal that's building the package. That has to be the same version as the program gets built against if it's to use this generated module. And then that has to be sufficiently close to the version that the packages was designed to use so that the fields from the cabal package description are the same. Hmm. Duncan

Duncan Coutts
On Thu, 2006-07-06 at 15:59 +0100, Duncan Coutts wrote:
Ok, along a similar theme...
We provide the Paths_${projname}.hs module, as a little extra there it provides the current version number. Perhaps we could generalise that and provide the whole cabal file (using the normal Cabal types).
More monologue...
Actually perhaps this isn't such a good idea. It'd tie the version of cabal more strongly to the app it's installing.
Suppose we generate a module using the current version of cabal that's building the package. That has to be the same version as the program gets built against if it's to use this generated module. And then that has to be sufficiently close to the version that the packages was designed to use so that the fields from the cabal package description are the same.
So you're saying that you're worried that the change in the APIs for cabal would make your build system more fragile? I can understand that worry, though the packageDescription type shouldn't change too much, I hope. If we go for something like this, we'll want to go through and make sure that the fields have names that are worthy of being exposed :) I don't understand what you mean here:
Suppose we generate a module using the current version of cabal that's building the package. That has to be the same version as the program gets built against if it's to use this generated module.
If you generate a module during build time and link it in right away, it's going to be the same version of cabal, right? peace, isaac

Duncan Coutts wrote:
On Thu, 2006-07-06 at 15:59 +0100, Duncan Coutts wrote:
Ok, along a similar theme...
We provide the Paths_${projname}.hs module, as a little extra there it provides the current version number. Perhaps we could generalise that and provide the whole cabal file (using the normal Cabal types).
More monologue...
Actually perhaps this isn't such a good idea. It'd tie the version of cabal more strongly to the app it's installing.
Suppose we generate a module using the current version of cabal that's building the package. That has to be the same version as the program gets built against if it's to use this generated module. And then that has to be sufficiently close to the version that the packages was designed to use so that the fields from the cabal package description are the same.
[ catching up on cabal-devel... ] Actually when I first added the Paths_<pkg> support I did try including the whole PackageDescription in that file. However I backed off precisely because of the reason you give: it means every package effectively includes a dependency on Cabal, and the package must therefore say which version of Cabal it is expecting. Cheers, Simon
participants (3)
-
Duncan Coutts
-
Isaac Jones
-
Simon Marlow