From 7d7f848afb1829daf969add10a158b8bfddc4497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Sun, 8 Mar 2015 20:18:36 +0100 Subject: [PATCH] Fix cabal-helper ignoring --with-* flags --- CabalHelper/Wrapper.hs | 14 +++++++------- Language/Haskell/GhcMod/CabalHelper.hs | 13 ++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CabalHelper/Wrapper.hs b/CabalHelper/Wrapper.hs index eef1fd4..34f5f9c 100644 --- a/CabalHelper/Wrapper.hs +++ b/CabalHelper/Wrapper.hs @@ -95,15 +95,15 @@ parseCommandArgs opts argv guessProgramPaths :: Options -> IO Options guessProgramPaths opts = do - mghcPkg <- guessToolFromGhcPath "ghc-pkg" (ghcProgram opts) - let guessedGhcPkg = fromMaybe (ghcPkgProgram dopts) mghcPkg - return opts { - ghcPkgProgram = if guessGhcPkg then guessedGhcPkg else ghcPkgProgram dopts - } + if not (same ghcProgram opts dopts) && same ghcPkgProgram opts dopts + then do + mghcPkg <- guessToolFromGhcPath "ghc-pkg" (ghcProgram opts) + return opts { + ghcPkgProgram = fromMaybe (ghcPkgProgram opts) mghcPkg + } + else return opts where - guessGhcPkg = nsame ghcProgram opts dopts && same ghcPkgProgram opts dopts same f o o' = f o == f o' - nsame f o o' = f o /= f o' dopts = defaultOptions main :: IO () diff --git a/Language/Haskell/GhcMod/CabalHelper.hs b/Language/Haskell/GhcMod/CabalHelper.hs index 27fd71d..46e512c 100644 --- a/Language/Haskell/GhcMod/CabalHelper.hs +++ b/Language/Haskell/GhcMod/CabalHelper.hs @@ -34,6 +34,7 @@ import Language.Haskell.GhcMod.Utils import Language.Haskell.GhcMod.World import Language.Haskell.GhcMod.PathsAndFiles import System.FilePath +import System.Process -- | Only package related GHC options, sufficient for things that don't need to -- access home modules @@ -86,21 +87,23 @@ cabalHelper :: (MonadIO m, GmEnv m) => m CabalHelper cabalHelper = withCabal $ do Cradle {..} <- cradle Options {..} <- options + let progArgs = [ "--with-ghc=" ++ ghcProgram + , "--with-ghc-pkg=" ++ ghcPkgProgram + , "--with-cabal=" ++ cabalProgram + ] + let args = [ "entrypoints" , "source-dirs" , "ghc-options" , "ghc-src-options" , "ghc-pkg-options" - , "--with-ghc=" ++ ghcProgram - , "--with-ghc-pkg=" ++ ghcPkgProgram - , "--with-cabal=" ++ cabalProgram - ] + ] ++ progArgs distdir = cradleRootDir "dist" res <- liftIO $ do exe <- findLibexecExe "cabal-helper-wrapper" - hexe <- readProcess exe [distdir, "print-exe"] "" + hexe <- readProcess exe ([distdir, "print-exe"] ++ progArgs) "" cached cradleRootDir (cabalHelperCache hexe args) $ do out <- readProcess exe (distdir:args) ""