Use cabal-helper for stack
This commit is contained in:
parent
18a8c67d39
commit
23a48aa6c7
@ -169,9 +169,7 @@ withCabal action = do
|
|||||||
|
|
||||||
Nothing -> return False
|
Nothing -> return False
|
||||||
|
|
||||||
cusPkgStack <- maybe [] ((PackageDb "clear"):) <$> getCustomPkgDbStack
|
projType <- cradleProjectType <$> cradle
|
||||||
|
|
||||||
--TODO: also invalidate when sandboxConfig file changed
|
|
||||||
|
|
||||||
when (isSetupConfigOutOfDate mCabalFile mCabalConfig) $
|
when (isSetupConfigOutOfDate mCabalFile mCabalConfig) $
|
||||||
gmLog GmDebug "" $ strDoc $ "setup configuration is out of date, reconfiguring Cabal project."
|
gmLog GmDebug "" $ strDoc $ "setup configuration is out of date, reconfiguring Cabal project."
|
||||||
@ -185,7 +183,21 @@ withCabal action = do
|
|||||||
when ( isSetupConfigOutOfDate mCabalFile mCabalConfig
|
when ( isSetupConfigOutOfDate mCabalFile mCabalConfig
|
||||||
|| pkgDbStackOutOfSync
|
|| pkgDbStackOutOfSync
|
||||||
|| isSetupConfigOutOfDate mCabalSandboxConfig mCabalConfig) $
|
|| isSetupConfigOutOfDate mCabalSandboxConfig mCabalConfig) $
|
||||||
|
case projType of
|
||||||
|
CabalProject ->
|
||||||
|
cabalReconfigure readProc opts crdl projdir distdir
|
||||||
|
StackProject ->
|
||||||
|
-- https://github.com/commercialhaskell/stack/issues/820
|
||||||
|
gmLog GmWarning "" $ strDoc $ "Stack project configuration is out of date, please reconfigure manually using 'stack build'"
|
||||||
|
_ ->
|
||||||
|
error $ "withCabal: unsupported project type: " ++ show projType
|
||||||
|
|
||||||
|
action
|
||||||
|
|
||||||
|
where
|
||||||
|
cabalReconfigure readProc opts crdl projdir distdir = do
|
||||||
withDirectory_ (cradleRootDir crdl) $ do
|
withDirectory_ (cradleRootDir crdl) $ do
|
||||||
|
cusPkgStack <- maybe [] ((PackageDb "clear"):) <$> getCustomPkgDbStack
|
||||||
let progOpts =
|
let progOpts =
|
||||||
[ "--with-ghc=" ++ T.ghcProgram opts ]
|
[ "--with-ghc=" ++ T.ghcProgram opts ]
|
||||||
-- Only pass ghc-pkg if it was actually set otherwise we
|
-- Only pass ghc-pkg if it was actually set otherwise we
|
||||||
@ -197,7 +209,7 @@ withCabal action = do
|
|||||||
liftIO $ void $ readProc (T.cabalProgram opts) ("configure":progOpts) ""
|
liftIO $ void $ readProc (T.cabalProgram opts) ("configure":progOpts) ""
|
||||||
gmLog GmDebug "" $ strDoc $ "writing Cabal autogen files"
|
gmLog GmDebug "" $ strDoc $ "writing Cabal autogen files"
|
||||||
liftIO $ writeAutogenFiles readProc projdir distdir
|
liftIO $ writeAutogenFiles readProc projdir distdir
|
||||||
action
|
|
||||||
|
|
||||||
pkgDbArg :: GhcPkgDb -> String
|
pkgDbArg :: GhcPkgDb -> String
|
||||||
pkgDbArg GlobalDb = "--package-db=global"
|
pkgDbArg GlobalDb = "--package-db=global"
|
||||||
|
@ -149,7 +149,7 @@ targetGhcOptions crdl sefnmn = do
|
|||||||
|
|
||||||
case cradleProjectType crdl of
|
case cradleProjectType crdl of
|
||||||
CabalProject -> cabalOpts crdl
|
CabalProject -> cabalOpts crdl
|
||||||
StackProject -> stackOpts crdl
|
StackProject -> cabalOpts crdl
|
||||||
_ -> sandboxOpts crdl
|
_ -> sandboxOpts crdl
|
||||||
where
|
where
|
||||||
zipMap f l = l `zip` (f `map` l)
|
zipMap f l = l `zip` (f `map` l)
|
||||||
@ -266,17 +266,9 @@ packageGhcOptions = do
|
|||||||
crdl <- cradle
|
crdl <- cradle
|
||||||
case cradleProjectType crdl of
|
case cradleProjectType crdl of
|
||||||
CabalProject -> getGhcMergedPkgOptions
|
CabalProject -> getGhcMergedPkgOptions
|
||||||
StackProject -> stackOpts crdl
|
StackProject -> getGhcMergedPkgOptions
|
||||||
_ -> sandboxOpts crdl
|
_ -> sandboxOpts crdl
|
||||||
|
|
||||||
stackOpts :: MonadIO m => Cradle -> m [String]
|
|
||||||
stackOpts crdl = do
|
|
||||||
pkgDbStack <- liftIO getStackPackageDbStack
|
|
||||||
let pkgOpts = ghcDbStackOpts pkgDbStack
|
|
||||||
return $ ["-i" ++ d | d <- [wdir,rdir]] ++ pkgOpts ++ ["-Wall"]
|
|
||||||
where
|
|
||||||
(wdir, rdir) = (cradleCurrentDir crdl, cradleRootDir crdl)
|
|
||||||
|
|
||||||
-- also works for plain projects!
|
-- also works for plain projects!
|
||||||
sandboxOpts :: MonadIO m => Cradle -> m [String]
|
sandboxOpts :: MonadIO m => Cradle -> m [String]
|
||||||
sandboxOpts crdl = do
|
sandboxOpts crdl = do
|
||||||
|
Loading…
Reference in New Issue
Block a user