diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-12-29 15:55:20 +0100 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2019-12-29 16:35:59 +0100 |
commit | cd293cc8ef24d5014bdea150f7d315d43126d055 (patch) | |
tree | fb47d1a4b9cd0dbd92da4e5228dcbd3606f3b9ba /tests | |
parent | 621f81d9a5b31990c08453c67b26fbfc11ae3bf4 (diff) |
ghc-session: Get GHC libdir from --print-libdir command
Using ghc-paths bypasses cabal's rebuild checks though, for example,
installing the compiler into a different directory will change the libdir
but cabal won't recompile ghc-paths.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GhcSession.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 58b3755..f9f4e04 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -10,7 +10,6 @@ module Main where import GHC import Config -import GHC.Paths (libdir) import Outputable import DynFlags @@ -38,7 +37,7 @@ import CabalHelper.Shared.Common import CabalHelper.Compiletime.Types (Env) import CabalHelper.Compiletime.Process (readProcess, callProcessStderr) import CabalHelper.Compiletime.Program.GHC - (GhcVersion(..), ghcVersion) + (GhcVersion(..), ghcVersion, ghcLibdir) import CabalHelper.Compiletime.Program.CabalInstall (CabalInstallVersion(..), cabalInstallVersion) @@ -295,6 +294,8 @@ test modProgs (psdImpl -> ProjSetupImpl{..}) topdir tmpdir projdir cabal_file let progs = modProgs (qePrograms qe') qe = qe' { qePrograms = progs } + ghc_libdir <- let ?progs = progs; ?verbose = const False in ghcLibdir + psiSdist progs topdir tmpdir cs <- concat <$> runQuery (allUnits (Map.elems . uiComponents)) qe @@ -318,7 +319,7 @@ test modProgs (psdImpl -> ProjSetupImpl{..}) topdir tmpdir projdir cabal_file putStrLn sopts hFlush stdout - tr <- compileModule pkgdir ciEntrypoints ciSourceDirs opts' + tr <- compileModule ghc_libdir pkgdir ciEntrypoints ciSourceDirs opts' return $ tr ciComponentName where formatArg x @@ -330,9 +331,9 @@ addCabalProject dir = do writeFile (dir </> "cabal.project") "packages: .\n" compileModule - :: FilePath -> ChEntrypoint -> [FilePath] -> [String] + :: FilePath -> FilePath -> ChEntrypoint -> [FilePath] -> [String] -> IO (ChComponentName -> FilePath -> String -> String -> TestResult) -compileModule pkgdir ep srcdirs opts = do +compileModule ghc_libdir pkgdir ep srcdirs opts = do cwd_before <- getCurrentDirectory setCurrentDirectory pkgdir flip E.finally (setCurrentDirectory cwd_before) $ do @@ -342,7 +343,7 @@ compileModule pkgdir ep srcdirs opts = do E.handle (\(ec :: ExitCode) -> print ec >> return (TestResult False)) $ do defaultErrorHandler defaultFatalMessager defaultFlushOut $ do - runGhc (Just libdir) $ do + runGhc (Just ghc_libdir) $ do let printGhcEx e = GHC.printException e >> return (TestResult False) handleSourceError printGhcEx $ do |