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

BuildEnv.Build

Description

computePlan computes a Cabal plan by generating pkg.cabal and cabal.project files with the given dependencies, constraints, flags..., calling cabal build --dry-run to compute a build plan, and parsing the resulting plan.json file.

fetchPlan calls cabal unpack to fetch all packages in the given plan.

buildPlan builds each unit in the build plan from source, using buildUnit. This can be done either asynchronously or sequentially in dependency order, depending on the BuildStrategy. buildPlan can also be used to output a shell script containing build instructions, with the Script BuildStrategy.

Synopsis

Computing, fetching and building plans

computePlan :: TempDirPermanence -> Verbosity -> Compiler -> Cabal -> CabalFilesContents -> IO CabalPlanBinary Source #

Query cabal to obtain a build plan for the given packages, by reading the output plan.json of a cabal build --dry-run invocation.

Use cabalFileContentsFromPackages and cabalProjectContentsFromPackages to generate the cabal file contents from a collection of packages with constraints and flags. See also parseCabalDotConfigPkgs and parseSeedFile for other ways of obtaining this information.

Use parsePlanBinary to convert the returned CabalPlanBinary into a CabalPlan.

fetchPlan Source #

Arguments

:: Verbosity 
-> Cabal 
-> FilePath

Directory in which to put the sources.

-> CabalPlan 
-> IO () 

Fetch the sources of a CabalPlan, calling cabal get on each package and putting it into the correspondingly named and versioned subfolder of the specified directory (e.g. pkg-name-1.2.3).

buildPlan Source #

Arguments

:: Verbosity 
-> FilePath

Working directory. Used to compute relative paths for local packages, and to choose a logging directory.

-> Paths ForPrep 
-> Paths ForBuild 
-> BuildStrategy 
-> Bool

True <> resume a previously-started build, skipping over units that were already built.

This function will fail if this argument is False and one of the units has already been registered in the package database.

-> Maybe [UnitId]

Just units: only build units and their transitive dependencies, instead of the full build plan.

-> (ConfiguredUnit -> UnitArgs)

Extra arguments for each unit in the build plan.

-> CabalPlan

Build plan to execute.

-> IO () 

Build a CabalPlan. This will install all the packages in the plan by running their Setup scripts. Libraries will be registered into a local package database at installDir/package.conf.

Generating pkg.cabal and cabal.project files.

data CabalFilesContents Source #

The file contents of the Cabal files of a Cabal project: pkg.cabal and cabal.project.

Constructors

CabalFilesContents 

Fields

cabalFileContentsFromPackages :: UnitSpecs -> Text Source #

The contents of a dummy Cabal file with dependencies on the specified units (without any constraints).

cabalProjectContentsFromPackages :: FilePath -> UnitSpecs -> PkgSpecs -> AllowNewer -> Text Source #

The contents of a dummy cabal.project file, specifying package constraints, flags and allow-newer.