[commit: Cabal] master: init: see whether source directory 'src' exists. (e2d8d48)
Ian Lynagh
igloo at earth.li
Sat Mar 17 17:07:31 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/e2d8d48779f77961e5f84e8a0e1a7097a720bcf1
>---------------------------------------------------------------
commit e2d8d48779f77961e5f84e8a0e1a7097a720bcf1
Author: Brent Yorgey <byorgey at cis.upenn.edu>
Date: Fri Oct 14 20:22:30 2011 +0000
init: see whether source directory 'src' exists.
>---------------------------------------------------------------
cabal-install/Distribution/Client/Init.hs | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/cabal-install/Distribution/Client/Init.hs b/cabal-install/Distribution/Client/Init.hs
index f2f9c85..d6ead0b 100644
--- a/cabal-install/Distribution/Client/Init.hs
+++ b/cabal-install/Distribution/Client/Init.hs
@@ -24,7 +24,9 @@ module Distribution.Client.Init (
import System.IO
( hSetBuffering, stdout, BufferMode(..) )
import System.Directory
- ( getCurrentDirectory )
+ ( getCurrentDirectory, doesDirectoryExist )
+import System.FilePath
+ ( (</>) )
import Data.Time
( getCurrentTime, utcToLocalTime, toGregorian, localDay, getCurrentTimeZone )
@@ -223,14 +225,20 @@ getGenComments flags = do
getSrcDir :: InitFlags -> IO InitFlags
getSrcDir flags = do
srcDirs <- return (sourceDirs flags)
- ?>> guessSourceDirs
+ ?>> Just `fmap` (guessSourceDirs flags)
return $ flags { sourceDirs = srcDirs }
--- XXX
--- | Try to guess source directories.
-guessSourceDirs :: IO (Maybe [String])
-guessSourceDirs = return Nothing
+-- | Try to guess source directories. Could try harder; for the
+-- moment just looks to see whether there is a directory called 'src'.
+guessSourceDirs :: InitFlags -> IO [String]
+guessSourceDirs flags = do
+ dir <- fromMaybe getCurrentDirectory
+ (fmap return . flagToMaybe $ packageDir flags)
+ srcIsDir <- doesDirectoryExist (dir </> "src")
+ if srcIsDir
+ then return ["src"]
+ else return []
-- | Get the list of exposed modules and extra tools needed to build them.
getModulesAndBuildTools :: InitFlags -> IO InitFlags
More information about the Cvs-libraries
mailing list