Safe Haskell | None |
---|---|
Language | Haskell2010 |
Custom modifications to the cabal-generated Paths_thentos_core.
Quick motivation: we run code in at least the following different ways:
- the deployed binary.
- with hspec's sensei (via the
Makefile
rules in the git repo root). - interactively (via the repl rules, same
Makefile
). - the test suite (cabal `cabal test` or `./misc/thentos-install.sh`).
- via TH splices that run during compile time (e.g., to compile css source files as byte strings into the executable)
In order to make sure the code will find places in the file system in all these contexts, the cabal built-in functionality is almost enough, but not quite. This file adds two little quirks.
- In development mode (cabal flag
development
),getDataFileName
returns the path into the package root (it just callsgetPackageSourceRoot
). getPackageSourceRoot
is exported both from here and from Paths.TH for use in sibling packages.
Related info: http://neilmitchell.blogspot.de/2008/02/adding-data-files-using-cabal.html
- getDataFileName :: FilePath -> IO FilePath
- getPackageSourceRoot :: FilePath -> Q Exp
- version :: Version
Documentation
getDataFileName :: FilePath -> IO FilePath
getPackageSourceRoot :: FilePath -> Q Exp
Takes a package name and returns a directory FilePath
at compile time. The file path is
determined as follows (first working method wins):
- Shell variable. Example: CABAL_PACKAGE_SOURCE_ROOT_THENTOS_CORE for package thentos-core.
- If current directory contains a directory with the same name as the package, take that.
- Like 2., but on *parent* directory.
- Take current directory.
WARNING: use this only for testing or build-time effects!
version :: Version