Add the -hide-all-packages flag.
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 )
| Opt_NoHsMain
| Opt_SplitObjs
| Opt_StgStats
+ | Opt_HideAllPackages
-- keeping stuff
| Opt_KeepHiDiffs
, ( "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
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
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.
<entry>-</entry>
</row>
<row>
+ <entry><option>-hide-all-packages</option></entry>
+ <entry>Hide all packages by default</entry>
+ <entry>static</entry>
+ <entry>-</entry>
+ </row>
+ <row>
<entry><option>-hide-package</option> <replaceable>name</replaceable></entry>
<entry>Hide package <replaceable>P</replaceable></entry>
<entry>static</entry>
</varlistentry>
<varlistentry>
+ <term><option>-hide-all-packages</option>
+ <indexterm><primary><option>-hide-package</option></primary>
+ </indexterm></term>
+ <listitem>
+ <para>Ignore the exposed flag on installed packages, and hide them
+ all by default. If you use
+ this flag, then any packages you require (including
+ <literal>base</literal>) need to be explicitly exposed using
+ <option>-package</option> options.</para>
+
+ <para>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.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-hide-package</option> <replaceable>P</replaceable>
<indexterm><primary><option>-hide-package</option></primary>
</indexterm></term>