pass through args to yesod devel

This commit is contained in:
Greg Weber 2012-02-16 19:03:37 -08:00
parent 9b8b20e058
commit e1d584cf1f
2 changed files with 46 additions and 47 deletions

View File

@ -28,7 +28,7 @@ import System.Exit (exitFailure, exitSuccess, ExitCode (..))
import System.FilePath (splitDirectories, dropExtension, takeExtension)
import System.Posix.Types (EpochTime)
import System.PosixCompat.Files (modificationTime, getFileStatus)
import System.Process (runCommand, terminateProcess, readProcess,
import System.Process (createProcess, proc, terminateProcess, readProcess,
waitForProcess, rawSystem)
import Build (recompDeps, getDeps,findHaskellFiles)
@ -44,8 +44,8 @@ writeLock = do
removeLock :: IO ()
removeLock = try_ (removeFile lockFile)
devel :: Bool -> IO ()
devel isCabalDev = do
devel :: Bool -> [String] -> IO ()
devel isCabalDev passThroughArgs = do
checkDevelFile
@ -58,28 +58,29 @@ devel isCabalDev = do
checkCabalFile gpd
_ <- if isCabalDev
then rawSystem "cabal-dev"
[ "configure"
, "--cabal-install-arg=-fdevel" -- legacy
, "--cabal-install-arg=-flibrary-only"
, "--disable-library-profiling"
]
else rawSystem "cabal"
[ "configure"
, "-fdevel" -- legacy
, "-flibrary-only"
, "--disable-library-profiling"
]
_<- rawSystem cmd args
mainLoop isCabalDev
mainLoop
_ <- getLine
writeLock
exitSuccess
where
cmd | isCabalDev == True = "cabal-dev"
| otherwise = "cabal"
mainLoop :: Bool -> IO ()
mainLoop isCabalDev = do
diffArgs | isCabalDev == True = [
"--cabal-install-arg=-fdevel" -- legacy
, "--cabal-install-arg=-flibrary-only"
]
| otherwise = [
"-fdevel" -- legacy
, "-flibrary-only"
]
args = "configure":diffArgs ++ ["--disable-library-profiling" ]
mainLoop :: IO ()
mainLoop = do
ghcVer <- ghcVersion
forever $ do
putStrLn "Rebuilding application..."
@ -87,18 +88,16 @@ mainLoop isCabalDev = do
recompDeps
list <- getFileList
exit <- if isCabalDev
then rawSystem "cabal-dev" ["build"]
else rawSystem "cabal" ["build"]
exit <- rawSystem cmd ["build"]
case exit of
ExitFailure _ -> putStrLn "Build failure, pausing..."
_ -> do
removeLock
let pkg = pkgConfigs isCabalDev ghcVer
let start = concat ["runghc ", pkg, " devel.hs"]
putStrLn $ "Starting development server: " ++ start
ph <- runCommand start
let dev_args = ([pkg, "devel.hs"] ++ passThroughArgs)
putStrLn $ "Starting development server: runghc " ++ L.intercalate " " dev_args
(_,_,_,ph) <- createProcess $ proc "runghc" dev_args
watchTid <- forkIO . try_ $ do
watchForChanges list
putStrLn "Stopping development server..."

View File

@ -35,7 +35,7 @@ main = do
"build":rest -> touch >> build rest >>= exitWith
["touch"] -> touch
#endif
["devel"] -> devel isDev
"devel":rest -> devel isDev rest
["version"] -> putStrLn yesodVersion
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
_ -> do