Skip to content

Commit

Permalink
Merge pull request #2322 from sjakobi/2262-multiple-config-pvp-bounds
Browse files Browse the repository at this point in the history
Add multi-config pvp-bounds generation (#2262)
  • Loading branch information
mgsloan committed Aug 6, 2016
2 parents 05be18e + 1b0c4cd commit 738e06d
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 145 deletions.
9 changes: 9 additions & 0 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Stack.Build.Installed
( InstalledMap
, Installed (..)
, GetInstalledOpts (..)
, defaultGetInstalledOpts
, getInstalled
) where

Expand Down Expand Up @@ -58,10 +59,18 @@ data GetInstalledOpts = GetInstalledOpts
-- ^ Require haddocks?
}

defaultGetInstalledOpts :: GetInstalledOpts
defaultGetInstalledOpts = GetInstalledOpts
{ getInstalledProfiling = False
, getInstalledHaddock = False
}

-- | Returns the new InstalledMap and all of the locally registered packages.
getInstalled :: (M env m, PackageInstallInfo pii)
=> EnvOverride
-> GetInstalledOpts
-- TODO: Clarify what the Map is used for and what properties it
-- should have.
-> Map PackageName pii -- ^ does not contain any installed information
-> m ( InstalledMap
, [DumpPackage () ()] -- globally installed
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/BuildPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ getToolMap mbp =

loadResolver
:: (MonadIO m, MonadLogger m, MonadReader env m, HasHttpManager env, HasConfig env, HasGHCVariant env, MonadBaseControl IO m, MonadMask m)
=> Maybe (Path Abs File)
=> Maybe (Path Abs File) -- ^ Optional path to project config file
-> Resolver
-> m (MiniBuildPlan, LoadedResolver)
loadResolver mconfigPath resolver =
Expand Down Expand Up @@ -958,7 +958,7 @@ shadowMiniBuildPlan (MiniBuildPlan cv pkgs0) shadowed =

parseCustomMiniBuildPlan
:: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasHttpManager env, HasConfig env, HasGHCVariant env, MonadBaseControl IO m)
=> Maybe (Path Abs File) -- ^ Root directory for when url is a filepath
=> Maybe (Path Abs File) -- ^ Optional path to project config file
-> T.Text
-> m (MiniBuildPlan, SnapshotHash)
parseCustomMiniBuildPlan mconfigPath0 url0 = do
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Stack.Config
,loadConfig
,loadConfigMaybeProject
,loadMiniConfig
,loadProjectConfig
,packagesParser
,resolvePackageEntry
,getImplicitGlobalProjectDir
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import qualified Data.Traversable as T
import Network.HTTP.Client.Conduit (HasHttpManager)
import Prelude -- Fix redundant import warnings
import Stack.Build (withLoadPackage)
import Stack.Build.Installed (getInstalled, GetInstalledOpts(..))
import Stack.Build.Installed (getInstalled, defaultGetInstalledOpts)
import Stack.Build.Source
import Stack.Build.Target
import Stack.Constants
Expand Down Expand Up @@ -97,7 +97,7 @@ createDependencyGraph dotOpts = do
let graph = Map.fromList (localDependencies dotOpts locals)
menv <- getMinimalEnvOverride
installedMap <- fmap snd . fst4 <$> getInstalled menv
(GetInstalledOpts False False)
defaultGetInstalledOpts
sourceMap
withLoadPackage menv (\loader -> do
let depLoader =
Expand Down
5 changes: 1 addition & 4 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,7 @@ ghciSetup GhciOpts{..} = do
menv <- getMinimalEnvOverride
(installedMap, _, _, _) <- getInstalled
menv
GetInstalledOpts
{ getInstalledProfiling = False
, getInstalledHaddock = False
}
defaultGetInstalledOpts
sourceMap
econfig <- asks getEnvConfig
directlyWanted <-
Expand Down
70 changes: 48 additions & 22 deletions src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,52 @@ module Stack.Options
,testOptsParser
,haddockOptsParser
,hpcReportOptsParser
,sdistOptsParser
,pvpBoundsOption
,pvpBoundsOptsParser
,globalOptsFromMonoid
,splitObjsWarning
) where

import Control.Monad.Logger (LogLevel (..))
import Data.Char (isSpace, toLower, toUpper)
import Data.List (intercalate)
import Data.List.Split (splitOn)
import qualified Data.Map as Map
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Control.Monad.Logger (LogLevel (..))
import Data.Char (isSpace, toLower, toUpper)
import Data.List (intercalate)
import Data.List.Split (splitOn)
import qualified Data.Map as Map
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Maybe
import Data.Monoid.Extra
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Text.Read (decimal)
import Distribution.Version (anyVersion)
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Text.Read (decimal)
import Distribution.Version (anyVersion)
import Options.Applicative
import Options.Applicative.Args
import Options.Applicative.Builder.Extra
import Options.Applicative.Types (fromM, oneM, readerAsk)
import Stack.Build (splitObjsWarning)
import Stack.Clean (CleanOpts (..))
import Stack.Config (packagesParser)
import Options.Applicative.Types (fromM, oneM, readerAsk)
import Stack.Build (splitObjsWarning)
import Stack.Clean (CleanOpts (..))
import Stack.Config (packagesParser)
import Stack.ConfigCmd
import Stack.Constants
import Stack.Coverage (HpcReportOpts (..))
import Stack.Coverage (HpcReportOpts (..))
import Stack.Docker
import qualified Stack.Docker as Docker
import qualified Stack.Docker as Docker
import Stack.Dot
import Stack.Ghci (GhciOpts (..))
import Stack.Ghci (GhciOpts (..))
import Stack.Init
import Stack.New
import Stack.Nix
import Stack.Types.FlagName
import Stack.Types.PackageName
import Stack.Types.Version
import Stack.SDist
import Stack.Types.Compiler
import Stack.Types.Config
import Stack.Types.Docker
import Stack.Types.FlagName
import Stack.Types.Nix
import Stack.Types.Compiler
import Stack.Types.PackageName
import Stack.Types.TemplateName
import Stack.Types.Version

-- | Allows adjust global options depending on their context
-- Note: This was being used to remove ambibuity between the local and global
Expand Down Expand Up @@ -949,6 +952,29 @@ hpcReportOptsParser = HpcReportOpts
<*> switch (long "all" <> help "Use results from all packages and components")
<*> optional (strOption (long "destdir" <> help "Output directy for HTML report"))

sdistOptsParser :: Parser SDistOpts
sdistOptsParser = SDistOpts
<$> many (strArgument $ metavar "DIR")
<*> optional pvpBoundsOptsParser
<*> switch (long "ignore-check" <> help "Do not check package for common mistakes")
<*> switch (long "sign" <> help "Sign & upload signatures")
<*> strOption
(long "sig-server" <> metavar "URL" <> showDefault <>
value "https://sig.commercialhaskell.org" <>
help "URL")

pvpBoundsOptsParser :: Parser PvpBoundsOpts
pvpBoundsOptsParser = PvpBoundsOpts
<$> pvpBoundsOption
<*> many (option readDependencyConfigurationSource
(long "also-considering" <>
help "Extra dependency configs to consider during bounds generation" <>
metavar "RESOLVER_OR_STACK_YAML"))
where
readDependencyConfigurationSource =
DCSResolver <$> readAbstractResolver <|>
DCSProjectConfig <$> str

pvpBoundsOption :: Parser PvpBounds
pvpBoundsOption =
option
Expand Down
Loading

0 comments on commit 738e06d

Please sign in to comment.