Write cabal_macros.h on reconfigure when using stack

This commit is contained in:
Daniel Gröber 2015-09-02 04:57:25 +02:00
parent 82c5069cd8
commit a8c111cda3

View File

@ -209,6 +209,12 @@ withCabal action = do
action action
where 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 cabalReconfigure readProc progs crdl projdir distdir = do
withDirectory_ (cradleRootDir crdl) $ do withDirectory_ (cradleRootDir crdl) $ do
cusPkgStack <- maybe [] ((PackageDb "clear"):) <$> getCustomPkgDbStack cusPkgStack <- maybe [] ((PackageDb "clear"):) <$> getCustomPkgDbStack
@ -221,16 +227,19 @@ withCabal action = do
else [] else []
++ map pkgDbArg cusPkgStack ++ map pkgDbArg cusPkgStack
liftIO $ void $ readProc (T.cabalProgram progs) ("configure":progOpts) "" liftIO $ void $ readProc (T.cabalProgram progs) ("configure":progOpts) ""
gmLog GmDebug "" $ strDoc $ "writing Cabal autogen files" writeAutogen projdir distdir
liftIO $ writeAutogenFiles readProc projdir distdir
stackReconfigure crdl progs = do stackReconfigure crdl progs = do
let projdir = cradleRootDir crdl
distdir = projdir </> cradleDistDir crdl
withDirectory_ (cradleRootDir crdl) $ do withDirectory_ (cradleRootDir crdl) $ 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
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 1.4.0.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 1.4.0.0)"