5import Distribution.Simple
6import Distribution.Simple.InstallDirs as I
7import Distribution.Simple.LocalBuildInfo as L
8import qualified Distribution.Simple.Setup as S
9import qualified Distribution.Simple.Program as P
10import Distribution.PackageDescription
11import Distribution.Text
14import System.FilePath ((</>), splitDirectories)
15import System.Directory
16import qualified System.FilePath.Posix as Px
18import qualified Data.Text as T
19import qualified Data.Text.IO as TIO
21-- After Idris is built, we need to check and install the prelude and other libs
23make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
24mvn verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation
32-- make on mingw32 exepects unix style separators
34idrisCmd local = Px.joinPath $ splitDirectories $
35 ".." <//> buildDir local <//> "idris" <//> "idris"
36rtsDir local = Px.joinPath $ splitDirectories $
37 ".." <//> buildDir local <//> "rts" <//> "libidris_rts"
39idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
40rtsDir local = ".." </> buildDir local </> "rts" </> "libidris_rts"
44 = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
45 make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
46 make verbosity [ "-C", "javascript", "clean", "IDRIS=idris" ]
49 = do dirty <- doesDirectoryExist ("java" </> "target")
50 when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
51 pomExists <- doesFileExist ("java" </> "pom.xml")
52 when pomExists $ removeFile ("java" </> "pom.xml")
53 execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
54 when pomExists $ removeFile ("java" </> "executable_pom.xml")
56cleanLLVMLib verbosity = make verbosity ["-C", "llvm", "clean"]
58installStdLib pkg local withoutEffects verbosity copy
59 = do let dirs = L.absoluteInstallDirs pkg local copy
60 let idir = datadir dirs
61 let icmd = idrisCmd local
62 putStrLn $ "Installing libraries in " ++ idir
64 [ "-C", "lib", "install"
68 unless withoutEffects $
70 [ "-C", "effects", "install"
75 [ "-C", "javascript", "install"
79 let idirRts = idir </> "rts"
80 putStrLn $ "Installing run time system in " ++ idirRts
82 [ "-C", "rts", "install"
83 , "TARGET=" ++ idirRts
87installLLVMLib verbosity pkg local copy =
88 let idir = datadir $ L.absoluteInstallDirs pkg local copy in
89 make verbosity ["-C", "llvm", "install", "TARGET=" ++ idir </> "llvm"]
91installJavaLib pkg local verbosity copy version = do
92 let rtsFile = "idris-" ++ display version ++ ".jar"
93 putStrLn $ "Installing java libraries"
94 mvn verbosity [ "install:install-file"
95 , "-Dfile=" ++ ("java" </> "target" </> rtsFile)
96 , "-DgroupId=org.idris-lang"
97 , "-DartifactId=idris"
98 , "-Dversion=" ++ display version
100 , "-DgeneratePom=True"
102 let dir = datadir $ L.absoluteInstallDirs pkg local copy
103 copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
105-- This is a hack. I don't know how to tell cabal that a data file needs
106-- installing but shouldn't be in the distribution. And it won't make the
107-- distribution if it's not there, so instead I just delete
108-- the file after configure.
110removeLibIdris local verbosity
111 = do let icmd = idrisCmd local
113 [ "-C", "rts", "clean"
117checkStdLib local withoutEffects verbosity
118 = do let icmd = idrisCmd local
119 putStrLn $ "Building libraries..."
121 [ "-C", "lib", "check"
124 unless withoutEffects $
126 [ "-C", "effects", "check"
130 [ "-C", "javascript", "check"
134 [ "-C", "rts", "check"
138checkJavaLib verbosity = mvn verbosity [ "-f", "java" </> "pom.xml", "package" ]
141 case lookup (FlagName "java") (S.configConfigurationsFlags flags) of
147 case lookup (FlagName "LLVM") (S.configConfigurationsFlags flags) of
153 case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
159 = do pomTemplate <- TIO.readFile ("java" </> "pom_template.xml")
160 TIO.writeFile ("java" </> "pom.xml") (insertVersion pomTemplate)
161 execPomTemplate <- TIO.readFile ("java" </> "executable_pom_template.xml")
162 TIO.writeFile ("java" </> "executable_pom.xml") (insertVersion execPomTemplate)
164 insertVersion template =
165 T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
167-- Install libraries during both copy and install
168-- See http://hackage.haskell.org/trac/hackage/ticket/718
170 defaultMainWithHooks $ simpleUserHooks
171 { postCopy = \ _ flags pkg lbi -> do
172 let verb = S.fromFlag $ S.copyVerbosity flags
173 let withoutEffects = noEffectsFlag $ configFlags lbi
174 installStdLib pkg lbi withoutEffects verb
175 (S.fromFlag $ S.copyDest flags)
176 when (llvmFlag $ configFlags lbi)
177 (installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags))
178 when (javaFlag $ configFlags lbi)
182 (S.fromFlag $ S.copyDest flags)
183 (pkgVersion . package $ localPkgDescr lbi)
185 , postInst = \ _ flags pkg lbi -> do
186 let verb = (S.fromFlag $ S.installVerbosity flags)
187 let withoutEffects = noEffectsFlag $ configFlags lbi
188 installStdLib pkg lbi withoutEffects verb
190 when (llvmFlag $ configFlags lbi)
191 (installLLVMLib verb pkg lbi NoCopyDest)
192 when (javaFlag $ configFlags lbi)
197 (pkgVersion . package $ localPkgDescr lbi)
199 , postConf = \ _ flags _ lbi -> do
200 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
201 when (javaFlag $ configFlags lbi)
202 (preparePoms . pkgVersion . package $ localPkgDescr lbi)
203 , postClean = \ _ flags _ _ -> do
204 let verb = S.fromFlag $ S.cleanVerbosity flags
208 , postBuild = \ _ flags _ lbi -> do
209 let verb = S.fromFlag $ S.buildVerbosity flags
210 let withoutEffects = noEffectsFlag $ configFlags lbi
211 checkStdLib lbi withoutEffects verb
212 when (javaFlag $ configFlags lbi) (checkJavaLib verb)
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