From a8c111cda322d3ce730f2ce1920b52299c5115c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Wed, 2 Sep 2015 04:57:25 +0200 Subject: [PATCH] Write cabal_macros.h on reconfigure when using stack --- Language/Haskell/GhcMod/CabalHelper.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/CabalHelper.hs b/Language/Haskell/GhcMod/CabalHelper.hs index 8d80172..3c04d68 100644 --- a/Language/Haskell/GhcMod/CabalHelper.hs +++ b/Language/Haskell/GhcMod/CabalHelper.hs @@ -209,6 +209,12 @@ withCabal action = do action where + writeAutogen projdir distdir = do + readProc <- gmReadProcess + gmLog GmDebug "" $ strDoc $ "writing Cabal autogen files" + liftIO $ writeAutogenFiles readProc projdir distdir + + cabalReconfigure readProc progs crdl projdir distdir = do withDirectory_ (cradleRootDir crdl) $ do cusPkgStack <- maybe [] ((PackageDb "clear"):) <$> getCustomPkgDbStack @@ -221,16 +227,19 @@ withCabal action = do else [] ++ map pkgDbArg cusPkgStack liftIO $ void $ readProc (T.cabalProgram progs) ("configure":progOpts) "" - gmLog GmDebug "" $ strDoc $ "writing Cabal autogen files" - liftIO $ writeAutogenFiles readProc projdir distdir + writeAutogen projdir distdir stackReconfigure crdl progs = do + let projdir = cradleRootDir crdl + distdir = projdir cradleDistDir crdl + withDirectory_ (cradleRootDir crdl) $ do supported <- haveStackSupport if supported then do spawn [T.stackProgram progs, "build", "--only-dependencies"] spawn [T.stackProgram progs, "build", "--only-configure"] + writeAutogen projdir distdir 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 1.4.0.0)"