Skip to content

Commit

Permalink
Refactoring related to ExtraDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Jan 22, 2024
1 parent 912c8dc commit 4306bf7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ import Stack.GhcPkg
, mkGhcPackagePath )
import Stack.Prelude
import Stack.Setup.Installed
( Tool (..), extraDirs, filterTools, getCompilerVersion
, installDir, listInstalled, markInstalled, tempInstallDir
( Tool (..), filterTools, getCompilerVersion, installDir
, listInstalled, markInstalled, tempInstallDir,toolExtraDirs
, toolString, unmarkInstalled
)
import Stack.SourceMap
Expand Down Expand Up @@ -984,11 +984,11 @@ withNewLocalBuildTargets targets f = do

-- | Add the include and lib paths to the given Config
addIncludeLib :: ExtraDirs -> Config -> Config
addIncludeLib (ExtraDirs _bins includes libs) config = config
addIncludeLib extraDirs config = config
{ extraIncludeDirs =
config.extraIncludeDirs ++ map toFilePathNoTrailingSep includes
config.extraIncludeDirs ++ map toFilePathNoTrailingSep extraDirs.includes
, extraLibDirs =
config.extraLibDirs ++ map toFilePathNoTrailingSep libs
config.extraLibDirs ++ map toFilePathNoTrailingSep extraDirs.libs
}

-- | Ensure both the compiler and the msys toolchain are installed and
Expand All @@ -1000,7 +1000,7 @@ ensureCompilerAndMsys ::
ensureCompilerAndMsys sopts = do
getSetupInfo' <- memoizeRef getSetupInfo
mmsys2Tool <- ensureMsys sopts getSetupInfo'
mmsysPaths <- maybe (pure Nothing) (fmap Just . extraDirs) mmsys2Tool
mmsysPaths <- maybe (pure Nothing) (fmap Just . toolExtraDirs) mmsys2Tool
actual <- either throwIO pure $ wantedToActual sopts.wantedCompiler
didWarn <- warnUnsupportedCompiler $ getGhcVersion actual
-- Modify the initial environment to include the MSYS2 path, if MSYS2 is being
Expand Down Expand Up @@ -1259,8 +1259,8 @@ ensureCompiler sopts getSetupInfo' = do
Just cp -> do
let paths = ExtraDirs
{ bins = [parent cp.compiler]
, include = []
, lib = []
, includes = []
, libs = []
}
pure (cp, paths)

Expand Down Expand Up @@ -1348,7 +1348,7 @@ ensureSandboxedCompiler sopts getSetupInfo' = do
commitId
flavour
_ -> installGhcBindist sopts getSetupInfo' installed
paths <- extraDirs compilerTool
paths <- toolExtraDirs compilerTool

wc <- either throwIO (pure . whichCompiler) $ wantedToActual wanted
menv0 <- view processContextL
Expand Down
14 changes: 7 additions & 7 deletions src/Stack/Setup/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Stack.Setup.Installed
, toolNameString
, parseToolText
, filterTools
, extraDirs
, toolExtraDirs
, installDir
, tempInstallDir
) where
Expand Down Expand Up @@ -133,8 +133,8 @@ getCompilerVersion wc exe =
isValid c = c == '.' || isDigit c

-- | Binary directories for the given installed package
extraDirs :: HasConfig env => Tool -> RIO env ExtraDirs
extraDirs tool = do
toolExtraDirs :: HasConfig env => Tool -> RIO env ExtraDirs
toolExtraDirs tool = do
config <- view configL
dir <- installDir config.localPrograms tool
case (config.platform, toolNameString tool) of
Expand All @@ -150,10 +150,10 @@ extraDirs tool = do
, dir </> relDirUsr </> relDirBin
, dir </> relDirUsr </> relDirLocal </> relDirBin
]
, include =
, includes =
[ dir </> relDirMingw32 </> relDirInclude
]
, lib =
, libs =
[ dir </> relDirMingw32 </> relDirLib
, dir </> relDirMingw32 </> relDirBin
]
Expand All @@ -164,10 +164,10 @@ extraDirs tool = do
, dir </> relDirUsr </> relDirBin
, dir </> relDirUsr </> relDirLocal </> relDirBin
]
, include =
, includes =
[ dir </> relDirMingw64 </> relDirInclude
]
, lib =
, libs =
[ dir </> relDirMingw64 </> relDirLib
, dir </> relDirMingw64 </> relDirBin
]
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Types/ExtraDirs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Stack.Prelude

data ExtraDirs = ExtraDirs
{ bins :: ![Path Abs Dir]
, include :: ![Path Abs Dir]
, lib :: ![Path Abs Dir]
, includes :: ![Path Abs Dir]
, libs :: ![Path Abs Dir]
}
deriving (Show, Generic)

Expand Down

0 comments on commit 4306bf7

Please sign in to comment.