-
Notifications
You must be signed in to change notification settings - Fork 17
/
Setup.hs
31 lines (28 loc) · 1.37 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# LANGUAGE CPP #-}
import Control.Monad (unless)
import Distribution.Simple
import Distribution.Simple.InstallDirs (InstallDirs(..), fromPathTemplate, toPathTemplate)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..))
import Distribution.Simple.Setup (ConfigFlags(..), fromFlag, fromFlagOrDefault)
import System.Directory (copyFile, doesFileExist)
import System.FilePath ((</>))
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
#else
import System.Posix.Files (createSymbolicLink)
#endif
main = defaultMainWithHooks simpleUserHooks {postCopy = postCopy'}
postCopy' _ _ _ buildInfo = do
-- I tried the following seemingly more correct way but received the error:
-- "internal error InstallDirs.libsubdir". For now I gave up on tracking it
-- down and switched to the following code. If you know what I'm doing wrong
-- here, please let me know.
-- let installDirs = absoluteInstallDirs pkgDesc buildInfo NoCopyDest
let dirs = configInstallDirs $ configFlags buildInfo
dir = (fromPathTemplate . fromFlag $ prefix dirs) </> (fromPathTemplate . fromFlagOrDefault (toPathTemplate "bin") $ bindir dirs)
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
copyFile (dir </> "redo.exe") (dir </> "redo-ifchange.exe")
#else
let symlink = (dir </> "redo-ifchange")
exists <- doesFileExist symlink
unless exists $ createSymbolicLink (dir </> "redo") symlink
#endif