GHC.Toolchain.Program

ghc-toolchain-0.1.0.0: Utility for managing GHC target toolchains

Safe Haskell | None
Language | Haskell2010

GHC.Toolchain.Program

Contents

- Running programs
- Finding `Program`s
- Compiler programs

Synopsis

- data Program = Program {
  - prgPath :: FilePath
  - prgFlags :: [String]
  }
- shProgram :: Program
- _prgPath :: Lens Program FilePath
- _prgFlags :: Lens Program [String]
- addFlagIfNew :: String -> Program -> Program
- runProgram :: Program -> [String] -> M ExitCode
- callProgram :: Program -> [String] -> M ()
- readProgram :: Program -> [String] -> M (ExitCode, String, String)
- readProgramStdout :: Program -> [String] -> M String
- data ProgOpt = ProgOpt {
  - poPath :: Maybe FilePath
  - poFlags :: Maybe [String]
  }
- emptyProgOpt :: ProgOpt
- programFromOpt :: ProgOpt -> FilePath -> [String] -> Program
- _poPath :: Lens ProgOpt (Maybe FilePath)
- _poFlags :: Lens ProgOpt (Maybe [String])
- findProgram :: String -> ProgOpt -> [FilePath] -> M Program
- compile :: FilePath -> [String] -> Lens compiler Program -> compiler -> FilePath -> String -> M ()
- supportsTarget :: ArchOS -> Lens compiler Program -> (compiler -> M ()) -> String -> compiler -> M compiler

# Documentation

data Program Source #

Constructors

Program |
Fields prgPath :: FilePath prgFlags :: [String]

#### Instances

Instances details

Read Program Source # |
Instance details Defined in GHC.Toolchain.Program Methods readsPrec :: Int -> ReadS Program # readList :: ReadS [Program] # readPrec :: ReadPrec Program # readListPrec :: ReadPrec [Program] #
Show Program Source # |
Instance details Defined in GHC.Toolchain.Program Methods showsPrec :: Int -> Program -> ShowS # show :: Program -> String # showList :: [Program] -> ShowS #
Eq Program Source # |
Instance details Defined in GHC.Toolchain.Program Methods (==) :: Program -> Program -> Bool # (/=) :: Program -> Program -> Bool #
Ord Program Source # |
Instance details Defined in GHC.Toolchain.Program Methods compare :: Program -> Program -> Ordering # (<) :: Program -> Program -> Bool # (<=) :: Program -> Program -> Bool # (>) :: Program -> Program -> Bool # (>=) :: Program -> Program -> Bool # max :: Program -> Program -> Program # min :: Program -> Program -> Program #

shProgram :: Program Source #

_prgPath :: Lens Program FilePath Source #

_prgFlags :: Lens Program [String] Source #

addFlagIfNew :: String -> Program -> Program Source #

Prepends a flag to a program's flags if the flag is not in the existing flags.

# Running programs

runProgram :: Program -> [String] -> M ExitCode Source #

callProgram :: Program -> [String] -> M () Source #

readProgram :: Program -> [String] -> M (ExitCode, String, String) Source #

Runs a program with a list of arguments and returns the exit code and the stdout and stderr output

readProgramStdout :: Program -> [String] -> M String Source #

Runs a program with a list of arguments and returns the stdout output, ignoring the exit code.

# Finding `Program`s

data ProgOpt Source #

Program specifier from the command-line.

Constructors

ProgOpt |
Fields poPath :: Maybe FilePath poFlags :: Maybe [String]

emptyProgOpt :: ProgOpt Source #

programFromOpt Source #

Arguments

:: ProgOpt |
-> FilePath | Program path to default to
-> [String] | Program flags to default to
-> Program |

Make a ``Program`` from user specified program options (``ProgOpt``), defaulting to the given path and flags if unspecified in the ``ProgOpt``.

_poPath :: Lens ProgOpt (Maybe FilePath) Source #

_poFlags :: Lens ProgOpt (Maybe [String]) Source #

findProgram Source #

Arguments

:: String |
-> ProgOpt | path provided by user
-> [FilePath] | candidate names
-> M Program |

Tries to find the user specified program by path or tries to look for one in the given list of candidates.

If the `ProgOpt` program flags are unspecified the program will have an empty list of flags.

# Compiler programs

compile Source #

Arguments

:: FilePath | input extension
-> [String] | extra flags
-> Lens compiler Program |
-> compiler |
-> FilePath | output path
-> String | source
-> M () |

Compile a program with a given compiler.

The compiler must * Take the program path as a positional argument * Accept `-o` to specify output path

supportsTarget Source #

Arguments

:: ArchOS |
-> Lens compiler Program |
-> (compiler -> M ()) | Action to check if compiler with `--target` flag works
-> String | The LLVM target to use if `cc` supports `--target`
-> compiler | The compiler to check `--target` support for
-> M compiler | Return compiler with `--target` flag if supported

Does compiler program support the `--target=triple` option? If so, we should pass it whenever possible to avoid ambiguity and potential compile-time errors (e.g. see #20162).