Safe Haskell | None |
---|---|
Language | Haskell98 |
The BuildFlags
record is an abstraction for various toolchain flags for
building executables and libraries from source files in a C
-based language.
It's intended to be toolchain-independent, but currently there's a
bias towards binutils/gcc/clang toolchains.
- data Language
- data BuildFlags
- systemIncludes :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath]
- userIncludes :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath]
- defines :: forall cat. ArrowApply cat => Lens cat BuildFlags [(String, Maybe String)]
- preprocessorFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String]
- compilerFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [(Maybe Language, [String])]
- libraryPath :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath]
- libraries :: forall cat. ArrowApply cat => Lens cat BuildFlags [String]
- linkerFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String]
- localLibraries :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath]
- archiverFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String]
- defineFlags :: BuildFlags -> [String]
- compilerFlagsFor :: Maybe Language -> BuildFlags -> [String]
- fromConfig :: (Functor m, Monad m) => (String -> m (Maybe String)) -> m (BuildFlags -> BuildFlags)
- (>>>=) :: Monad m => m (a -> b) -> m (b -> c) -> m (a -> c)
- append :: Monoid a => (f :-> a) -> a -> f -> f
- prepend :: Monoid a => (f :-> a) -> a -> f -> f
Source Language
Source language.
Currently something derived from C
.
Build flags
data BuildFlags Source #
Record type for abstracting various toolchain command line flags.
BuildFlags
is an instance of Default
, you can create a default record with
def
. BuildFlags
is also an instance Monoid
, you can create an empty record with
mempty
and append flags with mappend
. def
and mempty
are synonyms:
>>>
(def :: BuildFlags) == (mempty :: BuildFlags)
True
Record accessors are Lens
es from the
fclabels package, which
makes accessing and modifying record fields a bit more convenient.
fclabels
was chosen over lens
because it has far fewer dependencies, which is convenient when installing
the Shake build system in a per-project cabal sandbox. We might switch to
lens
when it gets included in the Haskell platform.
There are two convenience functions for working with BuildFlags
record fields
containing lists of flags, append
and prepend
. Since most combinators in
this library expect a function BuildFlags -> BuildFlags
, the following is a
common idiom:
buildFlags . append systemIncludes
["path"]
Note that when modifying the same record field, order of function composition
matters and you might want to use the arrow combinator >>>
for appending in
source statement order:
>>>
:{
get systemIncludes $ append systemIncludes ["path1"] . append systemIncludes ["path2"] $ mempty :} ["path2","path1"]
>>>
:{
get systemIncludes $ append systemIncludes ["path1"] >>> append systemIncludes ["path2"] $ mempty :} ["path1","path2"]
See Development.Shake.Language.C.Rules for how to use BuildFlags
in build
product rules.
systemIncludes :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath] Source #
System include directories, referenced by #include <...>
in code and usually passed to the compiler with the -isystem
flag.
userIncludes :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath] Source #
User include directories, referenced by #include "..."
in code and usually passed to the compiler with the -I
flag.
defines :: forall cat. ArrowApply cat => Lens cat BuildFlags [(String, Maybe String)] Source #
Preprocessor defines, a list of pairs of names with or without a value.
preprocessorFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String] Source #
Other preprocessor flags.
compilerFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [(Maybe Language, [String])] Source #
Compiler flags, either generic ones or for a specific source Language
.
libraryPath :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath] Source #
Linker search path for libraries.
libraries :: forall cat. ArrowApply cat => Lens cat BuildFlags [String] Source #
List of libraries to link against. Note that you should use the library name without the lib
prefix and without extension.
linkerFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String] Source #
Flags passed to the linker.
localLibraries :: forall cat. ArrowApply cat => Lens cat BuildFlags [FilePath] Source #
Locally built static libraries to be linked against. See also the corresponding section in the manual.
archiverFlags :: forall cat. ArrowApply cat => Lens cat BuildFlags [String] Source #
Flags passed to the object archiver. ** Utilities for toolchain writers
defineFlags :: BuildFlags -> [String] Source #
Construct preprocessor flags from the defines
field of BuildFlags
.
compilerFlagsFor :: Maybe Language -> BuildFlags -> [String] Source #
Return a list of compiler flags for a specific source language.
Working with config files
fromConfig :: (Functor m, Monad m) => (String -> m (Maybe String)) -> m (BuildFlags -> BuildFlags) Source #
Construct a BuildFlags
modifier function from a config file.
See also Development.Shake.Language.C.Config.
Utilities
(>>>=) :: Monad m => m (a -> b) -> m (b -> c) -> m (a -> c) Source #
Utility function for composing functions in a monad.
Append stuff to the Monoid
in record field specified by lens.