[commit: Cabal] master: build-dep can now build the dependencies specified in a local .cabal file. (fdd4f1d)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:43:57 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/fdd4f1d19503b99d168873b7b3705b5b783f11ad
>---------------------------------------------------------------
commit fdd4f1d19503b99d168873b7b3705b5b783f11ad
Author: bjorn <bjorn at bringert.net>
Date: Mon Apr 9 17:04:09 2007 +0000
build-dep can now build the dependencies specified in a local .cabal file.
This is useful when you want to build a development version of something whose dependencies are available in Hackage.
>---------------------------------------------------------------
.../src/Network/Hackage/CabalInstall/BuildDep.hs | 13 +++++++++++--
.../src/Network/Hackage/CabalInstall/Dependency.hs | 1 +
.../src/Network/Hackage/CabalInstall/Main.hs | 7 +++++--
.../src/Network/Hackage/CabalInstall/Setup.hs | 2 +-
4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/BuildDep.hs b/cabal-install/src/Network/Hackage/CabalInstall/BuildDep.hs
index a76c583..437a4b8 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/BuildDep.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/BuildDep.hs
@@ -12,10 +12,11 @@
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.BuildDep where
-import Network.Hackage.CabalInstall.Dependency (getPackages, getBuildDeps, resolveDependenciesAux)
-import Network.Hackage.CabalInstall.Install (installPkg)
+import Network.Hackage.CabalInstall.Dependency (getPackages, getBuildDeps, depToUnresolvedDep, resolveDependenciesAux)
+import Network.Hackage.CabalInstall.Install (install, installPkg)
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), UnresolvedDependency)
+import Distribution.PackageDescription (readPackageDescription, buildDepends)
import Distribution.Simple.Configure (getInstalledPackages)
{-|
@@ -27,3 +28,11 @@ buildDep cfg globalArgs deps
= do ipkgs <- getInstalledPackages (configCompiler cfg) (configUserIns cfg) (configVerbose cfg)
apkgs <- fmap getPackages (fmap (getBuildDeps ipkgs) (resolveDependenciesAux cfg ipkgs deps))
mapM_ (installPkg cfg globalArgs) apkgs
+
+-- | Takes the path to a .cabal file, and installs the build-dependencies listed there.
+-- FIXME: what if the package uses hooks which modify the build-dependencies?
+buildDepLocalPkg :: ConfigFlags -> FilePath -> IO ()
+buildDepLocalPkg cfg pkgDescPath =
+ do pkgDesc <- readPackageDescription (configVerbose cfg) pkgDescPath
+ let deps = map depToUnresolvedDep $ buildDepends pkgDesc
+ install cfg [] deps
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
index 63e1d2f..184beb2 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
@@ -16,6 +16,7 @@ module Network.Hackage.CabalInstall.Dependency
resolveDependencies
, resolveDependenciesAux
-- * Utilities
+ , depToUnresolvedDep
, getPackages -- :: [ResolvedPackage] -> [(PackageIdentifier,[String],String)]
, getBuildDeps -- :: [PackageIdentifier] -> [ResolvedPackage] -> [ResolvedPackage]
, filterFetchables -- :: [ResolvedPackage] -> [(PackageIdentifier,String)]
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Main.hs b/cabal-install/src/Network/Hackage/CabalInstall/Main.hs
index eb3d67b..b4e4396 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Main.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Main.hs
@@ -12,6 +12,7 @@
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.Main where
+import Data.List (isSuffixOf)
import System.Environment (getArgs)
import Network.Hackage.CabalInstall.Types (Action (..))
import Network.Hackage.CabalInstall.Setup (parseGlobalArgs, parsePackageArgs)
@@ -23,7 +24,7 @@ import Network.Hackage.CabalInstall.Info (info)
import Network.Hackage.CabalInstall.Update (update)
import Network.Hackage.CabalInstall.Fetch (fetch)
import Network.Hackage.CabalInstall.Clean (clean)
-import Network.Hackage.CabalInstall.BuildDep (buildDep)
+import Network.Hackage.CabalInstall.BuildDep (buildDep, buildDepLocalPkg)
main :: IO ()
@@ -34,7 +35,9 @@ main = do args <- getArgs
f config globalArgs pkgs
case action of
InstallCmd -> runCmd install
- BuildDepCmd -> runCmd buildDep
+ BuildDepCmd -> case args of
+ [file] | ".cabal" `isSuffixOf` file -> buildDepLocalPkg config file
+ _ -> runCmd buildDep
InfoCmd -> runCmd info
ListCmd -> list config args
UpdateCmd -> update config
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs b/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs
index baa3423..57b5e14 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs
@@ -159,7 +159,7 @@ listCmd :: Cmd
listCmd = mkCmd "list" "List available packages on the server." "" ListCmd
buildDepCmd :: Cmd
-buildDepCmd = mkCmd "build-dep" "Installs the dependencies for a list of packages." "" BuildDepCmd
+buildDepCmd = mkCmd "build-dep" "Installs the dependencies for a list of packages or for a .cabal file." "" BuildDepCmd
updateCmd :: Cmd
updateCmd = mkCmd "update" "Updates list of known packages" "" UpdateCmd
More information about the Cvs-libraries
mailing list