Today I was configuring Cabal to exclude Test binary from files being installed to ~/.cabal/bin. I've figured out that by default there is no any flag which controls it. Cabal library has structure Executable which has three fields: exeName, modulePath and buildInfo. Intall action doesn't install only those executables which have buildInfo.buildable field false. However if buildable is set to false in .cabal file, build action doesn't build the executable. So solution is the following:
- Build-type: Custom. In this case cabal will be using supplied Setup.hs file.
- Content of Setup.hs file is the following:
import Distribution.Simple import Distribution.PackageDescription import Data.Monoid (Monoid(mempty, mappend)) main = defaultMainWithHooks (simpleUserHooks { preInst = myPreInst }) myPreInst a f = return (Nothing, [("Test", mempty { buildable = False})])Maybe it's better to implement an explicit feature which allows to configure cabal to exclude some binaries from installation.