building a helper binary with cabal
Evan Martin
martine at danga.com
Sat Mar 1 12:17:54 EST 2008
On Sat, Mar 1, 2008 at 3:21 AM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> I presume you mean a private binary that's needed at runtime, rather
> than a program like a code-gen needed at build time but not installed.
That's right.
> Cabal does not have any direct support for private binaries, so you'll
> have to use a custom Setup.hs.
>
> Perhaps it should, if you can describe what you think is needed in
> general, file a feature request here:
> http://hackage.haskell.org/trac/hackage/
I can't think of many scenarios where they'd really be needed. The
two instances I've seen are:
1) to write a simplified (commands via stdin, output via stdout)
interface to an API that I don't want to link in (or don't want to
write bindings for)
2) this particular program, which would be written in Haskell except
that it does some C libdl tricks
> Cabal knows about the 'libexec' path which sounds like it might be what
> you want, though that doesn't include any package subdir (though perhaps
> it should - it is currently unused). Alternatively just install into the
> 'libdir' which does include the package subdir.
>
> let dirs = absoluteInstallDirs pkg_descr lbi copydest
> copyFileVerbose verbosity file (libdir dirs </> file)
Thanks, this is very helpful!
absoluteInstallDirs takes a few more args, so here's a longer example
for the mailing list archives. I'm 98% of the way there, just need to
figure out copyDest.
>From the docs, it may be the case that copyDest is only available in
the "copy" step? If that's right, does that mean the user needs to
run the copy step manually?
> type InstHook = PackageDescription -> LocalBuildInfo -> UserHooks
> -> InstallFlags -> IO ())
> creplChildInst :: InstHook -> InstHook
> creplChildInst oldhook desc buildinfo hooks flags = do
> oldhook desc buildinfo hooks flags
> let compilerpkg = compilerId (compiler buildinfo)
> let copydest = -- XXX still haven't figured this one out
> let dirtemplates = installDirTemplates buildinfo
> let dirs = absoluteInstallDirs desc compilerpkg copydest dirtemplates
> copyFileVerbose (installVerbose flags) (creplChildPath buildinfo)
> (libdir dirs </> "child")
> At runtime you can get the libexec and libdir that the user chose at
> configure time using the Paths_pkgname module which exports getLibDir
> and getLibexecDir amongst others.
Cool, thanks.
More information about the Libraries
mailing list