Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Variable
- data Recipe
- class MonadAction a m => RefInput a m x where
- class Monad m => RefOutput m x where
- data CakeString
- string :: String -> CakeString
- type A a = A' (Make' IO) a
- type Make a = Make' IO a
- buildMake :: MakeState -> Either String String
- runMake :: Make a -> IO String
- writeMake :: File -> Make a -> IO ()
- includeMakefile :: Foldable t => t File -> Make ()
- class Monad m => MonadMake m where
- rule :: A a -> Make a
- rule2 :: MonadMake m => A a -> m (Recipe, a)
- rule' :: MonadMake m => A a -> m a
- phony :: Monad m => String -> A' m ()
- depend :: RefInput a m x => x -> a ()
- produce :: RefOutput m x => x -> A' m ()
- ignoreDepends :: Monad m => A' m a -> A' m a
- prebuild :: MonadMake m => CommandGen -> m ()
- postbuild :: MonadMake m => CommandGen -> m ()
- class FileLike a where
- combine :: a -> String -> a
- takeDirectory :: a -> a
- takeBaseName :: a -> String
- takeFileName :: a -> String
- makeRelative :: a -> a -> a
- replaceExtension :: a -> String -> a
- takeExtension :: a -> String
- takeExtensions :: a -> String
- dropExtensions :: a -> a
- dropExtension :: a -> a
- type File = FileT FilePath
- file' :: ProjectLocation -> String -> File
- (.=) :: FileLike a => a -> String -> a
- (</>) :: FileLike a => a -> String -> a
- toFilePath :: FileT FilePath -> FilePath
- readFileForMake :: MonadMake m => File -> m ByteString
- genFile :: MonadMake m => File -> String -> m File
- genTmpFile :: MonadMake m => String -> m File
- genTmpFileWithPrefix :: MonadMake m => String -> String -> m File
- prerequisites :: (Applicative m, Monad m) => A' m (Set File)
- shell :: Monad m => CommandGen' m -> A' m [File]
- unsafeShell :: Monad m => CommandGen' m -> A' m [File]
- cmd :: QuasiQuoter
- makevar :: String -> String -> Variable
- extvar :: String -> Variable
- newtype CommandGen' m = CommandGen' {}
- make :: Variable
- data ProjectLocation = ProjectLocation {}
- currentDirLocation :: MonadIO m => m ProjectLocation
- module Data.String
- module Control.Monad
- module Control.Applicative
Documentation
The representation of Makefile variable
Recipe answers to the question 'How to build the targets'. Internally, it contains sets of targets and prerequisites, as well as shell commands required to build former from latter
class MonadAction a m => RefInput a m x where Source
Class of things which may be referenced using '$(expr)' from inside of quasy-quoted shell expressions
MonadAction a m => RefInput a m CakeString | |
MonadAction a m => RefInput a m Variable | |
MonadAction a m => RefInput a m Recipe | |
MonadAction a m => RefInput a m File | |
MonadAction a m => RefInput a m UWExe | |
MonadAction a m => RefInput a m UWLib | |
MonadAction a m => RefInput a m (CommandGen' m) | |
RefInput a m x => RefInput a m (Maybe x) | |
(RefInput a m x, MonadMake a) => RefInput a m (Make x) | |
(MonadAction a m, MonadMake a) => RefInput a m (Make Recipe) | |
(MonadIO a, RefInput a m x) => RefInput a m (IO x) | |
MonadAction a m => RefInput a m (Set File) | |
RefInput a m x => RefInput a m [x] |
class Monad m => RefOutput m x where Source
Class of things which may be referenced using '@(expr)' syntax of the quasi-quoted shell expressions.
data CakeString Source
Simple wrapper for strings, a target for various typeclass instances.
Eq CakeString | |
Ord CakeString | |
Show CakeString | |
MonadAction a m => RefInput a m CakeString |
string :: String -> CakeString Source
An alias to CakeString constructor
buildMake :: MakeState -> Either String String Source
Render the Makefile. Return either the content (Right), or error messages (Left).
runMake :: Make a -> IO String Source
A General Make runner. Executes the monad, returns the Makefile as a String. Errors go to stdout. fail is possible.
Execute the Make monad, build the Makefile, write it to the output file. Also note, that errors (if any) go to the stderr. fail will be executed in such cases
includeMakefile :: Foldable t => t File -> Make () Source
Add 'include ...' directive to the final Makefile for each input file.
class Monad m => MonadMake m where Source
A Monad providing access to MakeState. TODO: not mention IO here.
A version of rule2. Rule places it's recipe above all recipies defined so far.
:: MonadMake m | |
=> A a | Recipe builder |
-> m (Recipe, a) | The recipe itself and the recipe builder's result |
Build a Recipe using the builder provided and record it to the MakeState. Return the copy of Recipe (which should not be changed in future) and the result of recipe builder. The typical recipe builder result is the list of it's targets.
Example Lets declare a rule which builds "main.o" out of "main.c" and CFLAGS variable
let c = file "main.c" rule $ shell [cmd| gcc -c $(extvar "CFLAGS") -o @(c.="o") $c |]
Adds the phony target for a rule. Typical usage:
rule $ do phony "clean" unsafeShell [cmd|rm $elf $os $d|]
:: RefInput a m x | |
=> x | File or [File] or (Set File) or other form of dependency. |
-> a () |
Add it's argument to the list of dependencies (prerequsites) of a current recipe under construction
Declare that current recipe produces some producable item.
ignoreDepends :: Monad m => A' m a -> A' m a Source
Modifie the recipe builder: ignore all the dependencies
prebuild :: MonadMake m => CommandGen -> m () Source
Add prebuild command
postbuild :: MonadMake m => CommandGen -> m () Source
Add prebuild command
combine :: a -> String -> a Source
takeDirectory :: a -> a Source
takeBaseName :: a -> String Source
takeFileName :: a -> String Source
makeRelative :: a -> a -> a Source
replaceExtension :: a -> String -> a Source
takeExtension :: a -> String Source
takeExtensions :: a -> String Source
dropExtensions :: a -> a Source
dropExtension :: a -> a Source
file' :: ProjectLocation -> String -> File Source
toFilePath :: FileT FilePath -> FilePath Source
Convert File back to FilePath
:: MonadMake m | |
=> File | File to read contents of |
-> m ByteString |
Obtain the contents of a File. Note, that this generally means, that Makefile should be regenerated each time the File is changed.
genTmpFile :: MonadMake m => String -> m File Source
prerequisites :: (Applicative m, Monad m) => A' m (Set File) Source
Get a list of prerequisites added so far
:: Monad m | |
=> CommandGen' m | Command builder as returned by cmd quasi-quoter |
-> A' m [File] |
Apply the recipe builder to the current recipe state. Return the list of
targets of the current Recipe
under construction
unsafeShell :: Monad m => CommandGen' m -> A' m [File] Source
Version of shell
which doesn't track it's dependencies
cmd :: QuasiQuoter Source
Has effect of a function QQ -> CommandGen
where QQ is a string supporting
the following syntax:
- $(expr) evaluates to expr and adds it to the list of dependencies (prerequsites)
- @(expr) evaluates to expr and adds it to the list of targets
- $$ and @@ evaluates to $ and @
Example
[cmd|gcc $flags -o @file|]
is equivalent to
return $ CommandGen $ do s1 <- refInput "gcc " s2 <- refInput (flags :: Variable) s3 <- refInput " -o " s4 <- refOutput (file :: File) return (s1 ++ s2 ++ s3 ++ s4)
Later, this command may be examined or passed to the shell function to apply it to the recipe
Declare the variable which is defined in the current Makefile and has it's default value
newtype CommandGen' m Source
CommandGen is a recipe-builder packed in the newtype to prevent partial expantion of it's commands
MonadAction a m => RefInput a m (CommandGen' m) |
currentDirLocation :: MonadIO m => m ProjectLocation Source
module Data.String
module Control.Monad
module Control.Applicative