4import Control.Exception (SomeException, catch)
6import Distribution.Simple
7import Distribution.Simple.BuildPaths (autogenModulesDir)
8import Distribution.Simple.InstallDirs as I
9import Distribution.Simple.LocalBuildInfo as L
10import qualified Distribution.Simple.Setup as S
11import qualified Distribution.Simple.Program as P
12import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, rewriteFile)
13import Distribution.PackageDescription
14import Distribution.Text
17import System.FilePath ((</>), splitDirectories)
18import System.Directory
19import qualified System.FilePath.Posix as Px
21import qualified Data.Text as T
22import qualified Data.Text.IO as TIO
24-- After Idris is built, we need to check and install the prelude and other libs
26-- -----------------------------------------------------------------------------
29-- make on mingw32 exepects unix style separators
32idrisCmd local = Px.joinPath $ splitDirectories $ ".." <//> ".." <//> buildDir local <//> "idris" <//> "idris"
34idrisCmd local = ".." </> ".." </> buildDir local </> "idris" </> "idris"
37-- -----------------------------------------------------------------------------
40-- use GNU make on FreeBSD
47 P.runProgramInvocation verbosity . P.simpleProgramInvocation mymake
49-- -----------------------------------------------------------------------------
52usesLLVM :: S.ConfigFlags -> Bool
54 case lookup (FlagName "llvm") (S.configConfigurationsFlags flags) of
59usesGMP :: S.ConfigFlags -> Bool
61 case lookup (FlagName "gmp") (S.configConfigurationsFlags flags) of
66isRelease :: S.ConfigFlags -> Bool
68 case lookup (FlagName "release") (S.configConfigurationsFlags flags) of
73-- -----------------------------------------------------------------------------
76idrisClean _ flags _ _ = do
80 verbosity = S.fromFlag $ S.cleanVerbosity flags
85 cleanLLVM = makeClean "llvm"
87 makeClean dir = make verbosity [ "-C", dir, "clean", "IDRIS=idris" ]
90-- -----------------------------------------------------------------------------
93idrisConfigure _ flags _ local = do
97 verbosity = S.fromFlag $ S.configVerbosity flags
98 version = pkgVersion . package $ localPkgDescr local
100 -- This is a hack. I don't know how to tell cabal that a data file needs
101 -- installing but shouldn't be in the distribution. And it won't make the
102 -- distribution if it's not there, so instead I just delete
103 -- the file after configure.
104 configureRTS = make verbosity ["-C", "rts", "clean"]
106 -- Put the Git hash into a module for use in the program
107 -- For release builds, just put the empty string in the module
108 generateVersionModule = do
109 gitHash <- Control.Exception.catch (readProcess "git" ["rev-parse", "--short", "HEAD"] "")
110 (\e -> let e' = (e :: SomeException) in return "PRE")
111 let hash = takeWhile (/= '\n') gitHash
112 let versionModulePath = autogenModulesDir local </> "Version_idris" Px.<.> "hs"
113 createDirectoryIfMissingVerbose verbosity True (autogenModulesDir local)
114 rewriteFile versionModulePath (versionModuleContents hash)
116 versionModuleContents h = "module Version_idris where\n\n" ++
117 "gitHash :: String\n" ++
118 if isRelease (configFlags local)
119 then "gitHash = \"\"\n"
120 else "gitHash = \"-git:" ++ h ++ "\"\n"
123-- -----------------------------------------------------------------------------
126idrisBuild _ flags _ local = do
129 when (usesLLVM $ configFlags local) buildLLVM
131 verbosity = S.fromFlag $ S.buildVerbosity flags
134 putStrLn "Building libraries..."
137 makeBuild dir = make verbosity [ "-C", dir, "build" , "IDRIS=" ++ idrisCmd local]
139 buildRTS = make verbosity (["-C", "rts", "build"] ++
140 gmpflag (usesGMP (configFlags local)))
142 buildLLVM = make verbosity ["-C", "llvm", "build"]
145 gmpflag True = ["GMP=-DIDRIS_GMP"]
147-- -----------------------------------------------------------------------------
150idrisInstall verbosity copy pkg local = do
153 when (usesLLVM $ configFlags local) installLLVM
155 target = datadir $ L.absoluteInstallDirs pkg local copy
158 putStrLn $ "Installing libraries in " ++ target
159 makeInstall "libs" target
162 let target' = target </> "rts"
163 putStrLn $ "Installing run time system in " ++ target'
164 makeInstall "rts" target'
167 let target' = target </> "llvm"
168 putStrLn $ "Installing LLVM library in " ++ target
169 makeInstall "llvm" target'
171 makeInstall src target =
172 make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
174-- -----------------------------------------------------------------------------
177-- Install libraries during both copy and install
178-- See http://hackage.haskell.org/trac/hackage/ticket/718
179main = defaultMainWithHooks $ simpleUserHooks
180 { postClean = idrisClean
181 , postConf = idrisConfigure
182 , postBuild = idrisBuild
183 , postCopy = \_ flags pkg local ->
184 idrisInstall (S.fromFlag $ S.copyVerbosity flags)
185 (S.fromFlag $ S.copyDest flags) pkg local
186 , postInst = \_ flags pkg local ->
187 idrisInstall (S.fromFlag $ S.installVerbosity flags)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list