ghc-7.8.4: The GHC API

Safe HaskellNone
LanguageHaskell98

Packages

Contents

Description

Package manipulation

Synopsis

Documentation

The PackageConfigMap

type PackageConfigMap = UniqFM PackageConfig Source

A PackageConfigMap maps a PackageId to a PackageConfig

lookupPackage :: PackageConfigMap -> PackageId -> Maybe PackageConfig Source

Find the package we know about with the given id (e.g. "foo-1.0"), if any

dumpPackages :: DynFlags -> IO () Source

Show package info on console, if verbosity is >= 3

Reading the package config, and processing cmdline args

data PackageState Source

Package state is all stored in DynFlags, including the details of all packages, which packages are exposed, and which modules they provide.

The package state is computed by initPackages, and kept in DynFlags.

  • -package pkg causes pkg to become exposed, and all other packages with the same name to become hidden.
  • -hide-package pkg causes pkg to become hidden.
  • Let exposedPackages be the set of packages thus exposed. Let depExposedPackages be the transitive closure from exposedPackages of their dependencies.
  • When searching for a module from an preload import declaration, only the exposed modules in exposedPackages are valid.
  • When searching for a module from an implicit import, all modules from depExposedPackages are valid.
  • When linking in a compilation manager mode, we link in packages the program depends on (the compiler knows this list by the time it gets to the link step). Also, we link in all packages which were mentioned with preload -package flags on the command-line, or are a transitive dependency of same, or are "base"/"rts". The reason for this is that we might need packages which don't contain any Haskell modules, and therefore won't be discovered by the normal mechanism of dependency tracking.

initPackages :: DynFlags -> IO (DynFlags, [PackageId]) Source

Call this after parseDynFlags. It reads the package database files, and sets up various internal tables of package information, according to the package-related flags on the command-line (-package, -hide-package etc.)

Returns a list of packages to link in if we're doing dynamic linking. This list contains the packages that the user explicitly mentioned with -package flags.

initPackages can be called again subsequently after updating the packageFlags field of the DynFlags, and it will update the pkgState in DynFlags and return a list of packages to link in.

getPackageDetails :: PackageState -> PackageId -> PackageConfig Source

Looks up the package with the given id in the package state, panicing if it is not found

lookupModuleInAllPackages :: DynFlags -> ModuleName -> [(PackageConfig, Bool)] Source

Takes a Module, and if the module is in a package returns (pkgconf, exposed) where pkgconf is the PackageConfig for that package, and exposed is True if the package exposes the module.

Inspecting the set of packages in scope

getPackageIncludePath :: DynFlags -> [PackageId] -> IO [String] Source

Find all the include directories in these and the preload packages

getPackageLibraryPath :: DynFlags -> [PackageId] -> IO [String] Source

Find all the library paths in these and the preload packages

getPackageLinkOpts :: DynFlags -> [PackageId] -> IO ([String], [String], [String]) Source

Find all the link options in these and the preload packages, returning (package hs lib options, extra library options, other flags)

getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String] Source

Find all the C-compiler options in these and the preload packages

getPackageFrameworkPath :: DynFlags -> [PackageId] -> IO [String] Source

Find all the package framework paths in these and the preload packages

getPackageFrameworks :: DynFlags -> [PackageId] -> IO [String] Source

Find all the package frameworks in these and the preload packages

getPreloadPackagesAnd :: DynFlags -> [PackageId] -> IO [PackageConfig] Source

Find all the PackageConfig in both the preload packages from DynFlags and corresponding to the list of PackageConfigs

Utils

isDllName :: DynFlags -> PackageId -> Module -> Name -> Bool Source

Will the Name come from a dynamically linked library?