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

BuildEnv.Utils

Description

Various utilities:

  • Spawning of processes in particular environments; see callProcessInIO.
  • Semaphores.
Synopsis

Call a process in a given environment

data ProgPath Source #

The path of a program to run.

Constructors

AbsPath

An absolute path, or an executable in PATH.

Fields

RelPath

A relative path. What it is relative to depends on context.

Fields

data CallProcess Source #

Arguments to callProcess.

Constructors

CP 

Fields

  • cwd :: !FilePath

    Working directory.

  • extraPATH :: ![FilePath]

    Absolute filepaths to add to PATH.

  • extraEnvVars :: ![(String, String)]

    Extra envi!ronment variables to add before running the command.

  • prog :: !ProgPath

    The program to run.

    If it's a relative path, it should be relative to the cwd field.

  • args :: !Args

    Arguments to the program.

  • logBasePath :: !(Maybe FilePath)

    Log stdout to basePath.stdout and stderr to basePath.stderr.

  • sem :: !AbstractSem

    Lock to take when calling the process and waiting for it to return, to avoid contention in concurrent situations.

callProcessInIO Source #

Arguments

:: HasCallStack 
=> Maybe Counter

Optional counter. Used when the command fails, to report the progress that has been made so far.

-> CallProcess 
-> IO () 

Run a command and wait for it to complete.

Crashes if the process returns with non-zero exit code.

See CallProcess for a description of the options.

Create temporary directories

data TempDirPermanence Source #

How to handle deletion of temporary directories.

Instances

Instances details
Show TempDirPermanence Source # 
Instance details

Defined in BuildEnv.Config

withTempDir Source #

Arguments

:: TempDirPermanence

whether to delete the temporary directory after the action completes

-> String

directory name template

-> (FilePath -> IO a)

action to perform

-> IO a 

Perform an action with a fresh temporary directory.

Abstract semaphores

newtype AbstractSem Source #

Abstract acquire/release mechanism.

Constructors

AbstractSem 

Fields

newAbstractSem :: AsyncSem -> IO AbstractSem Source #

Create a semaphore-based acquire/release mechanism.

noSem :: AbstractSem Source #

No acquire/release mechanism required.

abstractQSem :: QSem -> AbstractSem Source #

Abstract acquire/release mechanism controlled by the given QSem.

Other utilities

splitOn :: Char -> String -> [String] Source #

Utility list splitOn function.