[Haskell-cafe] Dynamic package information with Setup.hs
Thiago Padilha
tpadilha84 at gmail.com
Thu Nov 21 16:56:46 UTC 2013
I'm writing a cabal package that provides bindings to a C library.
I've written a shell script that will download and build this C
library to a subdirectory of the user's
HOME(~/.cabal-tmp/{lib,include}). Currently I have the following
Setup.hs that automatically runs the script before installing:
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.PackageDescription
import System.Process
main :: IO ()
main =
defaultMainWithHooks simpleUserHooks
{
preConf = buildDeps
}
buildDeps :: Args -> ConfigFlags -> IO HookedBuildInfo
buildDeps _ _ = do
rawSystem "sh" ["./scripts/build-deps.sh"]
return emptyHookedBuildInfo
I've tried adding the following lines:
extra-lib-dirs: ${HOME}/.cabal-tmp/lib
include-dirs: ${HOME}/.cabal-tmp/include
But it complains about syntax errors and I found no other way to
expand the user's HOME directory in the .cabal file. If I use relative
paths in the 'extra-lib-dirs' an error is reported(cabal 1.16). Full
paths are also needed for linking against this package as ghc needs to
know the linker flags for the native library.
Obviously I cant know the full path the library will be installed in
advance, as I dont know the HOME directory of the user installing the
package until the Setup.hs script is running.
My question: How can I use the Setup.hs hooks to update those two
fields dynamically?
More information about the Haskell-Cafe
mailing list