diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2015-04-15 18:23:54 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2015-04-15 18:23:54 +0200 |
commit | 125908ae40d2b229926ed5ec57b52dd6a41d269e (patch) | |
tree | 580103328a32e98a84ad420ec7d1dad425ed1ba9 | |
parent | 2136c4205d4246337bec3a96dbb08d5876bcbc03 (diff) |
Fix X-Install-Target for older Cabal versions
-rw-r--r-- | Setup.hs | 46 |
1 files changed, 38 insertions, 8 deletions
@@ -3,21 +3,52 @@ import Distribution.Simple import Distribution.Simple.Setup import Distribution.Simple.Install +import Distribution.Simple.Register import Distribution.Simple.InstallDirs as ID import Distribution.Simple.LocalBuildInfo import Distribution.PackageDescription import Control.Applicative +import Control.Monad import Data.List import Data.Maybe import System.FilePath main :: IO () -main = defaultMainWithHooks $ simpleUserHooks { copyHook = xInstallTargetHook } - -xInstallTargetHook :: - PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO () -xInstallTargetHook pd lbi _uh cf = do +main = defaultMainWithHooks $ simpleUserHooks { + instHook = inst, + copyHook = copy + } + +-- mostly copypasta from 'defaultInstallHook' +inst :: + PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO () +inst pd lbi _uf ifl = do + let copyFlags = defaultCopyFlags { + copyDistPref = installDistPref ifl, + copyDest = toFlag NoCopyDest, + copyVerbosity = installVerbosity ifl + } + xInstallTarget pd lbi (\pd' lbi' -> install pd' lbi' copyFlags) + let registerFlags = defaultRegisterFlags { + regDistPref = installDistPref ifl, + regInPlace = installInPlace ifl, + regPackageDB = installPackageDB ifl, + regVerbosity = installVerbosity ifl + } + when (hasLibs pd) $ register pd lbi registerFlags + +copy :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO () +copy pd lbi _uh cf = + xInstallTarget pd lbi (\pd' lbi' -> install pd' lbi' cf) + + + +xInstallTarget :: PackageDescription + -> LocalBuildInfo + -> (PackageDescription -> LocalBuildInfo -> IO ()) + -> IO () +xInstallTarget pd lbi fn = do let (extended, regular) = partition (isJust . installTarget) (executables pd) let pd_regular = pd { executables = regular } @@ -42,10 +73,9 @@ xInstallTargetHook pd lbi _uh cf = do bindir = install_target'' } } + fn pd_extended lbi' - install pd_extended lbi' cf - - install pd_regular lbi cf + fn pd_regular lbi where installTarget :: Executable -> Maybe PathTemplate |