Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Variable
- data Recipe
- class Monad a => RefInput a 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
- runMakeH :: MakeState -> (String -> IO b) -> IO (MakeState, b)
- runMakeH_ :: MakeState -> (String -> IO b) -> IO b
- writeMake :: File -> Make a -> IO ()
- includeMakefile :: Foldable t => t File -> Make ()
- class Monad m => MonadMake m where
- rule' :: MonadMake m => A a -> m (Recipe, a)
- rule :: A a -> Make a
- phony :: Monad m => String -> A' m ()
- depend :: RefInput a 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
- data FileT h a = FileT h a
- type File = FileT ModuleLocation FilePath
- data ModuleLocation = ModuleLocation {}
- file' :: ModuleLocation -> FilePath -> File
- (.=) :: FileLike a => a -> String -> a
- (</>) :: FileLike a => a -> String -> a
- topRel :: File -> FilePath
- readFileForMake :: MonadMake m => File -> m ByteString
- genFile' :: File -> String -> A () -> Make File
- genFile :: File -> String -> Make 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
- tool :: String -> Tool
- newtype CommandGen' m = CommandGen' {}
- make :: Variable
- currentDirLocation :: MonadIO m => m ModuleLocation
- gitSubmoduleFile :: File -> Make File
- 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 Monad a => RefInput a x where Source #
Class of things which may be referenced using '$(expr)' syntax of the quasy-quoted shell expressions
RefInput a x => RefInput a (Maybe x) Source # | |
(MonadIO a, RefInput a x) => RefInput a (IO x) Source # | |
RefInput a x => RefInput a (Set x) Source # | |
RefInput a x => RefInput a [x] Source # | |
(RefInput a x, MonadMake a) => RefInput a (Make x) Source # | |
Monad m => RefInput (A' m) CakeString Source # | |
Monad m => RefInput (A' m) Tool Source # | |
Monad m => RefInput (A' m) Variable Source # | |
Monad m => RefInput (A' m) Recipe Source # | |
Monad m => RefInput (A' m) File Source # | |
Monad m => RefInput (A' m) UWExe Source # | |
Monad m => RefInput (A' m) UWLib Source # | |
Monad m => RefInput (UrpGen m) File Source # | |
Monad m => RefInput (A' m) (CommandGen' m) Source # | |
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 Source # | |
Ord CakeString Source # | |
Show CakeString Source # | |
Monad m => RefInput (A' m) CakeString Source # | |
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 #
Execute the mk
monad, return the Makefile as a String. In case of
errors, print report to stderr and abort the execution with fail
call
A Generic Make monad runner. Execute the monad mk
, provide the output
handler with Makefile encoded as a string. Note that Makefile may contain
rules which references the file itself by the name makefile
. In case of
errors, print report to stderr and abort the execution with fail
call
A Version of runMakeH
returning no state
Execute the mk
monad, build the Makefile, write it to the output file.
In case of errors, print report to stderr and abort the execution with fail
call
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.
:: 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 |]
Create the rule, place it's recipe above all recipies defined so far. See rule' for other details
Adds the phony target for a rule. Typical usage:
rule $ do phony "clean" unsafeShell [cmd|rm $elf $os $d|]
:: RefInput a 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 item x
.
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 postbuild command
class FileLike a where Source #
combine, takeDirectory, takeBaseName, takeFileName, makeRelative, replaceExtension, takeExtension, takeExtensions, dropExtensions, dropExtension, splitDirectories
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 #
splitDirectories :: a -> [String] Source #
FileT h a |
EmbedDecl File Source # | |
SrcDecl File Source # | |
LinkDecl File Source # | |
ModuleDecl File Source # | |
Monad m => RefOutput m File Source # | |
Monad m => LibraryDecl m File Source # | |
RefOutput m File => RefOutput m (m File) Source # | |
Monad m => RefOutput m (Set File) Source # | |
Monad m => RefOutput m [File] Source # | |
Monad m => LibraryDecl m (m File) Source # | |
Monad m => LibraryDecl m [File] Source # | |
(Monad m, FileLike (FileT h a)) => FileLike (m (FileT h a)) Source # | |
Monad m => RefInput (A' m) File Source # | |
Monad m => RefInput (UrpGen m) File Source # | |
(Eq a, Eq h) => Eq (FileT h a) Source # | |
(Data a, Data h) => Data (FileT h a) Source # | |
(Ord a, Ord h) => Ord (FileT h a) Source # | |
(Show a, Show h) => Show (FileT h a) Source # | |
(Eq h, Show h, FileLike a) => FileLike (FileT h a) Source # | |
LinkDecl (File, String) Source # | |
ModuleDecl (File, File) Source # | |
SrcDecl (File, String, String) Source # | |
type File = FileT ModuleLocation FilePath Source #
Simple wrapper for FilePath. The first type argument is a Hint, containing the path to the current module
data ModuleLocation Source #
Eq ModuleLocation Source # | |
Data ModuleLocation Source # | |
Ord ModuleLocation Source # | |
Show ModuleLocation Source # | |
EmbedDecl File Source # | |
SrcDecl File Source # | |
LinkDecl File Source # | |
ModuleDecl File Source # | |
Monad m => RefOutput m File Source # | |
Monad m => LibraryDecl m File Source # | |
RefOutput m File => RefOutput m (m File) Source # | |
Monad m => RefOutput m (Set File) Source # | |
Monad m => RefOutput m [File] Source # | |
Monad m => LibraryDecl m (m File) Source # | |
Monad m => LibraryDecl m [File] Source # | |
Monad m => RefInput (A' m) File Source # | |
Monad m => RefInput (UrpGen m) File Source # | |
LinkDecl (File, String) Source # | |
ModuleDecl (File, File) Source # | |
SrcDecl (File, String, String) Source # | |
file' :: ModuleLocation -> FilePath -> File Source #
Converts string representation of Path into type-safe File. Internally,
files are stored in a form of offset from module root directory, plus the
path from top-level dir to module root and back (see ModuleLocation
)
TODO: rename to mkFile
topRel :: File -> FilePath Source #
Returns the path to the file, relative to the top-level directory (the place, where the target Makefile is located)
:: 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.
genFile' :: File -> String -> A () -> Make File Source #
A version of rule, without monad set explicitly rule' :: (MonadMake m) => A a -> m a rule' act = liftMake $ snd $ withPlacement (rule2 act)
Build a rule for creating file tgt
with a fixed content cnt
, use
additional actions act
for the recipe
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
Define the Makefile-level variable. Rules, referring to a variable,
notice
it's changes.
extvar :: String -> Variable Source #
Declare the variable defined elsewhere. Typycally, environment variables
may be decalred with this functions. Variables are tracked by the cake3.
Rules, referring to a variable, notice
it's changes.
newtype CommandGen' m Source #
CommandGen is a recipe-builder packed in the newtype to prevent partial expansion of it's commands
currentDirLocation :: MonadIO m => m ModuleLocation Source #
module Data.String
module Control.Monad
module Control.Applicative