diff options
author | Paolo Capriotti <p.capriotti@gmail.com> | 2012-05-03 11:29:51 +0100 |
---|---|---|
committer | Paolo Capriotti <p.capriotti@gmail.com> | 2012-05-15 08:18:51 +0100 |
commit | 6a831be4aa73e86568256813ffa862d7cfd5732d (patch) | |
tree | bf52dd84057b7d838241dc86f1d989221fd8b7a4 /compiler/main/DynFlags.hs | |
parent | c250f93bd38c7d8f6453dd79dd9951f9a02bf5a7 (diff) | |
download | haskell-6a831be4aa73e86568256813ffa862d7cfd5732d.tar.gz |
Add flags to manipulate package db stack (#5977)
Introduce new flags to allow any package database stack to be set up.
The `-no-user-package-conf` and `-no-global-package-conf` flags remove
the corresponding package db from the initial stack, while
`-user-package-conf` and `-global-package-conf` push it back on top of
the stack.
Diffstat (limited to 'compiler/main/DynFlags.hs')
-rw-r--r-- | compiler/main/DynFlags.hs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index a497dedcda..f49da9358f 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -38,6 +38,7 @@ module DynFlags ( GhcMode(..), isOneShot, GhcLink(..), isNoLink, PackageFlag(..), + PkgConfRef(..), Option(..), showOpt, DynLibLoader(..), fFlags, fWarningFlags, fLangFlags, xFlags, @@ -275,6 +276,7 @@ data DynFlag | Opt_ForceRecomp | Opt_ExcessPrecision | Opt_EagerBlackHoling + | Opt_ReadGlobalPackageConf | Opt_ReadUserPackageConf | Opt_NoHsMain | Opt_SplitObjs @@ -548,7 +550,7 @@ data DynFlags = DynFlags { depSuffixes :: [String], -- Package flags - extraPkgConfs :: [FilePath], + extraPkgConfs :: [PkgConfRef], -- ^ The @-package-conf@ flags given on the command line, in the order -- they appeared. @@ -1755,8 +1757,13 @@ dynamic_flags = [ package_flags :: [Flag (CmdLineP DynFlags)] package_flags = [ ------- Packages ---------------------------------------------------- - Flag "package-conf" (HasArg extraPkgConf_) + Flag "package-conf" (HasArg (extraPkgConf_ . PkgConfFile)) + , Flag "clear-package-conf" (NoArg clearPkgConf) + , Flag "no-global-package-conf" (NoArg (unSetDynFlag Opt_ReadGlobalPackageConf)) , Flag "no-user-package-conf" (NoArg (unSetDynFlag Opt_ReadUserPackageConf)) + , Flag "global-package-conf" (NoArg (extraPkgConf_ GlobalPkgConf)) + , Flag "user-package-conf" (NoArg (extraPkgConf_ UserPkgConf)) + , Flag "package-name" (hasArg setPackageName) , Flag "package-id" (HasArg exposePackageId) , Flag "package" (HasArg exposePackage) @@ -2066,6 +2073,7 @@ xFlags = [ defaultFlags :: [DynFlag] defaultFlags = [ Opt_AutoLinkPackages, + Opt_ReadGlobalPackageConf, Opt_ReadUserPackageConf, Opt_SharedImplib, @@ -2404,9 +2412,19 @@ setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 }) addCmdlineHCInclude :: String -> DynP () addCmdlineHCInclude a = upd (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes s}) -extraPkgConf_ :: FilePath -> DynP () +data PkgConfRef + = GlobalPkgConf + | UserPkgConf + | PkgConfFile FilePath + +extraPkgConf_ :: PkgConfRef -> DynP () extraPkgConf_ p = upd (\s -> s{ extraPkgConfs = p : extraPkgConfs s }) +clearPkgConf :: DynP () +clearPkgConf = do + unSetDynFlag Opt_ReadGlobalPackageConf + unSetDynFlag Opt_ReadUserPackageConf + exposePackage, exposePackageId, hidePackage, ignorePackage, trustPackage, distrustPackage :: String -> DynP () exposePackage p = |