buildbox- Rehackable components for writing buildbots and test harnesses.




Defines the main Build monad and common utils.



data BuildError Source

The errors we recognise.


ErrorOther String

Some generic error


Some system command fell over, and it barfed out the given stdout and stderr.

ErrorIOError IOError

Some miscellanous IO action failed.

forall prop . Show prop => ErrorCheckFailed Bool prop

Some property check was supposed to return the given boolean value, but it didn't.

ErrorNeeds FilePath

A build command needs the following file to continue. This can be used for writing make-like bots.

data BuildState Source

Global builder configuration.




buildStateLogSystem :: Maybe Handle

Log all system commands executed to this file handle.

buildStateId :: Integer

Uniqueish id for this build process. On POSIX we'd use the PID, but that doesn't work on Windows. The id is initialised by the Haskell random number generator on startup.

buildStateSeq :: Integer

Sequence number for generating fresh file names.

buildStateScratchDir :: FilePath

Scratch directory for making temp files.

buildStateDefault :: Integer -> FilePath -> BuildStateSource

The default build config.

type Build a = ErrorT BuildError (StateT BuildState IO) aSource

The builder monad encapsulates and IO action that can fail with an error, and also read some global configuration info.


runBuild :: FilePath -> Build a -> IO (Either BuildError a)Source

Run a build command. The first argument is a directory that can be used for temporary files (like "/tmp")

runBuildPrint :: FilePath -> Build a -> IO (Maybe a)Source

Like runBuild, but Run a build command, reporting whether it succeeded to the console. If it succeeded then return Just the result, else Nothing.

runBuildPrintWithState :: BuildState -> Build a -> IO (Maybe a)Source

Like runBuildPrintWithConfig but also takes a BuildConfig.

successfully :: IO a -> IO ()Source

Discard the resulting value of a compuation. Used like successfully . runBuild ...


throw :: BuildError -> Build aSource

Throw an error in the build monad.

needs :: FilePath -> Build ()Source

Throw a needs error saying we needs the given file. A catcher could then usefully create the file, or defer the compuation until it has been created.


io :: IO a -> Build aSource

Lift an IO action into the build monad. If the action throws any exceptions they get caught and turned into ErrorIOError exceptions in our Build monad.

whenM :: Monad m => m Bool -> m () -> m ()Source

Like when, but with teh monadz.


out :: Pretty a => a -> Build ()Source

Print some text to stdout.

outLn :: Pretty a => a -> Build ()Source

Print some text to stdout followed by a newline.

outBlank :: Build ()Source

Print a blank line to stdout

outLine :: Build ()Source

Print a ----- line to stdout

outLINE :: Build ()Source

Print a ===== line to stdout

logSystem :: String -> Build ()Source

Log a system command to the handle in our BuildConfig, if any.