Skip to content
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

Remove hls-ghc-x.y from install script and wrapper #1805

Merged
merged 2 commits into from May 7, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions exe/Wrapper.hs
Expand Up @@ -55,7 +55,7 @@ launchHaskellLanguageServer parsedArgs = do
_ -> pure ()

d <- getCurrentDirectory

-- search for the project cradle type
cradle <- findProjectCradle

Expand Down Expand Up @@ -88,11 +88,7 @@ launchHaskellLanguageServer parsedArgs = do

let
hlsBin = "haskell-language-server-" ++ ghcVersion
backupHlsBin =
case dropWhileEnd (/='.') ghcVersion of
[] -> "haskell-language-server"
xs -> "haskell-language-server-" ++ init xs
candidates' = [hlsBin, backupHlsBin, "haskell-language-server"]
candidates' = [hlsBin, "haskell-language-server"]
candidates = map (++ exeExtension) candidates'

hPutStrLn stderr $ "haskell-language-server exe candidates: " ++ show candidates
Expand Down Expand Up @@ -137,12 +133,12 @@ findProjectCradle :: IO (Cradle Void)
findProjectCradle = do
d <- getCurrentDirectory

let initialFp = (d </> "a")
let initialFp = d </> "a"
hieYaml <- Session.findCradle def initialFp

-- Some log messages
case hieYaml of
Just yaml -> hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ initialFp ++ "\""
Nothing -> hPutStrLn stderr "No 'hie.yaml' found. Try to discover the project type!"

Session.loadCradle def hieYaml d
Session.loadCradle def hieYaml d
11 changes: 4 additions & 7 deletions install/src/Cabal.hs
Expand Up @@ -72,20 +72,17 @@ cabalInstallHls versionNumber args = do
++ installMethod
++ args

let minorVerExe = "haskell-language-server-" ++ versionNumber <.> exe
majorVerExe = "haskell-language-server-" ++ dropExtension versionNumber <.> exe
let verExe = "haskell-language-server-" ++ versionNumber <.> exe

let copyCmd old new = if os == "mingw32"
then liftIO $ copyFile old new
else command [] "ln" ["-f", old, new]
copyCmd (localBin </> "haskell-language-server" <.> exe) (localBin </> minorVerExe)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jumm, i think the ghc-x.y.z (minorVerExe in the code) is still needed, to have several hls versions and let the wrapper choose the correct one (the hlsBin in the wrapper code)
We should remove only the ghc-x.y

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry you have renamed it to verExe, nvm

copyCmd (localBin </> "haskell-language-server" <.> exe) (localBin </> majorVerExe)
copyCmd (localBin </> "haskell-language-server" <.> exe) (localBin </> verExe)

printLine $ "Copied executables "
++ ("haskell-language-server-wrapper" <.> exe) ++ ", "
++ ("haskell-language-server" <.> exe) ++ ", "
++ majorVerExe ++ " and "
++ minorVerExe
++ verExe
++ " to " ++ localBin

getProjectFile :: VersionNumber -> Action FilePath
Expand All @@ -108,7 +105,7 @@ checkCabal args = do
return cabalVersion

getCabalVersion :: [String] -> Action String
getCabalVersion args = trimmedStdout <$> (execCabal $ ["--numeric-version"] ++ args)
getCabalVersion args = trimmedStdout <$> execCabal ("--numeric-version" : args)

-- | Error message when the `cabal` binary is an older version
cabalInstallIsOldFailMsg :: String -> String
Expand Down
4 changes: 1 addition & 3 deletions install/src/Stack.hs
Expand Up @@ -39,8 +39,6 @@ stackInstallHls mbVersionNumber args = do
else command [] "ln" ["-f", old, new]
copyCmd (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ versionNumber <.> exe)
copyCmd (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ dropExtension versionNumber <.> exe)

getGhcVersionOfCfgFile :: String -> [String] -> Action VersionNumber
getGhcVersionOfCfgFile stackFile args = do
Expand All @@ -51,7 +49,7 @@ getGhcVersionOfCfgFile stackFile args = do
-- | check `stack` has the required version
checkStack :: [String] -> Action ()
checkStack args = do
stackVersion <- trimmedStdout <$> (execStackShake $ ["--numeric-version"] ++ args)
stackVersion <- trimmedStdout <$> execStackShake ("--numeric-version" : args)
unless (checkVersion requiredStackVersion stackVersion) $ do
printInStars $ stackExeIsOldFailMsg stackVersion
error $ stackExeIsOldFailMsg stackVersion
Expand Down
6 changes: 3 additions & 3 deletions src/Ide/Version.hs
Expand Up @@ -43,9 +43,9 @@ data ProgramsOfInterest = ProgramsOfInterest
showProgramVersionOfInterest :: ProgramsOfInterest -> String
showProgramVersionOfInterest ProgramsOfInterest {..} =
unlines
[ concat ["cabal:\t\t", showVersionWithDefault cabalVersion]
, concat ["stack:\t\t", showVersionWithDefault stackVersion]
, concat ["ghc:\t\t", showVersionWithDefault ghcVersion]
[ "cabal:\t\t" ++ showVersionWithDefault cabalVersion
, "stack:\t\t" ++ showVersionWithDefault stackVersion
, "ghc:\t\t" ++ showVersionWithDefault ghcVersion
]
where
showVersionWithDefault :: Maybe Version -> String
Expand Down