Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Install script with cabal: check there is one ghc in $PATH #1632

Merged
merged 2 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion install/src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ cabalInstallIsOldFailMsg cabalVersion =
++ versionToString requiredCabalVersion
++ "`."


requiredCabalVersion :: RequiredVersion
requiredCabalVersion | isWindowsSystem = requiredCabalVersionForWindows
| otherwise = [2, 4, 1, 0]
Expand Down
16 changes: 16 additions & 0 deletions install/src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ findInstalledGhcs = do
-- filter out stack provided GHCs (assuming that stack programs path is the default one in linux)
$ filter (not . isInfixOf ".stack" . snd) (knownGhcs ++ availableGhcs)

showInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
showInstalledGhcs ghcPaths = do
let msg = "Found the following GHC paths: \n"
++ unlines
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
ghcPaths
)
printInStars msg

checkInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
checkInstalledGhcs ghcPaths = when (null ghcPaths) $ do
let msg = "No ghc installations found in $PATH. \n"
++ "The script requires at least one ghc in $PATH to be able to build hie.\n"
printInStars msg
error msg

-- | Get the path to a GHC that has the version specified by `VersionNumber`
-- If no such GHC can be found, Nothing is returned.
-- First, it is checked whether there is a GHC with the name `ghc-$VersionNumber`.
Expand Down
25 changes: 9 additions & 16 deletions install/src/HieInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,27 @@ defaultMain = do
(\version -> phony ("hie-" ++ version) $ do
need ["submodules"]
need ["check"]
if isRunFromStack then do
if isRunFromStack then
stackInstallHieWithErrMsg (Just version)
else
cabalInstallHie version
)

phony "latest" (need ["hie-" ++ latestVersion])
phony "hie" (need ["data", "latest"])

unless (null versions) $ do
phony "latest" (need ["hie-" ++ latestVersion])
phony "hie" (need ["data", "latest"])

-- stack specific targets
-- Default `stack.yaml` uses ghc-8.8.2 and we can't build hie in windows
-- TODO: Enable for windows when it uses ghc-8.8.3
when (isRunFromStack && not isWindowsSystem) $ do

when (isRunFromStack && not isWindowsSystem) $
phony "dev" $ stackInstallHieWithErrMsg Nothing

-- cabal specific targets
when isRunFromCabal $ do

phony "ghcs" $ do
let
msg =
"Found the following GHC paths: \n"
++ unlines
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
ghcPaths
)
printInStars msg
-- It throws an error if there is no ghc in $PATH
checkInstalledGhcs ghcPaths
phony "ghcs" $ showInstalledGhcs ghcPaths

-- macos specific targets
phony "icu-macos-fix"
Expand Down