Support multi-package stack projects

This commit is contained in:
Daniel Gröber 2015-09-08 03:54:29 +02:00
parent 026b64ee26
commit f06511bff1
2 changed files with 10 additions and 4 deletions

View File

@ -242,8 +242,8 @@ withCabal action = do
supported <- haveStackSupport supported <- haveStackSupport
if supported if supported
then do then do
spawn [T.stackProgram progs, "build", "--only-dependencies"] spawn [T.stackProgram progs, "build", "--only-dependencies", "."]
spawn [T.stackProgram progs, "build", "--only-configure"] spawn [T.stackProgram progs, "build", "--only-configure", "."]
writeAutogen projdir distdir writeAutogen projdir distdir
else else
gmLog GmWarning "" $ strDoc $ "Stack project configuration is out of date, please reconfigure manually using 'stack build' as your stack version is too old (need at least 0.1.4.0)" gmLog GmWarning "" $ strDoc $ "Stack project configuration is out of date, please reconfigure manually using 'stack build' as your stack version is too old (need at least 0.1.4.0)"

View File

@ -20,6 +20,7 @@ module Language.Haskell.GhcMod.PathsAndFiles (
) where ) where
import Config (cProjectVersion) import Config (cProjectVersion)
import Control.Arrow (second)
import Control.Applicative import Control.Applicative
import Control.Exception as E import Control.Exception as E
import Control.Monad import Control.Monad
@ -77,7 +78,12 @@ findCabalFile dir = do
appendDir d fs = (d </>) `map` fs appendDir d fs = (d </>) `map` fs
findStackConfigFile :: FilePath -> IO (Maybe FilePath) findStackConfigFile :: FilePath -> IO (Maybe FilePath)
findStackConfigFile dir = mightExist (dir </> "stack.yaml") findStackConfigFile dir = do
fs <- map (second listToMaybe) <$> findFileInParentsP (=="stack.yaml") dir
case find (isJust . snd) fs of
Nothing -> return Nothing
Just (d, Just a) -> return $ Just $ d </> a
Just (_, Nothing) -> error "findStackConfigFile"
getStackDistDir :: (IOish m, GmOut m) => FilePath -> m (Maybe FilePath) getStackDistDir :: (IOish m, GmOut m) => FilePath -> m (Maybe FilePath)
getStackDistDir projdir = U.withDirectory_ projdir $ runMaybeT $ do getStackDistDir projdir = U.withDirectory_ projdir $ runMaybeT $ do
@ -165,7 +171,7 @@ takeExtension' p =
-- it's parent directories. -- it's parent directories.
findFileInParentsP :: (FilePath -> Bool) -> FilePath findFileInParentsP :: (FilePath -> Bool) -> FilePath
-> IO [(DirPath, [FileName])] -> IO [(DirPath, [FileName])]
findFileInParentsP p dir = findFileInParentsP p dir' = makeAbsolute dir' >>= \dir ->
getFilesP p `zipMapM` parents dir getFilesP p `zipMapM` parents dir
-- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@. -- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@.