summaryrefslogtreecommitdiff
path: root/compiler/main/Packages.hs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2015-10-26 20:48:36 +0100
committerBen Gamari <ben@smart-cactus.org>2015-10-26 21:43:01 +0100
commita9c93bdd8b027d6de09a3eada7721e7fd2d3e050 (patch)
tree570c2cd55dc6943a929d8a5d9f9d80af6740935e /compiler/main/Packages.hs
parent499ce291b6bab252c63f0791276c38012280f0b4 (diff)
downloadhaskell-a9c93bdd8b027d6de09a3eada7721e7fd2d3e050.tar.gz
Implement MIN_VERSION and VERSION macros natively in GHC.
Test Plan: validate Reviewers: austin, thomie, bgamari Reviewed By: thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1349 GHC Trac Issues: #10970
Diffstat (limited to 'compiler/main/Packages.hs')
-rw-r--r--compiler/main/Packages.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 0e32947b31..9f60c1cc28 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -7,7 +7,7 @@ module Packages (
module PackageConfig,
-- * Reading the package config, and processing cmdline args
- PackageState(preloadPackages),
+ PackageState(preloadPackages, explicitPackages),
emptyPackageState,
initPackages,
readPackageConfigs,
@@ -245,6 +245,10 @@ data PackageState = PackageState {
-- is always mentioned before the packages it depends on.
preloadPackages :: [UnitId],
+ -- | Packages which we explicitly depend on (from a command line flag).
+ -- We'll use this to generate version macros.
+ explicitPackages :: [UnitId],
+
-- | This is a full map from 'ModuleName' to all modules which may possibly
-- be providing it. These providers may be hidden (but we'll still want
-- to report them in error messages), or it may be an ambiguous import.
@@ -255,6 +259,7 @@ emptyPackageState :: PackageState
emptyPackageState = PackageState {
pkgIdMap = emptyUFM,
preloadPackages = [],
+ explicitPackages = [],
moduleToPkgConfAll = Map.empty
}
@@ -961,6 +966,10 @@ mkPackageState dflags0 pkgs0 preload0 = do
let pstate = PackageState{
preloadPackages = dep_preload,
+ explicitPackages = foldUFM (\pkg xs ->
+ if elemUFM (packageConfigId pkg) vis_map
+ then packageConfigId pkg : xs
+ else xs) [] pkg_db,
pkgIdMap = pkg_db,
moduleToPkgConfAll = mkModuleToPkgConfAll dflags pkg_db vis_map
}