added preCopy and postCopy hooks in Setup.hs

This commit is contained in:
krasimir
2009-06-23 11:44:36 +00:00
parent 032f8de862
commit 8e72ff3a1c

View File

@@ -5,7 +5,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.BuildPaths import Distribution.Simple.BuildPaths
import Distribution.Simple.Utils import Distribution.Simple.Utils
import Distribution.Simple.Setup import Distribution.Simple.Setup
import Distribution.PackageDescription import Distribution.PackageDescription hiding (Flag)
import Control.Monad import Control.Monad
import Data.Maybe import Data.Maybe
import System.IO import System.IO
@@ -21,6 +21,8 @@ main = defaultMainWithHooks simpleUserHooks{ preBuild =checkRGLArgs
, postBuild=buildRGL , postBuild=buildRGL
, preInst =checkRGLArgs , preInst =checkRGLArgs
, postInst =installRGL , postInst =installRGL
, preCopy =checkRGLArgs
, postCopy =copyRGL
, sDistHook=sdistRGL , sDistHook=sdistRGL
, runTests =testRGL , runTests =testRGL
} }
@@ -88,8 +90,16 @@ installRGL args flags pkg lbi = do
let mode = getOptMode args let mode = getOptMode args
let inst_gf_lib_dir = datadir (absoluteInstallDirs pkg lbi NoCopyDest) </> "lib" let inst_gf_lib_dir = datadir (absoluteInstallDirs pkg lbi NoCopyDest) </> "lib"
copyAll mode (getRGLBuildDir lbi mode) (inst_gf_lib_dir </> getRGLBuildSubDir lbi mode) copyAll mode (getRGLBuildDir lbi mode) (inst_gf_lib_dir </> getRGLBuildSubDir lbi mode)
where
copyAll mode from to = do copyRGL args flags pkg lbi = do
let mode = getOptMode args
dest = case copyDest flags of
NoFlag -> NoCopyDest
Flag d -> d
let inst_gf_lib_dir = datadir (absoluteInstallDirs pkg lbi dest) </> "lib"
copyAll mode (getRGLBuildDir lbi mode) (inst_gf_lib_dir </> getRGLBuildSubDir lbi mode)
copyAll mode from to = do
putStrLn $ "Installing [" ++ show mode ++ "] " ++ to putStrLn $ "Installing [" ++ show mode ++ "] " ++ to
createDirectoryIfMissing True to createDirectoryIfMissing True to
files <- fmap (drop 2) $ getDirectoryContents from files <- fmap (drop 2) $ getDirectoryContents from