Skip to content

install: create hls hardlinks instead of copies except on Windows #451

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
Oct 2, 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
10 changes: 6 additions & 4 deletions install/src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Development.Shake
import Development.Shake.FilePath
import Control.Monad
import System.Directory ( copyFile )
import System.Info ( os )

import Version
import Print
Expand Down Expand Up @@ -74,9 +75,11 @@ cabalInstallHls versionNumber args = do
let minorVerExe = "haskell-language-server-" ++ versionNumber <.> exe
majorVerExe = "haskell-language-server-" ++ dropExtension versionNumber <.> exe

liftIO $ do
copyFile (localBin </> "haskell-language-server" <.> exe) (localBin </> minorVerExe)
copyFile (localBin </> "haskell-language-server" <.> exe) (localBin </> majorVerExe)
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)
copyCmd (localBin </> "haskell-language-server" <.> exe) (localBin </> majorVerExe)

printLine $ "Copied executables "
++ ("haskell-language-server-wrapper" <.> exe) ++ ", "
Expand Down Expand Up @@ -141,4 +144,3 @@ getVerbosityArg v = "-v" ++ cabalVerbosity
Chatty -> "2"
#endif
Diagnostic -> "3"

13 changes: 8 additions & 5 deletions install/src/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Development.Shake.FilePath
import Control.Monad
import System.Directory ( copyFile )
-- import System.FilePath ( (</>) )
import System.Info ( os )
import Version
import Print

Expand All @@ -32,11 +33,13 @@ stackInstallHls mbVersionNumber args = do

localBinDir <- getLocalBin args
let hls = "haskell-language-server" <.> exe
liftIO $ do
copyFile (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ versionNumber <.> exe)
copyFile (localBinDir </> hls)
(localBinDir </> "haskell-language-server-" ++ dropExtension versionNumber <.> exe)
copyCmd old new = if os == "mingw32"
then liftIO $ copyFile old new
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 Down