Skip to content

Commit

Permalink
Get cabal to check library after install
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Brady committed Dec 15, 2011
1 parent 6d01c6b commit ec7c1b8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
33 changes: 33 additions & 0 deletions Setup.hs
@@ -0,0 +1,33 @@
import Distribution.Simple
import Distribution.Simple.InstallDirs as I
import Distribution.Simple.LocalBuildInfo as L
import Distribution.PackageDescription

import System.Exit
import System.Process

-- After Idris is built, we need to check and install the prelude and other libs

system' cmd = do
exit <- system cmd
case exit of
ExitSuccess -> return ()
ExitFailure _ -> exitWith exit

postCleanLib args flags desc _
= system' "make -C lib clean"

addPrefix pfx var c = "export " ++ var ++ "=" ++ show pfx ++ "/" ++ c ++ ":$" ++ var

postInstLib args flags desc local
= do let pkg = localPkgDescr local
let penv = packageTemplateEnv (package pkg)
let dirs = substituteInstallDirTemplates penv (installDirTemplates local)
let idir = fromPathTemplate (datadir dirs) ++ "/" ++
fromPathTemplate (datasubdir dirs)
system' $ "make -C lib install TARGET=" ++ idir

main = defaultMainWithHooks (simpleUserHooks { postInst = postInstLib,
postClean = postCleanLib })


5 changes: 2 additions & 3 deletions idris.cabal
Expand Up @@ -16,10 +16,9 @@ Description: Idris is an experimental language with full dependent types.
related to Epigram and Agda. There is a tutorial at <http://www.idris-lang.org/tutorial.html>.

Cabal-Version: >= 1.6
Build-type: Simple
Build-type: Custom

Data-files: *.idr prelude/*.idr
Data-dir: lib
Extra-source-files: lib/Makefile lib/*.idr lib/prelude/*.idr

Executable idris
Main-is: Main.hs
Expand Down
5 changes: 5 additions & 0 deletions lib/Makefile
Expand Up @@ -7,6 +7,11 @@ check: .PHONY

recheck: clean check

install: check
install *.ibc $(TARGET)
mkdir -p $(TARGET)/prelude
install prelude/*.ibc $(TARGET)/prelude

clean: .PHONY
rm -f *.ibc
rm -f prelude/*.ibc
Expand Down
15 changes: 9 additions & 6 deletions src/Idris/IBC.hs
Expand Up @@ -16,6 +16,7 @@ import Data.ByteString.Lazy as B hiding (length, elem)
import Control.Monad
import Control.Monad.State hiding (get, put)
import System.FilePath
import System.Directory
import System.Posix.Files

import Paths_idris
Expand Down Expand Up @@ -53,7 +54,7 @@ writeIBC src f
= do iLOG $ "Writing ibc " ++ show f
i <- getIState
case idris_metavars i \\ primDefs of
(_:_) -> fail "Can't write ibc when there are unsolve metavariables"
(_:_) -> fail "Can't write ibc when there are unsolved metavariables"
[] -> return ()
ibcf <- mkIBC (ibc_write i) (initIBC { sourcefile = src })
lift $ encodeFile f ibcf
Expand Down Expand Up @@ -108,11 +109,13 @@ process i fn
pDefs (ibc_defs i)

timestampOlder :: FilePath -> FilePath -> IO ()
timestampOlder src ibc = do srcs <- getFileStatus src
ibcs <- getFileStatus ibc
if (modificationTime srcs > modificationTime ibcs)
then fail "Needs reloading"
else return ()
timestampOlder src ibc = do srcok <- doesFileExist src
when srcok $ do
srcs <- getFileStatus src
ibcs <- getFileStatus ibc
if (modificationTime srcs > modificationTime ibcs)
then fail "Needs reloading"
else return ()

pImports :: [FilePath] -> Idris ()
pImports fs
Expand Down

0 comments on commit ec7c1b8

Please sign in to comment.