From 068874a470c717bbcc32f8b6a63cff777ff822f9 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 15 Dec 2015 19:14:36 -0800 Subject: [PATCH] Add ghci --no-hide-packages option #1517 --- src/Stack/Ghci.hs | 8 ++++++-- src/Stack/Ide.hs | 1 + src/Stack/Options.hs | 1 + src/Stack/Package.hs | 3 ++- src/Stack/Types/Package.hs | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 97a984d0b6..454c691419 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -66,6 +66,7 @@ data GhciOpts = GhciOpts , ghciAdditionalPackages :: ![String] , ghciMainIs :: !(Maybe Text) , ghciSkipIntermediate :: !Bool + , ghciHidePackages :: !Bool , ghciBuildOpts :: !BuildOpts } deriving Show @@ -98,8 +99,11 @@ ghci GhciOpts{..} = do mainFile <- figureOutMainFile bopts mainIsTargets targets pkgs wc <- getWhichCompiler let pkgopts = hidePkgOpt ++ genOpts ++ ghcOpts - hidePkgOpt = if null pkgs then [] else ["-hide-all-packages"] - genOpts = nubOrd (concatMap (concatMap (bioOneWordOpts . snd) . ghciPkgOpts) pkgs) + hidePkgOpt = if null pkgs || not ghciHidePackages then [] else ["-hide-all-packages"] + oneWordOpts bio + | ghciHidePackages = bioOneWordOpts bio ++ bioPackageFlags bio + | otherwise = bioOneWordOpts bio + genOpts = nubOrd (concatMap (concatMap (oneWordOpts . snd) . ghciPkgOpts) pkgs) (omittedOpts, ghcOpts) = partition badForGhci $ concatMap (concatMap (bioOpts . snd) . ghciPkgOpts) pkgs ++ getUserOptions Nothing ++ diff --git a/src/Stack/Ide.hs b/src/Stack/Ide.hs index 758d30ccb1..edf037aac1 100644 --- a/src/Stack/Ide.hs +++ b/src/Stack/Ide.hs @@ -100,6 +100,7 @@ getPackageOptsAndTargetFiles pwd pkg = do let ghcOptions bio = bioOneWordOpts bio ++ bioOpts bio ++ + bioPackageFlags bio ++ maybe [] (\cabalMacros -> ["-optP-include", "-optP" <> toFilePath cabalMacros]) (bioCabalMacros bio) return ( ("--dist-dir=" <> toFilePathNoTrailingSep dist) : diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index 0dc2314154..ba6564a80d 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -513,6 +513,7 @@ ghciOptsParser = GhciOpts \module to load, such as for an executable for \ \test suite or benchmark.")) <*> switch (long "skip-intermediate-deps" <> help "Skip loading intermediate target dependencies") + <*> boolFlags True "hide-packages" "package hiding" idm <*> buildOptsParser Build -- | Parser for exec command diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 0a9e764bca..dfa85b277a 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -316,7 +316,8 @@ generateBuildInfoOpts sourceMap installedMap mcabalMacros cabalDir distDir omitP -- -- See https://github.com/commercialhaskell/stack/issues/1255 , bioOneWordOpts = nubOrd $ concat - [extOpts b, srcOpts, includeOpts, deps, extra b, extraDirs, fworks b, cObjectFiles] + [extOpts b, srcOpts, includeOpts, extra b, extraDirs, fworks b, cObjectFiles] + , bioPackageFlags = deps , bioCabalMacros = mcabalMacros } where diff --git a/src/Stack/Types/Package.hs b/src/Stack/Types/Package.hs index 4019ccb718..ee76ee8f2e 100644 --- a/src/Stack/Types/Package.hs +++ b/src/Stack/Types/Package.hs @@ -117,6 +117,7 @@ instance Show GetPackageOpts where data BuildInfoOpts = BuildInfoOpts { bioOpts :: [String] , bioOneWordOpts :: [String] + , bioPackageFlags :: [String] -- ^ These options can safely have 'nubOrd' applied to them, as -- there are no multi-word options (see -- https://github.com/commercialhaskell/stack/issues/1255)