needing to know install paths

Duncan Coutts duncan.coutts at
Thu Jul 6 10:59:23 EDT 2006

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

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

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.


More information about the cabal-devel mailing list