[Haskell-cafe] Cabal question
Rogan Creswick
creswick at gmail.com
Sat Jul 19 15:49:29 UTC 2014
On Sat, Jul 19, 2014 at 4:33 AM, Jurriaan Hage <J.Hage at uu.nl> wrote:
> What I still need is a way to run some kind of postprocessing (like running
> a Makefile) after installation (as it happens this is for compiling the
> libraries that come with Helium).
You can do this with a custom cabal build type, a non-trivial Setup.hs.
Cabal exposes a bunch of 'user hooks' that let you specify functions to be
run at various stages of the compilation (such as pre-build, post-install,
etc...).
See the API here for the hooks available:
-
http://www.haskell.org/ghc/docs/7.6.3/html/libraries/Cabal/Distribution-Simple-UserHooks.html
I use prebuild hooks quite a lot to pre-process GF files (for the
grammatical framework); one relatively simple example is shown in my gfI8N
package: https://github.com/creswick/gfI8N
Note that the cabal file uses `build-type: Custom` (which causes cabal to
actually use the Setup.hs).
The relevant part of the Setup.hs is:
import Distribution.Simple
import Distribution.Simple.Program.Types
import Distribution.Simple.Setup
import Distribution.Simple.UserHooks
import Distribution.Simple.Utils ( rawSystemExit, warn, debug
, findProgramVersion, notice )
import Distribution.Verbosity ( Verbosity )
main = do
defaultMainWithHooks simpleUserHooks
{ preBuild = \a b -> generatePGF a b >> preBuild simpleUserHooks a b
, preClean = \a b -> preClean simpleUserHooks a b
}
That should be enough to get you going -- now some cautions, and a minor
rant ;)
Working with these hooks has lead me to /really/ want a way to express
dependencies for Setup.hs files. You *can not* use any hackage libraries
in the definitions of these hooks and retain a portable build, because
there is no way to indicate that the Setup.hs depends on such things. It
used to be the case that you could assume that the dependencies of your
library / executable would be visible, but with sandboxed builds that
assumption is no longer valid. There's a cabal ticket for this feature
here: https://github.com/haskell/cabal/issues/948
You should be able to rely on these packages (which shipped with ghc -- the
versions will depend on the ghc version installed):
Cabal-1.16.0
array-0.4.0.1
base-4.6.0.1
bin-package-db-0.0.0.0
binary-0.5.1.1
bytestring-0.10.0.2
containers-0.5.0.0
deepseq-1.3.0.1
directory-1.2.0.1
filepath-1.3.0.1
ghc-7.6.3
ghc-prim-0.3.0.0
haskell2010-1.1.1.0
haskell98-2.0.0.2
hoopl-3.9.0.0
hpc-0.6.0.0
integer-gmp-0.5.0.0
old-locale-1.0.0.5
old-time-1.1.0.1
pretty-1.1.1.0
process-1.1.0.2
rts-1.0
template-haskell-2.8.0.0
time-1.4.0.1
--Rogan
Does anyone know here whether that is supported
> and how, without having to resort to build-types like Make that for I
> actually
> want to avoid?
>
> best,
> Jur
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140719/84dd27fe/attachment.html>
More information about the Haskell-Cafe
mailing list