Safe Haskell | None |
---|---|
Language | Haskell2010 |
General rules for writing consistent rattle build systems:
- Never write to the same file twice. Never read then write.
- Don't delete files that have been produced. Each command should make new files, not delete old files.
Synopsis
- rattleRun :: RattleOptions -> Run a -> IO a
- data Run a
- rattleDump :: (String -> IO ()) -> FilePath -> IO ()
- data Hazard
- data RattleOptions = RattleOptions {}
- rattleOptions :: RattleOptions
- data RattleUI
- cmd :: (Partial, CmdArguments args) => args :-> Action r
- data CmdOption
- = Cwd FilePath
- | Env [(String, String)]
- | AddEnv String String
- | RemEnv String
- | AddPath [String] [String]
- | Stdin String
- | StdinBS ByteString
- | FileStdin FilePath
- | Shell
- | BinaryPipes
- | Traced String
- | Timeout Double
- | WithStdout Bool
- | WithStderr Bool
- | EchoStdout Bool
- | EchoStderr Bool
- | FileStdout FilePath
- | FileStderr FilePath
- | AutoDeps
- | UserCommand String
- | FSAOptions String
- | CloseFileHandles
- | NoProcessGroup
- | InheritStdin
- data CmdOption2
- toCmdOption :: CmdOption2 -> CmdOption
- parallel :: [Run a] -> Run [a]
- forP :: [a] -> (a -> Run b) -> Run [b]
- forP_ :: [a] -> (a -> Run b) -> Run ()
- withCmdOptions :: [CmdOption] -> Run a -> Run a
- memo :: (Eq a, Hashable a, MonadIO m) => (a -> m b) -> m (a -> m b)
- memoRec :: (Eq a, Hashable a, MonadIO m) => ((a -> m b) -> a -> m b) -> m (a -> m b)
- cmdWriteFile :: FilePath -> String -> Run ()
- data Program a
- newProgram :: (Show a, Read a) => (a -> String) -> Q (TExp (a -> IO ())) -> Program a
- runProgram :: Show a => Program a -> a -> Run ()
- liftIO :: MonadIO m => IO a -> m a
- writeProfile :: RattleOptions -> FilePath -> IO ()
- graphData :: RattleOptions -> IO (Seconds, Seconds, Seconds)
Documentation
rattleRun :: RattleOptions -> Run a -> IO a Source #
Given an Action to run, and a list of previous commands that got run, run it again
Type of actions to run. Executed using rattle
.
Instances
Monad Run Source # | |
Functor Run Source # | |
Applicative Run Source # | |
MonadIO Run Source # | |
Defined in Development.Rattle.Server | |
a ~ () => CmdArguments (Run a) Source # | |
Defined in Development.Rattle.Server cmdArguments :: CmdArgument -> Run a # |
Type of exception thrown if there is a hazard when running the build system.
Instances
Show Hazard Source # | |
Exception Hazard Source # | |
Defined in Development.Rattle.Hazards toException :: Hazard -> SomeException # fromException :: SomeException -> Maybe Hazard # displayException :: Hazard -> String # |
data RattleOptions Source #
Basic options for configuring rattle.
RattleOptions | |
|
Instances
Show RattleOptions Source # | |
Defined in Development.Rattle.Options showsPrec :: Int -> RattleOptions -> ShowS # show :: RattleOptions -> String # showList :: [RattleOptions] -> ShowS # |
rattleOptions :: RattleOptions Source #
Default RattleOptions
value.
What UI should rattle show the user.
RattleSerial | Show a series of lines for each command run |
RattleFancy | Show a few lines that change as commands run |
RattleQuiet | Don't show commands |
cmd :: (Partial, CmdArguments args) => args :-> Action r #
Build or execute a system command. Before using cmd
to run a command, make sure you need
any files
that are used by the command.
String
arguments are treated as a list of whitespace separated arguments.[String]
arguments are treated as a list of literal arguments.CmdOption
arguments are used as options.CmdArgument
arguments, which can be built bycmd
itself, are spliced into the containing command.
Typically only string literals should be passed as String
arguments. When using variables
prefer [myvar]
so that if myvar
contains spaces they are properly escaped.
As some examples, here are some calls, and the resulting command string:
cmd_
"git log --pretty=" "oneline" -- git log --pretty= onelinecmd_
"git log --pretty=" ["oneline"] -- git log --pretty= onelinecmd_
"git log" ("--pretty=" ++ "oneline") -- git log --pretty=onelinecmd_
"git log" ("--pretty=" ++ "one line") -- git log --pretty=one linecmd_
"git log" ["--pretty=" ++ "one line"] -- git log "--pretty=one line"
More examples, including return values, see this translation of the examples given for the command
function:
cmd_
"gcc -c myfile.c" -- compile a file, throwing an exception on failureExit
c <-cmd
"gcc -c" [myfile] -- run a command, recording the exit code (Exit
c,Stderr
err) <-cmd
"gcc -c myfile.c" -- run a command, recording the exit code and error outputStdout
out <-cmd
"gcc -MM myfile.c" -- run a command, recording the outputcmd
(Cwd
"generated") "gcc -c" [myfile] ::Action
() -- run a command in a directory let gccCommand =cmd
"gcc -c" ::CmdArgument
-- build a sub-command.cmd
can returnCmdArgument
values as well as execute commands cmd (Cwd
"generated") gccCommand [myfile] -- splice that command into a greater command
If you use cmd
inside a do
block and do not use the result, you may get a compile-time error about being
unable to deduce CmdResult
. To avoid this error, use cmd_
. If you enable OverloadedStrings
or OverloadedLists
you may have to give type signatures to the arguments, or use the more constrained command
instead.
The cmd
function can also be run in the IO
monad, but then Traced
is ignored and command lines are not echoed.
As an example:
cmd
(Cwd
"generated")Shell
"gcc -c myfile.c" :: IO ()
Options passed to command
or cmd
to control how processes are executed.
Cwd FilePath | Change the current directory in the spawned process. By default uses this processes current directory.
Successive |
Env [(String, String)] | Change the environment variables in the spawned process. By default uses this processes environment. |
AddEnv String String | Add an environment variable in the child process. |
RemEnv String | Remove an environment variable from the child process. |
AddPath [String] [String] | Add some items to the prefix and suffix of the |
Stdin String | Given as the |
StdinBS ByteString | Given as the |
FileStdin FilePath | Take the |
Shell | Pass the command to the shell without escaping - any arguments will be joined with spaces. By default arguments are escaped properly. |
BinaryPipes | Treat the |
Traced String | Name to use with |
Timeout Double | Abort the computation after N seconds, will raise a failure exit code. Calls |
WithStdout Bool | Should I include the |
WithStderr Bool | Should I include the |
EchoStdout Bool | Should I echo the |
EchoStderr Bool | Should I echo the |
FileStdout FilePath | Should I put the |
FileStderr FilePath | Should I put the |
AutoDeps | Compute dependencies automatically. Only works if |
UserCommand String | The command the user thinks about, before any munging. Defaults to the actual command. |
FSAOptions String | Options to |
CloseFileHandles | Before starting the command in the child process, close all file handles except stdin, stdout, stderr in the child process. Uses |
NoProcessGroup | Don't run the process in its own group. Required when running |
InheritStdin | Cause the stdin from the parent to be inherited. Might also require NoProcessGroup on Linux. Ignored if you explicitly pass a stdin. |
Instances
data CmdOption2 Source #
A data type for additional rattle options
Instances
Read CmdOption2 Source # | |
Defined in Development.Rattle.CmdOption readsPrec :: Int -> ReadS CmdOption2 # readList :: ReadS [CmdOption2] # readPrec :: ReadPrec CmdOption2 # readListPrec :: ReadPrec [CmdOption2] # | |
Show CmdOption2 Source # | |
Defined in Development.Rattle.CmdOption showsPrec :: Int -> CmdOption2 -> ShowS # show :: CmdOption2 -> String # showList :: [CmdOption2] -> ShowS # | |
IsCmdArgument CmdOption2 Source # | |
Defined in Development.Rattle.CmdOption toCmdArgument :: CmdOption2 -> CmdArgument # |
toCmdOption :: CmdOption2 -> CmdOption Source #
Convert a new option into a standard one.
parallel :: [Run a] -> Run [a] Source #
Run a sequence of Run
actions in parallel. They will be run in parallel with no limit
on simultaneous executions.
withCmdOptions :: [CmdOption] -> Run a -> Run a Source #
Apply specific options ot all nested Run values.
memoRec :: (Eq a, Hashable a, MonadIO m) => ((a -> m b) -> a -> m b) -> m (a -> m b) Source #
Memoize an IO action which is recursive
newProgram :: (Show a, Read a) => (a -> String) -> Q (TExp (a -> IO ())) -> Program a Source #
Create a new program which is based on a TH splice.
writeProfile :: RattleOptions -> FilePath -> IO () Source #
Generate a profile report given a file.