[commit: Cabal] master: Attempts to use --flags options to set configurations flags when finalizing packages. (541efac)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:45:15 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/541efac5c93c1826453d972c874f39eed89f836a
>---------------------------------------------------------------
commit 541efac5c93c1826453d972c874f39eed89f836a
Author: bjorn <bjorn at bringert.net>
Date: Fri Oct 5 10:51:42 2007 +0000
Attempts to use --flags options to set configurations flags when finalizing packages.
>---------------------------------------------------------------
.../src/Network/Hackage/CabalInstall/Dependency.hs | 21 ++++++++++++++++---
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
index 00e945c..e225d1b 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
@@ -36,7 +36,8 @@ import Distribution.ParseUtils (showDependency)
import Distribution.Simple.Configure (getInstalledPackages)
import Distribution.Simple.Compiler (PackageDB(..), showCompilerId, compilerVersion)
-import Data.List (nub, maximumBy)
+import Data.Char (toLower)
+import Data.List (nub, maximumBy, isPrefixOf)
import Data.Maybe (mapMaybe)
import Control.Monad (guard)
import qualified System.Info (arch,os)
@@ -150,7 +151,18 @@ getDependency cfg installed available (UnresolvedDependency { dependency=dep, de
where pkgData p = ( package p'
, pkgUrl p'
, map (getDependency cfg installed available . depToUnresolvedDep) (buildDepends p'))
- where p' = finalizePackage cfg installed available p
+ where p' = finalizePackage cfg installed available (configurationsFlags opts) p
+
+configurationsFlags :: [String] -> [(String, Bool)]
+configurationsFlags opts =
+ case filter ("--flags=" `isPrefixOf`) opts of
+ [] -> []
+ xs -> flagList $ removeQuotes $ drop 8 $ last xs
+ where removeQuotes ('"':s) = take (length s - 1) s
+ removeQuotes s = s
+ flagList = map tagWithValue . words
+ where tagWithValue ('-':name) = (map toLower name, False)
+ tagWithValue name = (map toLower name, True)
-- |Get the PackageIdentifier, build options and location from a list of resolved packages.
-- Throws an exception if a package couldn't be resolved.
@@ -172,15 +184,16 @@ filterFetchables = mapMaybe worker
finalizePackage :: ConfigFlags
-> [PackageIdentifier] -- ^ All installed packages
-> [GenericPackageDescription] -- ^ All available packages
+ -> [(String,Bool)] -- ^ Configurations flags
-> GenericPackageDescription
-> PackageDescription
-finalizePackage cfg installed available desc
+finalizePackage cfg installed available flags desc
= case e of
Left missing -> error $ "Can't resolve dependencies: " ++ show missing
Right (d,flags) -> d
where
e = finalizePackageDescription
- []
+ flags
(Just $ nub $ installed ++ map (package . packageDescription) available)
System.Info.os
System.Info.arch
More information about the Cvs-libraries
mailing list