Compare commits
2 Commits
6fc30272aa
...
e7160485b6
Author | SHA1 | Date |
---|---|---|
Rachel Lambda Samuelsson | e7160485b6 | |
Rachel Lambda Samuelsson | c25ca6c0cb |
24
Setup.hs
24
Setup.hs
|
@ -3,15 +3,31 @@ import System.Process
|
|||
import System.Environment
|
||||
import System.Directory
|
||||
|
||||
libdir :: String
|
||||
libdir = "src"
|
||||
target :: String
|
||||
target = "src/Hm"
|
||||
|
||||
source :: String
|
||||
source = "hm.cf"
|
||||
|
||||
regenerateGrammar :: IO ()
|
||||
regenerateGrammar = do
|
||||
callProcess "bnfc" ["-d", "--text-token", "--functor", source]
|
||||
removePathForcibly target
|
||||
renameDirectory "Hm" target
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
(a:_) <- getArgs
|
||||
if a == "build"
|
||||
then do
|
||||
callProcess "bnfc" ["-d", "--text-token", "--functor", "hm.cf"]
|
||||
renameDirectory "Hm" (libdir <> "/Hm")
|
||||
b <- doesDirectoryExist target
|
||||
if not b
|
||||
then regenerateGrammar
|
||||
else do
|
||||
sourceDate <- getModificationTime source
|
||||
targetDate <- getModificationTime target
|
||||
if sourceDate >= targetDate
|
||||
then regenerateGrammar
|
||||
else pure ()
|
||||
else pure ()
|
||||
defaultMain
|
||||
|
|
Loading…
Reference in New Issue