hie-bios-0.7.1: Set up a GHC API session
Safe HaskellNone
LanguageHaskell2010

HIE.Bios.Environment

Synopsis

Documentation

initSession :: GhcMonad m => ComponentOptions -> m [Target] Source #

Start a GHC session and set some sensible options for tooling to use. Creates a folder in the cache directory to cache interface files to make reloading faster.

getRuntimeGhcLibDir :: Cradle a -> IO (CradleLoadResult FilePath) Source #

getRuntimeGhcLibDir cradle will give you the ghc libDir: do not use runGhcCmd directly. This will also perform additional lookups and fallbacks to try and get a reliable library directory. It tries this specific order of paths:

  1. the NIX_GHC_LIBDIR if it is set
  2. calling runCradleGhc on the provided cradle

getRuntimeGhcVersion :: Cradle a -> IO (CradleLoadResult String) Source #

Gets the version of ghc used when compiling the cradle. It is based off of getRuntimeGhcLibDir. If it can't work out the verison reliably, it will return a CradleError

makeDynFlagsAbsolute :: FilePath -> DynFlags -> DynFlags Source #

Make filepaths in the given DynFlags absolute. This makes the DynFlags independent of the current working directory.

getCacheDir :: FilePath -> IO FilePath Source #

Back in the day we used to clear the cache at the start of each session, however, it's not really necessary as 1. There is one cache dir for any change in options. 2. Interface files are resistent to bad option changes anyway.

clearInterfaceCache :: FilePath -> IO ()
clearInterfaceCache fp = do
  cd <- getCacheDir fp
  res <- doesPathExist cd
  when res (removeDirectoryRecursive cd)

Prepends the cache directory used by the library to the supplied file path. It tries to use the path under the environment variable `$HIE_BIOS_CACHE_DIR` and falls back to the standard `$XDG_CACHE_HOME/hie-bios` if the former is not set

addCmdOpts :: GhcMonad m => [String] -> DynFlags -> m (DynFlags, [Target]) Source #

Interpret and set the specific command line options. A lot of this code is just copied from ghc/Main.hs It would be good to move this code into a library module so we can just use it rather than copy it.