From: simonmar Date: Thu, 7 Apr 2005 11:35:48 +0000 (+0000) Subject: [project @ 2005-04-07 11:35:48 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~785 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c73d0b413690188231f921f290603bad88d2c710;p=ghc-hetmet.git [project @ 2005-04-07 11:35:48 by simonmar] Add the -hide-all-packages flag. --- diff --git a/ghc/compiler/main/DynFlags.hs b/ghc/compiler/main/DynFlags.hs index f02c27d..c3324ad 100644 --- a/ghc/compiler/main/DynFlags.hs +++ b/ghc/compiler/main/DynFlags.hs @@ -60,7 +60,9 @@ import Util ( notNull, splitLongestPrefix, split, normalisePath ) import DATA_IOREF ( readIORef ) import EXCEPTION ( throwDyn ) import Monad ( when ) +#ifdef mingw32_TARGET_OS import Data.List ( isPrefixOf ) +#endif import Maybe ( fromJust ) import Char ( isDigit, isUpper ) @@ -168,6 +170,7 @@ data DynFlag | Opt_NoHsMain | Opt_SplitObjs | Opt_StgStats + | Opt_HideAllPackages -- keeping stuff | Opt_KeepHiDiffs @@ -819,6 +822,7 @@ dynamic_flags = [ , ( "package-name" , HasArg ignorePackage ) -- for compatibility , ( "package" , HasArg exposePackage ) , ( "hide-package" , HasArg hidePackage ) + , ( "hide-all-packages", NoArg (setDynFlag Opt_HideAllPackages) ) , ( "ignore-package" , HasArg ignorePackage ) , ( "syslib" , HasArg exposePackage ) -- for compatibility diff --git a/ghc/compiler/main/Packages.lhs b/ghc/compiler/main/Packages.lhs index 911da2f..a7e48b8 100644 --- a/ghc/compiler/main/Packages.lhs +++ b/ghc/compiler/main/Packages.lhs @@ -228,9 +228,16 @@ readPackageConfig dflags pkg_map conf_file = do debugTraceMsg dflags 2 ("Using package config file: " ++ conf_file) proto_pkg_configs <- loadPackageConfig conf_file top_dir <- getTopDir - let pkg_configs = mungePackagePaths top_dir proto_pkg_configs - return (extendPackageConfigMap pkg_map pkg_configs) - + let pkg_configs1 = mungePackagePaths top_dir proto_pkg_configs + pkg_configs2 = maybeHidePackages dflags pkg_configs1 + return (extendPackageConfigMap pkg_map pkg_configs2) + +maybeHidePackages :: DynFlags -> [PackageConfig] -> [PackageConfig] +maybeHidePackages dflags pkgs + | dopt Opt_HideAllPackages dflags = map hide pkgs + | otherwise = pkgs + where + hide pkg = pkg{ exposed = False } mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig] -- Replace the string "$topdir" at the beginning of a path @@ -257,7 +264,7 @@ mkPackageState :: DynFlags -> PackageConfigMap -> IO PackageState mkPackageState dflags pkg_db = do -- -- Modify the package database according to the command-line flags - -- (-package, -hide-package, -ignore-package). + -- (-package, -hide-package, -ignore-package, -hide-all-packages). -- -- Also, here we build up a set of the packages mentioned in -package -- flags on the command line; these are called the "explicit" packages. diff --git a/ghc/docs/users_guide/flags.xml b/ghc/docs/users_guide/flags.xml index e24226d..0bb4400 100644 --- a/ghc/docs/users_guide/flags.xml +++ b/ghc/docs/users_guide/flags.xml @@ -481,6 +481,12 @@ - + + Hide all packages by default + static + - + + name Hide package P static diff --git a/ghc/docs/users_guide/packages.xml b/ghc/docs/users_guide/packages.xml index 6bacd66..b55e58d 100644 --- a/ghc/docs/users_guide/packages.xml +++ b/ghc/docs/users_guide/packages.xml @@ -131,6 +131,23 @@ exposed-modules: Network.BSD, + + + + + Ignore the exposed flag on installed packages, and hide them + all by default. If you use + this flag, then any packages you require (including + base) need to be explicitly exposed using + options. + + This is a good way to insulate your program from differences + in the globally exposed packages, and being explicit about package + dependencies is a Good Thing. + + + + P