[Haskell-cafe] Inject cabal version or VCS version as a CPP macro

Eugene Kirpichov ekirpichov at gmail.com
Wed Feb 22 12:01:25 CET 2012


On Wed, Feb 22, 2012 at 2:57 PM, Herbert Valerio Riedel <hvr at gnu.org> wrote:

> Eugene Kirpichov <ekirpichov at gmail.com> writes:
>
> > It can be used like this:
> >
> > {-# LANGUAGE TemplateHaskell #-}
> >  import Distribution.VcsRevision.Git
> >  import Language.Haskell.TH.Syntax
> >
> >  showMyGitVersion :: String
> >  showMyGitVersion = $(do
> >    v <- qRunIO getRevision
> >    lift $ case v of
> >      Nothing           -> "<none>"
> >      Just (hash,True)  -> hash ++ " (with local modifications)"
> >      Just (hash,False) -> hash)
>
> Btw, I'm wondering (haven't tried myself), when using TH to generate the
> version string, does GHC's and/or cabal's dependency tracking
>
>  a) reliably refresh the generated hash so that you can be sure it's
>    the git-commit id compiled into the binary is reliable, and
>
>  b) avoid re-generating the TH file and redundant recompilation if the
>    git commit-id hasn't changed?
>
> Do you mean all this in the context where this resides in a library rather
than an application? I haven't thought about that yet.


> hvr
> --
>



-- 
Eugene Kirpichov
Principal Engineer, Mirantis Inc. http://www.mirantis.com/
Editor, http://fprog.ru/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120222/ea9745c6/attachment.htm>


More information about the Haskell-Cafe mailing list