@@ -1,24 +1,31 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2import Distribution.Simple
5import Distribution.Simple
3import Distribution.Simple.InstallDirs as I
6import Distribution.Simple.InstallDirs as I
4import Distribution.Simple.LocalBuildInfo as L
7import Distribution.Simple.LocalBuildInfo as L
5import qualified Distribution.Simple.Setup as S
8import qualified Distribution.Simple.Setup as S
6import qualified Distribution.Simple.Program as P
9import qualified Distribution.Simple.Program as P
7import Distribution.PackageDescription
10import Distribution.PackageDescription
11+import Distribution.Text
9import System.Exit
13import System.Exit
10import System.FilePath ((</>), splitDirectories)
14import System.FilePath ((</>), splitDirectories)
15+import System.Directory
11import qualified System.FilePath.Posix as Px
16import qualified System.FilePath.Posix as Px
12import System.Process
17import System.Process
14-- After Idris is built, we need to check and install the prelude and other libs
20-- After Idris is built, we need to check and install the prelude and other libs
16make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
22make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
23+mvn verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "mvn"
18#ifdef mingw32_HOST_OS
25#ifdef mingw32_HOST_OS
19-- make on mingw32 exepects unix style separators
26-- make on mingw32 exepects unix style separators
20(<//>) = (Px.</>)
27(<//>) = (Px.</>)
21−idrisCmd local = Px.joinPath $ splitDirectories $
28+idrisCmd local = Px.joinPath $ splitDirectories $
22 ".." <//> buildDir local <//> "idris" <//> "idris"
29 ".." <//> buildDir local <//> "idris" <//> "idris"
24idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
31idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
@@ -28,6 +35,12 @@ cleanStdLib verbosity
28 = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
35 = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
29 make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
36 make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
38+cleanJavaLib verbosity
39+ = do dirty <- doesDirectoryExist ("java" </> "target")
40+ when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
41+ pomExists <- doesFileExist ("java" </> "pom.xml")
42+ when pomExists $ removeFile ("java" </> "pom.xml")
31installStdLib pkg local verbosity copy
44installStdLib pkg local verbosity copy
32 = do let dirs = L.absoluteInstallDirs pkg local copy
45 = do let dirs = L.absoluteInstallDirs pkg local copy
33 let idir = datadir dirs
46 let idir = datadir dirs
@@ -51,6 +64,8 @@ installStdLib pkg local verbosity copy
51 , "IDRIS=" ++ icmd
64 , "IDRIS=" ++ icmd
67+installJavaLib verbosity = mvn verbosity [ "-f", "java/pom.xml", "install" ]
54-- This is a hack. I don't know how to tell cabal that a data file needs
69-- This is a hack. I don't know how to tell cabal that a data file needs
55-- installing but shouldn't be in the distribution. And it won't make the
70-- installing but shouldn't be in the distribution. And it won't make the
56-- distribution if it's not there, so instead I just delete
71-- distribution if it's not there, so instead I just delete
@@ -79,19 +94,44 @@ checkStdLib local verbosity
79 , "IDRIS=" ++ icmd
94 , "IDRIS=" ++ icmd
97+checkJavaLib verbosity = mvn verbosity [ "-f", "java/pom.xml", "package" ]
100+ case lookup (FlagName "nojava") (S.configConfigurationsFlags flags) of
106+ = do pomTemplate <- readFile ("java" </> "pom_template.xml")
107+ writeFile ("java" </> "pom.xml") (unlines . map insertVersion $ lines pomTemplate)
109+ insertVersion " <version></version>" = " <version>" ++ display version ++ "</version>"
110+ insertVersion other = other
82-- Install libraries during both copy and install
112-- Install libraries during both copy and install
83-- See http://hackage.haskell.org/trac/hackage/ticket/718
113-- See http://hackage.haskell.org/trac/hackage/ticket/718
84−main = defaultMainWithHooks $ simpleUserHooks
115+ defaultMainWithHooks $ simpleUserHooks
85 { postCopy = \ _ flags pkg lbi -> do
116 { postCopy = \ _ flags pkg lbi -> do
86− installStdLib pkg lbi (S.fromFlag $ S.copyVerbosity flags)
117+ let verb = S.fromFlag $ S.copyVerbosity flags
118+ installStdLib pkg lbi verb
87 (S.fromFlag $ S.copyDest flags)
119 (S.fromFlag $ S.copyDest flags)
88 , postInst = \ _ flags pkg lbi -> do
120 , postInst = \ _ flags pkg lbi -> do
89− installStdLib pkg lbi (S.fromFlag $ S.installVerbosity flags)
121+ let verb = (S.fromFlag $ S.installVerbosity flags)
122+ installStdLib pkg lbi verb
90 NoCopyDest
123 NoCopyDest
124+ unless (noJavaFlag $ configFlags lbi) (installJavaLib verb)
91 , postConf = \ _ flags _ lbi -> do
125 , postConf = \ _ flags _ lbi -> do
92 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
126 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
127+ unless (noJavaFlag $ configFlags lbi)
128+ (preparePom . pkgVersion . package $ localPkgDescr lbi)
93 , postClean = \ _ flags _ _ -> do
129 , postClean = \ _ flags _ _ -> do
94− cleanStdLib (S.fromFlag $ S.cleanVerbosity flags)
130+ let verb = S.fromFlag $ S.cleanVerbosity flags
95 , postBuild = \ _ flags _ lbi -> do
133 , postBuild = \ _ flags _ lbi -> do
96− checkStdLib lbi (S.fromFlag $ S.buildVerbosity flags)
134+ let verb = S.fromFlag $ S.buildVerbosity flags
135+ checkStdLib lbi verb
136+ unless (noJavaFlag $ configFlags lbi) (checkJavaLib verb)