Skip to content

Commit

Permalink
Merge pull request #451 from juhp/exe-hardlinks
Browse files Browse the repository at this point in the history
install: create hls hardlinks instead of copies except on Windows
  • Loading branch information
jneira authored Oct 2, 2020
2 parents d4d50a6 + 9d3188e commit 623da0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
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

0 comments on commit 623da0a

Please sign in to comment.