Commit fca2d25f authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

DynFlags: add UnitConfig datatype

Avoid directly querying flags from DynFlags to build the UnitState.
Instead go via UnitConfig so that we could reuse this to make another
UnitState for plugins.
parent 8408d521
......@@ -1677,9 +1677,11 @@ interpretPackageEnv dflags = do
where
-- Loading environments (by name or by location)
platformArchOs = platformMini (targetPlatform dflags)
namedEnvPath :: String -> MaybeT IO FilePath
namedEnvPath name = do
appdir <- versionedAppDir dflags
appdir <- versionedAppDir (programName dflags) platformArchOs
return $ appdir </> "environments" </> name
probeEnvName :: String -> MaybeT IO FilePath
......@@ -1716,7 +1718,7 @@ interpretPackageEnv dflags = do
-- e.g. .ghc.environment.x86_64-linux-7.6.3
localEnvFileName :: FilePath
localEnvFileName = ".ghc.environment" <.> versionedFilePath dflags
localEnvFileName = ".ghc.environment" <.> versionedFilePath platformArchOs
-- Search for an env file, starting in the current dir and looking upwards.
-- Fail if we get to the users home dir or the filesystem root. That is,
......
......@@ -1005,14 +1005,14 @@ tablesNextToCode = platformMisc_tablesNextToCode . platformMisc
-- | The directory for this version of ghc in the user's app directory
-- (typically something like @~/.ghc/x86_64-linux-7.6.3@)
--
versionedAppDir :: DynFlags -> MaybeT IO FilePath
versionedAppDir dflags = do
versionedAppDir :: String -> PlatformMini -> MaybeT IO FilePath
versionedAppDir appname platform = do
-- Make sure we handle the case the HOME isn't set (see #11678)
appdir <- tryMaybeT $ getAppUserDataDirectory (programName dflags)
return $ appdir </> versionedFilePath dflags
appdir <- tryMaybeT $ getAppUserDataDirectory appname
return $ appdir </> versionedFilePath platform
versionedFilePath :: DynFlags -> FilePath
versionedFilePath dflags = uniqueSubdir $ platformMini $ targetPlatform dflags
versionedFilePath :: PlatformMini -> FilePath
versionedFilePath platform = uniqueSubdir platform
-- | The target code type of the compilation (if any).
--
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment