build-env-1.2.0.0: Compute, fetch and install Cabal build plans into a local environment
Safe HaskellSafe-Inferred
LanguageHaskell2010

BuildEnv.Script

Description

This modules provides a tiny build script DSL.

A BuildScript is a series of simple build steps (process calls).

A BuildScript can be executed in the IO monad, using executeBuildScript.

A BuildScript can be turned into a shell script which can be executed later, using script.

Synopsis

Interpreting build scripts

Executing build scripts

executeBuildScript Source #

Arguments

:: SymbolicPath CWD (Dir Project)

Working directory.

-> Maybe Counter

Optional counter to use to report progress.

-> BuildScript

The build script to execute.

-> IO () 

Execute a BuildScript in the IO monad.

Shell-script output

script :: ScriptConfig -> BuildScript -> Text Source #

Obtain the textual contents of a build script.

Build scripts

type BuildScript = BuildScriptM () Source #

A build script: a list of build steps, given a ScriptConfig context.

newtype BuildScriptM a Source #

Build script monad.

Instances

Instances details
Applicative BuildScriptM Source # 
Instance details

Defined in BuildEnv.Script

Functor BuildScriptM Source # 
Instance details

Defined in BuildEnv.Script

Methods

fmap :: (a -> b) -> BuildScriptM a -> BuildScriptM b #

(<$) :: a -> BuildScriptM b -> BuildScriptM a #

Monad BuildScriptM Source # 
Instance details

Defined in BuildEnv.Script

Monoid BuildScript Source # 
Instance details

Defined in BuildEnv.Script

Semigroup BuildScript Source # 
Instance details

Defined in BuildEnv.Script

emptyBuildScript :: BuildScript Source #

The empty build script: no build steps.

buildSteps :: ScriptConfig -> BuildScript -> BuildSteps Source #

Obtain the build steps of a BuildScript.

Individual build steps

data BuildStep Source #

A build step.

Constructors

forall dir. CallProcess (CallProcess dir)

Call a processs with the given arguments.

forall dir. CreateDir (AbsolutePath (Dir dir))

Create the given directory.

LogMessage String

Log a message to stdout.

ReportProgress

Report one unit of progress.

Fields

type BuildSteps = [BuildStep] Source #

A list of build steps.

step :: BuildStep -> BuildScript Source #

Declare a build step.

callProcess :: CallProcess dir -> BuildScript Source #

Call a process with given arguments.

createDir :: AbsolutePath (Dir dir) -> BuildScript Source #

Create the given directory.

reportProgress :: Verbosity -> BuildScript Source #

Report one unit of progress.

Configuring build scripts

data ScriptOutput Source #

How to interpret the build script: run it in IO, or turn it into a shell script?

Constructors

Run

Run the build script in IO

Shell

Generate a shell script.

Fields

  • useVariables :: !Bool

    Replace various values with variables, so that they can be set before running the build script.

    Values:

    • GHC and GHC-PKG,
    • fetched sources directory SOURCES,
    • PREFIX and DESTDIR.

data ScriptConfig Source #

Configuration options for a BuildScript.

Constructors

ScriptConfig 

Fields

hostRunCfg Source #

Arguments

:: SymbolicPath CWD (Dir Project) 
-> Maybe Word

Optional: total to report progress against.

-> ScriptConfig 

Configure a script to run on the host (in IO).

data EscapeVars Source #

Whether to expand or escape variables in a shell script.

Constructors

ExpandVars

Allow the shell to expand variables.

EscapeVars

Escape variables so that the shell doesn't expand them.

Instances

Instances details
Show EscapeVars Source # 
Instance details

Defined in BuildEnv.Script

quoteArg :: (IsString r, Monoid r) => EscapeVars -> ScriptConfig -> String -> r Source #

Quote a command-line argument, if the ScriptConfig requires arguments to be quoted.

No need to call this on the cwd or prog fields of BuildStep, as these will be quoted by the shell-script backend no matter what.