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 "mvn"
27-- make on mingw32 exepects unix style separators
29idrisCmd local = Px.joinPath $ splitDirectories $
30 ".." <//> buildDir local <//> "idris" <//> "idris"
31rtsDir local = Px.joinPath $ splitDirectories $
32 ".." <//> buildDir local <//> "rts" <//> "libidris_rts"
34idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
35rtsDir local = ".." </> buildDir local </> "rts" </> "libidris_rts"
39 = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
40 make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
43 = do dirty <- doesDirectoryExist ("java" </> "target")
44 when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
45 pomExists <- doesFileExist ("java" </> "pom.xml")
46 when pomExists $ removeFile ("java" </> "pom.xml")
47 execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
48 when pomExists $ removeFile ("java" </> "executable_pom.xml")
50installStdLib pkg local verbosity copy
51 = do let dirs = L.absoluteInstallDirs pkg local copy
52 let idir = datadir dirs
53 let icmd = idrisCmd local
54 putStrLn $ "Installing libraries in " ++ idir
56 [ "-C", "lib", "install"
59 , "RTS=" ++ rtsDir local
62 [ "-C", "effects", "install"
65 , "RTS=" ++ rtsDir local
67 let idirRts = idir </> "rts"
68 putStrLn $ "Installing run time system in " ++ idirRts
70 [ "-C", "rts", "install"
71 , "TARGET=" ++ idirRts
73 , "RTS=" ++ rtsDir local
76installJavaLib pkg local verbosity copy version = do
77 let rtsFile = "idris-" ++ display version ++ ".jar"
78 putStrLn $ "Installing java libraries"
79 mvn verbosity [ "install:install-file"
80 , "-Dfile=" ++ ("java" </> "target" </> rtsFile)
81 , "-DgroupId=org.idris-lang"
82 , "-DartifactId=idris"
83 , "-Dversion=" ++ display version
85 , "-DgeneratePom=True"
87 let dir = datadir $ L.absoluteInstallDirs pkg local copy
88 copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
90-- This is a hack. I don't know how to tell cabal that a data file needs
91-- installing but shouldn't be in the distribution. And it won't make the
92-- distribution if it's not there, so instead I just delete
93-- the file after configure.
95removeLibIdris local verbosity
96 = do let icmd = idrisCmd local
98 [ "-C", "rts", "clean"
102checkStdLib local verbosity
103 = do let icmd = idrisCmd local
104 putStrLn $ "Building libraries..."
106 [ "-C", "lib", "check"
108 , "RTS=" ++ rtsDir local
111 [ "-C", "effects", "check"
113 , "RTS=" ++ rtsDir local
116 [ "-C", "rts", "check"
120buildRTS dir verbosity
121 = do putStrLn "Building RTS..."
123 [ "-C", "rts", "build"
127checkJavaLib verbosity = mvn verbosity [ "-f", "java" </> "pom.xml", "package" ]
130 case lookup (FlagName "java") (S.configConfigurationsFlags flags) of
136 = do pomTemplate <- TIO.readFile ("java" </> "pom_template.xml")
137 TIO.writeFile ("java" </> "pom.xml") (insertVersion pomTemplate)
138 execPomTemplate <- TIO.readFile ("java" </> "executable_pom_template.xml")
139 TIO.writeFile ("java" </> "executable_pom.xml") (insertVersion execPomTemplate)
141 insertVersion template =
142 T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
144-- Install libraries during both copy and install
145-- See http://hackage.haskell.org/trac/hackage/ticket/718
147 defaultMainWithHooks $ simpleUserHooks
148 { postCopy = \ _ flags pkg lbi -> do
149 let verb = S.fromFlag $ S.copyVerbosity flags
150 installStdLib pkg lbi verb
151 (S.fromFlag $ S.copyDest flags)
152 , postInst = \ _ flags pkg lbi -> do
153 let verb = (S.fromFlag $ S.installVerbosity flags)
154 installStdLib pkg lbi verb
156 when (javaFlag $ configFlags lbi)
161 (pkgVersion . package $ localPkgDescr lbi)
163 , postConf = \ _ flags _ lbi -> do
164 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
165 when (javaFlag $ configFlags lbi)
166 (preparePoms . pkgVersion . package $ localPkgDescr lbi)
167 , postClean = \ _ flags _ _ -> do
168 let verb = S.fromFlag $ S.cleanVerbosity flags
171 , postBuild = \ _ flags _ lbi -> do
172 let verb = S.fromFlag $ S.buildVerbosity flags
173 let distdir = buildDir lbi
174 buildRTS distdir verb
176 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