Commit 2326db6e authored by Duncan Coutts's avatar Duncan Coutts

Put the configurations flags into each UnresolvedDependency

We don't actually have per-package flags yet. All -f flags
on the install/upgrade command line apply to every paclage.
parent efba1784
......@@ -45,6 +45,8 @@ import Distribution.Simple.Setup
( Flag(..), toFlag, flagToList, trueArg, optionVerbosity )
import Distribution.Version
( Version(Version) )
import Distribution.Package
( Dependency )
import Distribution.Text
( Text(parse), display )
import Distribution.ReadE
......@@ -52,7 +54,7 @@ import Distribution.ReadE
import Distribution.Verbosity (Verbosity, normal)
import Hackage.Types
( UnresolvedDependency(..), Username(..), Password(..) )
( Username(..), Password(..) )
import Hackage.ParseUtils (readPToMaybe, parseDependencyOrPackageId)
import Data.Monoid (Monoid(..))
......@@ -357,15 +359,12 @@ usagePackages name pname =
++ " or: " ++ pname ++ " " ++ name ++ " [PACKAGES]\n\n"
++ "Flags for " ++ name ++ ":"
parsePackageArgs :: [String] -> Either String [UnresolvedDependency]
--TODO: do we want to allow per-package flags?
parsePackageArgs :: [String] -> Either String [Dependency]
parsePackageArgs = parsePkgArgs []
where
parsePkgArgs ds [] = Right (reverse ds)
parsePkgArgs ds (arg:args) =
case readPToMaybe parseDependencyOrPackageId arg of
Just dep -> let d = UnresolvedDependency {
dependency = dep,
depFlags = []
}
in parsePkgArgs (d:ds) args
Just dep -> parsePkgArgs (dep:ds) args
Nothing -> Left ("Failed to parse package dependency: " ++ show arg)
......@@ -14,6 +14,8 @@
module Main where
import Hackage.Setup
import Hackage.Types
( UnresolvedDependency(UnresolvedDependency) )
import Distribution.Simple.Setup (Flag(..), fromFlag, fromFlagOrDefault,
flagToMaybe,SDistFlags,sdistCommand)
import qualified Distribution.Simple.Setup as Cabal
......@@ -159,7 +161,9 @@ installAction (cflags,iflags) extraArgs = do
(comp, conf) <- configCompilerAux cflags'
install verbosity
(configPackageDB cflags') (configRepos config)
comp conf cflags' iflags pkgs
comp conf cflags' iflags
[ UnresolvedDependency pkg (Cabal.configConfigurationsFlags cflags')
| pkg <- pkgs ]
listAction :: ListFlags -> [String] -> IO ()
listAction listFlags extraArgs = do
......@@ -194,7 +198,9 @@ upgradeAction (cflags,iflags) extraArgs = do
(comp, conf) <- configCompilerAux cflags'
upgrade verbosity
(configPackageDB cflags') (configRepos config)
comp conf cflags' iflags pkgs
comp conf cflags' iflags
[ UnresolvedDependency pkg (Cabal.configConfigurationsFlags cflags')
| pkg <- pkgs ]
fetchAction :: Flag Verbosity -> [String] -> IO ()
fetchAction verbosityFlag extraArgs = do
......@@ -206,7 +212,9 @@ fetchAction verbosityFlag extraArgs = do
(comp, conf) <- configCompilerAux flags
fetch verbosity
(configPackageDB flags) (configRepos config)
comp conf pkgs
comp conf
[ UnresolvedDependency pkg [] --TODO: flags?
| pkg <- pkgs ]
uploadAction :: UploadFlags -> [String] -> IO ()
uploadAction flags extraArgs = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment