@@ -20,158 +20,138 @@ import qualified Data.Text.IO as TIO
21-- After Idris is built, we need to check and install the prelude and other libs
21-- After Idris is built, we need to check and install the prelude and other libs
23−make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
23+-- -----------------------------------------------------------------------------
25−#ifdef mingw32_HOST_OS
26-- make on mingw32 exepects unix style separators
26-- make on mingw32 exepects unix style separators
27+#ifdef mingw32_HOST_OS
27(<//>) = (Px.</>)
28(<//>) = (Px.</>)
28−idrisCmd local = Px.joinPath $ splitDirectories $
29+idrisCmd local = Px.joinPath $ splitDirectories $ ".." <//> buildDir local <//> "idris" <//> "idris"
29− ".." <//> buildDir local <//> "idris" <//> "idris"
30−rtsDir local = Px.joinPath $ splitDirectories $
31− ".." <//> buildDir local <//> "rts" <//> "libidris_rts"
33idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
31idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
34−rtsDir local = ".." </> buildDir local </> "rts" </> "libidris_rts"
37−cleanStdLib verbosity
34+-- -----------------------------------------------------------------------------
38− = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
35+-- Make Commands
39− make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
36+
40− make verbosity [ "-C", "javascript", "clean", "IDRIS=idris" ]
37+make verbosity =
41−
38+ P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
42−cleanJavaPom verbosity
39+
43− = do execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
40+-- -----------------------------------------------------------------------------
44− when execPomExists $ removeFile ("java" </> "executable_pom.xml")
41+-- Flags
46−cleanLLVMLib verbosity = make verbosity ["-C", "llvm", "clean"]
43+usesLLVM :: S.ConfigFlags -> Bool
48−installStdLib pkg local withoutEffects verbosity copy
49− = do let dirs = L.absoluteInstallDirs pkg local copy
50− let idir = datadir dirs
51− let icmd = idrisCmd local
52− putStrLn $ "Installing libraries in " ++ idir
54− [ "-C", "lib", "install"
58− unless withoutEffects $
60− [ "-C", "effects", "install"
65− [ "-C", "javascript", "install"
69− let idirRts = idir </> "rts"
70− putStrLn $ "Installing run time system in " ++ idirRts
72− [ "-C", "rts", "install"
73− , "TARGET=" ++ idirRts
77−installLLVMLib verbosity pkg local copy =
78− let idir = datadir $ L.absoluteInstallDirs pkg local copy in
79− make verbosity ["-C", "llvm", "install", "TARGET=" ++ idir </> "llvm"]
81−buildLLVMLib verbosity = make verbosity ["-C", "llvm", "all"]
83−installJavaPom pkg local verbosity copy version = do
84− putStrLn $ "Installing java pom template"
85− let dir = datadir $ L.absoluteInstallDirs pkg local copy
86− copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
88−-- This is a hack. I don't know how to tell cabal that a data file needs
89−-- installing but shouldn't be in the distribution. And it won't make the
90−-- distribution if it's not there, so instead I just delete
91−-- the file after configure.
93−removeLibIdris local verbosity
94− = do let icmd = idrisCmd local
96− [ "-C", "rts", "clean"
100−checkStdLib local withoutEffects verbosity
101− = do let icmd = idrisCmd local
102− putStrLn $ "Building libraries..."
104− [ "-C", "lib", "check"
107− unless withoutEffects $
109− [ "-C", "effects", "check"
113− [ "-C", "javascript", "check"
117− [ "-C", "rts", "check"
122 case lookup (FlagName "llvm") (S.configConfigurationsFlags flags) of
45 case lookup (FlagName "llvm") (S.configConfigurationsFlags flags) of
123 Just True -> True
46 Just True -> True
124 Just False -> False
47 Just False -> False
125 Nothing -> True
48 Nothing -> True
127−noEffectsFlag flags =
50+usesEffects :: S.ConfigFlags -> Bool
128− case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
52+ case lookup (FlagName "effects") (S.configConfigurationsFlags flags) of
129 Just True -> True
53 Just True -> True
130 Just False -> False
54 Just False -> False
131− Nothing -> False
55+ Nothing -> True
57+-- -----------------------------------------------------------------------------
60+idrisClean _ flags _ _ = do
64+ verbosity = S.fromFlag $ S.cleanVerbosity flags
69+ makeClean "javascript"
71+ cleanLLVM = makeClean "llvm"
73+ makeClean dir = make verbosity [ "-C", dir, "clean", "IDRIS=idris" ]
76+-- -----------------------------------------------------------------------------
79+idrisConfigure _ flags _ local = do
82+ verbosity = S.fromFlag $ S.configVerbosity flags
83+ version = pkgVersion . package $ localPkgDescr local
85+ -- This is a hack. I don't know how to tell cabal that a data file needs
86+ -- installing but shouldn't be in the distribution. And it won't make the
87+ -- distribution if it's not there, so instead I just delete
88+ -- the file after configure.
89+ configureRTS = make verbosity ["-C", "rts", "clean"]
91+-- -----------------------------------------------------------------------------
94+idrisBuild _ flags _ local = do
97+ when (usesLLVM $ configFlags local) buildLLVM
99+ verbosity = S.fromFlag $ S.buildVerbosity flags
102+ putStrLn "Building libraries..."
104+ when (usesEffects $ configFlags local) $ makeBuild "effects"
105+ makeBuild "javascript"
107+ makeBuild dir = make verbosity [ "-C", dir, "build" , "IDRIS=" ++ idrisCmd local]
109+ buildRTS = make verbosity ["-C", "rts", "build"]
111+ buildLLVM = make verbosity ["-C", "llvm", "build"]
113+-- -----------------------------------------------------------------------------
116+idrisInstall verbosity copy pkg local = do
119+ when (usesLLVM $ configFlags local) installLLVM
121+ target = datadir $ L.absoluteInstallDirs pkg local copy
124+ putStrLn $ "Installing libraries in " ++ target
125+ makeInstall "lib" target
126+ when (usesEffects $ configFlags local) $ makeInstall "effects" target
127+ makeInstall "javascript" target
130+ let target' = target </> "rts"
131+ putStrLn $ "Installing run time system in " ++ target'
132+ makeInstall "rts" target'
135+ let target' = target </> "llvm"
136+ putStrLn $ "Installing LLVM library in " ++ target
137+ makeInstall "llvm" target
139+ makeInstall src target =
140+ make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
133−preparePoms version
142+-- -----------------------------------------------------------------------------
134− = do execPomTemplate <- TIO.readFile ("java" </> "executable_pom_template.xml")
143+-- Main
135− TIO.writeFile ("java" </> "executable_pom.xml") (insertVersion execPomTemplate)
137− insertVersion template =
138− T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
140-- Install libraries during both copy and install
145-- Install libraries during both copy and install
141-- See http://hackage.haskell.org/trac/hackage/ticket/718
146-- See http://hackage.haskell.org/trac/hackage/ticket/718
143− defaultMainWithHooks $ simpleUserHooks
147+main = defaultMainWithHooks $ simpleUserHooks
148+ { postClean = idrisClean
149+ , postConf = idrisConfigure
150+ , postBuild = idrisBuild
144− { postCopy = \ _ flags pkg lbi -> do
151+ , postCopy = \_ flags pkg local ->
145− let verb = S.fromFlag $ S.copyVerbosity flags
152+ idrisInstall (S.fromFlag $ S.copyVerbosity flags)
146− let withoutEffects = noEffectsFlag $ configFlags lbi
147− installStdLib pkg lbi withoutEffects verb
148− (S.fromFlag $ S.copyDest flags)
149− installJavaPom pkg lbi verb
150− (S.fromFlag $ S.copyDest flags)
153+ (S.fromFlag $ S.copyDest flags) pkg local
151− (pkgVersion . package $ localPkgDescr lbi)
152− when (llvmFlag $ configFlags lbi)
153− (installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags))
154− , postInst = \ _ flags pkg lbi -> do
154+ , postInst = \_ flags pkg local ->
155− let verb = (S.fromFlag $ S.installVerbosity flags)
155+ idrisInstall (S.fromFlag $ S.installVerbosity flags)
156− let withoutEffects = noEffectsFlag $ configFlags lbi
157− installStdLib pkg lbi withoutEffects verb
159− installJavaPom pkg lbi verb
160− NoCopyDest
156+ NoCopyDest pkg local
161− (pkgVersion . package $ localPkgDescr lbi)
162− when (llvmFlag $ configFlags lbi)
163− (installLLVMLib verb pkg lbi NoCopyDest)
164− , postConf = \ _ flags _ lbi -> do
165− removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
166− preparePoms . pkgVersion . package $ localPkgDescr lbi
167− , postClean = \ _ flags _ _ -> do
168− let verb = S.fromFlag $ S.cleanVerbosity flags
172− , postBuild = \ _ flags _ lbi -> do
173− let verb = S.fromFlag $ S.buildVerbosity flags
174− when (llvmFlag $ configFlags lbi) (buildLLVMLib verb)
175− let withoutEffects = noEffectsFlag $ configFlags lbi
176− checkStdLib lbi withoutEffects verb