Fix cabal-helper ignoring --with-* flags
This commit is contained in:
parent
1ac71364a9
commit
7d7f848afb
@ -95,15 +95,15 @@ parseCommandArgs opts argv
|
|||||||
|
|
||||||
guessProgramPaths :: Options -> IO Options
|
guessProgramPaths :: Options -> IO Options
|
||||||
guessProgramPaths opts = do
|
guessProgramPaths opts = do
|
||||||
|
if not (same ghcProgram opts dopts) && same ghcPkgProgram opts dopts
|
||||||
|
then do
|
||||||
mghcPkg <- guessToolFromGhcPath "ghc-pkg" (ghcProgram opts)
|
mghcPkg <- guessToolFromGhcPath "ghc-pkg" (ghcProgram opts)
|
||||||
let guessedGhcPkg = fromMaybe (ghcPkgProgram dopts) mghcPkg
|
|
||||||
return opts {
|
return opts {
|
||||||
ghcPkgProgram = if guessGhcPkg then guessedGhcPkg else ghcPkgProgram dopts
|
ghcPkgProgram = fromMaybe (ghcPkgProgram opts) mghcPkg
|
||||||
}
|
}
|
||||||
|
else return opts
|
||||||
where
|
where
|
||||||
guessGhcPkg = nsame ghcProgram opts dopts && same ghcPkgProgram opts dopts
|
|
||||||
same f o o' = f o == f o'
|
same f o o' = f o == f o'
|
||||||
nsame f o o' = f o /= f o'
|
|
||||||
dopts = defaultOptions
|
dopts = defaultOptions
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
@ -34,6 +34,7 @@ import Language.Haskell.GhcMod.Utils
|
|||||||
import Language.Haskell.GhcMod.World
|
import Language.Haskell.GhcMod.World
|
||||||
import Language.Haskell.GhcMod.PathsAndFiles
|
import Language.Haskell.GhcMod.PathsAndFiles
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
|
import System.Process
|
||||||
|
|
||||||
-- | Only package related GHC options, sufficient for things that don't need to
|
-- | Only package related GHC options, sufficient for things that don't need to
|
||||||
-- access home modules
|
-- access home modules
|
||||||
@ -86,21 +87,23 @@ cabalHelper :: (MonadIO m, GmEnv m) => m CabalHelper
|
|||||||
cabalHelper = withCabal $ do
|
cabalHelper = withCabal $ do
|
||||||
Cradle {..} <- cradle
|
Cradle {..} <- cradle
|
||||||
Options {..} <- options
|
Options {..} <- options
|
||||||
|
let progArgs = [ "--with-ghc=" ++ ghcProgram
|
||||||
|
, "--with-ghc-pkg=" ++ ghcPkgProgram
|
||||||
|
, "--with-cabal=" ++ cabalProgram
|
||||||
|
]
|
||||||
|
|
||||||
let args = [ "entrypoints"
|
let args = [ "entrypoints"
|
||||||
, "source-dirs"
|
, "source-dirs"
|
||||||
, "ghc-options"
|
, "ghc-options"
|
||||||
, "ghc-src-options"
|
, "ghc-src-options"
|
||||||
, "ghc-pkg-options"
|
, "ghc-pkg-options"
|
||||||
, "--with-ghc=" ++ ghcProgram
|
] ++ progArgs
|
||||||
, "--with-ghc-pkg=" ++ ghcPkgProgram
|
|
||||||
, "--with-cabal=" ++ cabalProgram
|
|
||||||
]
|
|
||||||
|
|
||||||
distdir = cradleRootDir </> "dist"
|
distdir = cradleRootDir </> "dist"
|
||||||
|
|
||||||
res <- liftIO $ do
|
res <- liftIO $ do
|
||||||
exe <- findLibexecExe "cabal-helper-wrapper"
|
exe <- findLibexecExe "cabal-helper-wrapper"
|
||||||
hexe <- readProcess exe [distdir, "print-exe"] ""
|
hexe <- readProcess exe ([distdir, "print-exe"] ++ progArgs) ""
|
||||||
|
|
||||||
cached cradleRootDir (cabalHelperCache hexe args) $ do
|
cached cradleRootDir (cabalHelperCache hexe args) $ do
|
||||||
out <- readProcess exe (distdir:args) ""
|
out <- readProcess exe (distdir:args) ""
|
||||||
|
Loading…
Reference in New Issue
Block a user