Skip to content

Complete renaming from hie to hls in install script #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 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
6 changes: 3 additions & 3 deletions install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{- stack
runghc
--stack-yaml=install/shake.yaml
--package hie-install
--package hls-install
-}
{- cabal:
build-depends:
base
, hie-install
, hls-install
-}
-- call as:
-- * `cabal v2-run install.hs --project-file install/shake.project <target>`
Expand All @@ -16,6 +16,6 @@ build-depends:
-- TODO: set `shake.project` in cabal-config above, when supported
-- (see https://github.com/haskell/cabal/issues/6353)

import HieInstall (defaultMain)
import HlsInstall (defaultMain)

main = defaultMain
2 changes: 0 additions & 2 deletions install/Setup.hs

This file was deleted.

6 changes: 3 additions & 3 deletions install/hie-install.cabal → install/hls-install.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: hie-install
name: hls-install
version: 0.8.0.0
synopsis: Install the haskell-ide-engine
synopsis: Install the haskell-language-engine
license: BSD3
author: Many, TBD when we release
maintainer: samuel.pilz@posteo.net
Expand All @@ -10,7 +10,7 @@ cabal-version: >=2.0

library
hs-source-dirs: src
exposed-modules: HieInstall
exposed-modules: HlsInstall
other-modules: BuildSystem
, Stack
, Version
Expand Down
2 changes: 1 addition & 1 deletion install/shake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ nix:
packages: [ zlib ]

flags:
hie-install:
hls-install:
run-from-stack: true
4 changes: 2 additions & 2 deletions install/src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ getGhcPathOfOrThrowError versionNumber =
error (ghcVersionNotFoundFailMsg versionNumber)
Just p -> return p

cabalInstallHie :: VersionNumber -> [String] -> Action ()
cabalInstallHie versionNumber args = do
cabalInstallHls :: VersionNumber -> [String] -> Action ()
cabalInstallHls versionNumber args = do
localBin <- liftIO $ getInstallDir
cabalVersion <- getCabalVersion args
ghcPath <- getGhcPathOfOrThrowError versionNumber
Expand Down
24 changes: 12 additions & 12 deletions install/src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ isWindowsSystem = os `elem` ["mingw32", "win32"]

findInstalledGhcs :: IO [(VersionNumber, GhcPath)]
findInstalledGhcs = do
hieVersions <- getHieVersions :: IO [VersionNumber]
hlsVersions <- getHlsVersions :: IO [VersionNumber]
knownGhcs <- mapMaybeM
(\version -> getGhcPathOf version >>= \case
Nothing -> return Nothing
Just p -> return $ Just (version, p)
)
(reverse hieVersions)
(reverse hlsVersions)
-- filter out not supported ghc versions
availableGhcs <- filter ((`elem` hieVersions) . fst) <$> getGhcPaths
availableGhcs <- filter ((`elem` hlsVersions) . fst) <$> getGhcPaths
return
-- sort by version to make it coherent with getHieVersions
-- sort by version to make it coherent with getHlsVersions
$ sortBy (comparing fst)
-- nub by version. knownGhcs takes precedence.
$ nubBy ((==) `on` fst)
Expand Down Expand Up @@ -103,15 +103,15 @@ ghcVersionNotFoundFailMsg versionNumber =
<> "Either install a fitting GHC, use the stack targets or modify the PATH variable accordingly."


-- | Defines all different hie versions that are buildable.
-- | Defines all different hls versions that are buildable.
--
-- The current directory is scanned for `stack-*.yaml` files.
getHieVersions :: MonadIO m => m [VersionNumber]
getHieVersions = do
getHlsVersions :: MonadIO m => m [VersionNumber]
getHlsVersions = do
let stackYamlPrefix = T.pack "stack-"
let stackYamlSuffix = T.pack ".yaml"
files <- liftIO $ listDirectory "."
let hieVersions =
let hlsVersions =
files
& map T.pack
& mapMaybe
Expand All @@ -120,10 +120,10 @@ getHieVersions = do
-- the following line excludes `8.6.3`, `8.8.1` and `8.8.2` on windows systems
& filter (\p -> not (isWindowsSystem && p `elem` ["8.6.3", "8.8.1", "8.8.2"]))
& sort
return hieVersions
return hlsVersions


-- | Most recent version of hie.
-- | Most recent version of hls.
-- Shown in the more concise help message.
mostRecentHieVersion :: MonadIO m => m VersionNumber
mostRecentHieVersion = last <$> getHieVersions
mostRecentHlsVersion :: MonadIO m => m VersionNumber
mostRecentHlsVersion = last <$> getHlsVersions
16 changes: 8 additions & 8 deletions install/src/Help.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ printUsage = do
-- | short help message is printed by default
shortHelpMessage :: Action ()
shortHelpMessage = do
hieVersions <- getHieVersions
hlsVersions <- getHlsVersions
printUsage
printLine ""
printLine "Targets:"
mapM_ (printLineIndented . showHelpItem (spaces hieVersions)) (targets hieVersions)
mapM_ (printLineIndented . showHelpItem (spaces hlsVersions)) (targets hlsVersions)
printLine ""
where
spaces hieVersions = space (targets hieVersions)
targets hieVersions =
spaces hlsVersions = space (targets hlsVersions)
targets hlsVersions =
[ ("help", "Show help message including all targets")
, emptyTarget
, buildTarget
, buildLatestTarget
, hieTarget $ last hieVersions
, hlsTarget $ last hlsVersions
, buildDataTarget
, cabalGhcsTarget
]
Expand Down Expand Up @@ -90,7 +90,7 @@ helpMessage versions@BuildableVersions {..} = do
generalTargets = [helpTarget]

defaultTargets = [buildTarget, buildLatestTarget, buildDataTarget]
++ map hieTarget (getDefaultBuildSystemVersions versions)
++ map hlsTarget (getDefaultBuildSystemVersions versions)

-- | Empty target. Purpose is to introduce a newline between the targets
emptyTarget :: (String, String)
Expand All @@ -99,8 +99,8 @@ emptyTarget = ("", "")
templateTarget :: (String, String)
templateTarget = ("<target>", "")

hieTarget :: String -> TargetDescription
hieTarget version =
hlsTarget :: String -> TargetDescription
hlsTarget version =
("hls-" ++ version, "Install haskell-language-server for GHC version " ++ version)

buildTarget :: TargetDescription
Expand Down
12 changes: 6 additions & 6 deletions install/src/HieInstall.hs → install/src/HlsInstall.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HieInstall where
module HlsInstall where

import Development.Shake
import Control.Monad
Expand All @@ -21,7 +21,7 @@ defaultMain = do
let cabalVersions = map fst ghcPaths

-- used for stack-based targets
stackVersions <- getHieVersions
stackVersions <- getHlsVersions

let versions = if isRunFromStack then stackVersions else cabalVersions

Expand Down Expand Up @@ -62,22 +62,22 @@ defaultMain = do
need ["submodules"]
need ["check"]
if isRunFromStack then
stackInstallHieWithErrMsg (Just version) args
stackInstallHlsWithErrMsg (Just version) args
else
cabalInstallHie version args
cabalInstallHls version args
)

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

-- stack specific targets
-- Default `stack.yaml` uses ghc-8.8.2 and we can't build hie in windows
-- Default `stack.yaml` uses ghc-8.8.2 and we can't build hls in windows
-- TODO: Enable for windows when it uses ghc-8.8.3
when (isRunFromStack && not isWindowsSystem) $
phony "dev" $ do
need ["show-options"]
stackInstallHieWithErrMsg Nothing args
stackInstallHlsWithErrMsg Nothing args

-- cabal specific targets
when isRunFromCabal $ do
Expand Down
16 changes: 8 additions & 8 deletions install/src/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import System.Directory ( copyFile )
import Version
import Print

stackInstallHieWithErrMsg :: Maybe VersionNumber -> [String] -> Action ()
stackInstallHieWithErrMsg mbVersionNumber args =
stackInstallHie mbVersionNumber args
stackInstallHlsWithErrMsg :: Maybe VersionNumber -> [String] -> Action ()
stackInstallHlsWithErrMsg mbVersionNumber args =
stackInstallHls mbVersionNumber args
`actionOnException` liftIO (putStrLn stackBuildFailMsg)

-- | copy the built binaries into the localBinDir
stackInstallHie :: Maybe VersionNumber -> [String] -> Action ()
stackInstallHie mbVersionNumber args = do
stackInstallHls :: Maybe VersionNumber -> [String] -> Action ()
stackInstallHls mbVersionNumber args = do
versionNumber <-
case mbVersionNumber of
Nothing -> do
Expand All @@ -30,11 +30,11 @@ stackInstallHie mbVersionNumber args = do
return vn

localBinDir <- getLocalBin args
let hie = "haskell-language-server" <.> exe
let hls = "haskell-language-server" <.> exe
liftIO $ do
copyFile (localBinDir </> hie)
copyFile (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ versionNumber <.> exe)
copyFile (localBinDir </> hie)
copyFile (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ dropExtension versionNumber <.> exe)

getGhcVersionOfCfgFile :: String -> [String] -> Action VersionNumber
Expand Down