Compare commits
54 Commits
ghcup-run-
...
stack-hook
| Author | SHA1 | Date | |
|---|---|---|---|
|
e9575aba5c
|
|||
|
81c7f6a32a
|
|||
|
|
ab97c80b80 | ||
|
|
04369673ef | ||
|
|
63dfdc2da6 | ||
|
14de382129
|
|||
|
d97c10dbe6
|
|||
|
|
8420bf093e | ||
|
|
5e28074522 | ||
|
c842c41a78
|
|||
|
8b93eaad59
|
|||
|
2cba97cf1c
|
|||
|
7d74178295
|
|||
|
c37bef55e9
|
|||
|
837ba8b46a
|
|||
|
|
c25e73408a | ||
|
|
71c3172cf5 | ||
|
|
1f2855a107 | ||
|
|
d949c4375e | ||
|
|
22f0081303 | ||
|
5562be18e3
|
|||
|
6baa891424
|
|||
|
a544feffb3
|
|||
|
3b6bb0df46
|
|||
|
60299b6bb8
|
|||
|
4d20f4e07c
|
|||
|
5f6b5f845d
|
|||
|
b0fecce0d1
|
|||
|
|
27c06ddde7 | ||
|
3154d2839b
|
|||
|
|
511d8d5ed8 | ||
|
fe22405ee1
|
|||
|
ea828cd13a
|
|||
|
00fa70b9de
|
|||
|
823275363c
|
|||
|
2f299ee48d
|
|||
|
284fe1b3b6
|
|||
|
35bda8d67a
|
|||
|
9673d28d3e
|
|||
|
99a51d67a1
|
|||
|
|
ca5c5550ab | ||
|
|
3d49f79beb | ||
|
|
e9740d13fc | ||
|
|
2bd5a8fe1a | ||
|
|
0acccae523 | ||
|
974112016e
|
|||
|
9fb2889696
|
|||
|
63f22b28d7
|
|||
|
|
9ceb66ef21 | ||
|
|
7cbe38b011 | ||
|
|
3bbc1edb19 | ||
|
|
b8dac2d7cd | ||
|
|
0e1fd68d93 | ||
|
|
c7eceb2330 |
31
CHANGELOG.md
31
CHANGELOG.md
@@ -1,5 +1,36 @@
|
|||||||
# Revision history for ghcup
|
# Revision history for ghcup
|
||||||
|
|
||||||
|
## 0.1.18.1 -- 2022-08-06
|
||||||
|
|
||||||
|
* fix sdist and unbreak hackage, wrt [#399](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/399)
|
||||||
|
|
||||||
|
## 0.1.18.0 -- 2022-07-30
|
||||||
|
|
||||||
|
* Fix tui set wrt [#266](https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/266) by Arjun Kathuria
|
||||||
|
- Ask the user to install the tool via prompt when setting an non-installed version
|
||||||
|
* improvements to safe (un-)installations
|
||||||
|
- bindists that don't support `make DESTDIR=/some/tmp/dir install` are now unsupported
|
||||||
|
- installed GHC files are now recorded to avoid use of `removePathForcibly`
|
||||||
|
- internally uses a newtype wrapper for user-input paths and restrict destructive operations to validated paths
|
||||||
|
* Add `--disable-ld-override` for darwin bindists wrt #391
|
||||||
|
* Allow passing bindist configure args wrt #377
|
||||||
|
* use of `TMPDIR` is dropped... now uses an internal tmp dir `~/.ghcup/tmp`
|
||||||
|
* improvements to error handling and warnings
|
||||||
|
* Require --isolate to have an absolute directory, fixes #367
|
||||||
|
* Fix mingw PATH handling wrt #371
|
||||||
|
* Add --mingw-path switch to `ghcup run`
|
||||||
|
* Fix `ghcup run` on windows, fixes #375
|
||||||
|
* Improve `ghcup compile <hls|ghc>`
|
||||||
|
- short hashes now work
|
||||||
|
- print the long hash in addition to the detected version
|
||||||
|
* Improve `ghcup compile hls`
|
||||||
|
- add `--git-describe-version` switch as an alternative to `--overwrite-version`
|
||||||
|
- Allow to build HLS from hackage (now is the default)
|
||||||
|
- Allow to run 'cabal update' automatically before the HLS build
|
||||||
|
- Fix parser and completer for 'ghcup compile hls --version'
|
||||||
|
* Improve `ghcup compile ghc`
|
||||||
|
- Allow to build from arbitrary GHC source dists
|
||||||
|
|
||||||
## 0.1.17.10 -- 2022-05-12
|
## 0.1.17.10 -- 2022-05-12
|
||||||
|
|
||||||
* windows hotfix (hackage-only release)
|
* windows hotfix (hackage-only release)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import GHCup.Prelude ( decUTF8Safe )
|
|||||||
import GHCup.Prelude.File
|
import GHCup.Prelude.File
|
||||||
import GHCup.Prelude.Logger
|
import GHCup.Prelude.Logger
|
||||||
import GHCup.Prelude.Process
|
import GHCup.Prelude.Process
|
||||||
|
import GHCup.Prompts
|
||||||
|
|
||||||
import Brick
|
import Brick
|
||||||
import Brick.Widgets.Border
|
import Brick.Widgets.Border
|
||||||
@@ -52,6 +53,8 @@ import Text.PrettyPrint.HughesPJClass ( prettyShow )
|
|||||||
import URI.ByteString
|
import URI.ByteString
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import qualified Data.Text.Lazy.Builder as B
|
||||||
|
import qualified Data.Text.Lazy as L
|
||||||
import qualified Graphics.Vty as Vty
|
import qualified Graphics.Vty as Vty
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import System.Environment (getExecutablePath)
|
import System.Environment (getExecutablePath)
|
||||||
@@ -98,7 +101,7 @@ keyHandlers KeyBindings {..} =
|
|||||||
[ (bQuit, const "Quit" , halt)
|
[ (bQuit, const "Quit" , halt)
|
||||||
, (bInstall, const "Install" , withIOAction install')
|
, (bInstall, const "Install" , withIOAction install')
|
||||||
, (bUninstall, const "Uninstall", withIOAction del')
|
, (bUninstall, const "Uninstall", withIOAction del')
|
||||||
, (bSet, const "Set" , withIOAction ((liftIO .) . set'))
|
, (bSet, const "Set" , withIOAction set')
|
||||||
, (bChangelog, const "ChangeLog", withIOAction changelog')
|
, (bChangelog, const "ChangeLog", withIOAction changelog')
|
||||||
, ( bShowAllVersions
|
, ( bShowAllVersions
|
||||||
, \BrickSettings {..} ->
|
, \BrickSettings {..} ->
|
||||||
@@ -486,9 +489,12 @@ install' _ (_, ListResult {..}) = do
|
|||||||
<> "Also check the logs in ~/.ghcup/logs"
|
<> "Also check the logs in ~/.ghcup/logs"
|
||||||
|
|
||||||
|
|
||||||
set' :: BrickState -> (Int, ListResult) -> IO (Either String ())
|
set' :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadFail m, MonadMask m, MonadUnliftIO m)
|
||||||
set' _ (_, ListResult {..}) = do
|
=> BrickState
|
||||||
settings <- readIORef settings'
|
-> (Int, ListResult)
|
||||||
|
-> m (Either String ())
|
||||||
|
set' bs input@(_, ListResult {..}) = do
|
||||||
|
settings <- liftIO $ readIORef settings'
|
||||||
|
|
||||||
let run =
|
let run =
|
||||||
flip runReaderT settings
|
flip runReaderT settings
|
||||||
@@ -504,7 +510,28 @@ set' _ (_, ListResult {..}) = do
|
|||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
VRight _ -> pure $ Right ()
|
VRight _ -> pure $ Right ()
|
||||||
VLeft e -> pure $ Left (prettyShow e)
|
VLeft e -> case e of
|
||||||
|
(V (NotInstalled tool _)) -> do
|
||||||
|
promptAnswer <- getUserPromptResponse userPrompt
|
||||||
|
case promptAnswer of
|
||||||
|
PromptYes -> do
|
||||||
|
res <- install' bs input
|
||||||
|
case res of
|
||||||
|
(Left err) -> pure $ Left err
|
||||||
|
(Right _) -> do
|
||||||
|
logInfo "Setting now..."
|
||||||
|
set' bs input
|
||||||
|
|
||||||
|
PromptNo -> pure $ Left (prettyShow e)
|
||||||
|
where
|
||||||
|
userPrompt = L.toStrict . B.toLazyText . B.fromString $
|
||||||
|
"This Version of "
|
||||||
|
<> show tool
|
||||||
|
<> " you are trying to set is not installed.\n"
|
||||||
|
<> "Would you like to install it first? [Y/N]: "
|
||||||
|
|
||||||
|
_ -> pure $ Left (prettyShow e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
del' :: (MonadReader AppState m, MonadIO m, MonadFail m, MonadMask m, MonadUnliftIO m)
|
del' :: (MonadReader AppState m, MonadIO m, MonadFail m, MonadMask m, MonadUnliftIO m)
|
||||||
|
|||||||
@@ -452,9 +452,11 @@ tagCompleter tool add = listIOCompleter $ do
|
|||||||
pure $ nub $ (add ++) $ fmap tagToString allTags
|
pure $ nub $ (add ++) $ fmap tagToString allTags
|
||||||
VLeft _ -> pure (nub $ ["recommended", "latest"] ++ add)
|
VLeft _ -> pure (nub $ ["recommended", "latest"] ++ add)
|
||||||
|
|
||||||
|
|
||||||
versionCompleter :: Maybe ListCriteria -> Tool -> Completer
|
versionCompleter :: Maybe ListCriteria -> Tool -> Completer
|
||||||
versionCompleter criteria tool = listIOCompleter $ do
|
versionCompleter criteria tool = versionCompleter' criteria tool (const True)
|
||||||
|
|
||||||
|
versionCompleter' :: Maybe ListCriteria -> Tool -> (Version -> Bool) -> Completer
|
||||||
|
versionCompleter' criteria tool filter' = listIOCompleter $ do
|
||||||
dirs' <- liftIO getAllDirs
|
dirs' <- liftIO getAllDirs
|
||||||
let loggerConfig = LoggerConfig
|
let loggerConfig = LoggerConfig
|
||||||
{ lcPrintDebug = False
|
{ lcPrintDebug = False
|
||||||
@@ -483,7 +485,7 @@ versionCompleter criteria tool = listIOCompleter $ do
|
|||||||
runEnv = flip runReaderT appState
|
runEnv = flip runReaderT appState
|
||||||
|
|
||||||
installedVersions <- runEnv $ listVersions (Just tool) criteria
|
installedVersions <- runEnv $ listVersions (Just tool) criteria
|
||||||
return $ T.unpack . prettyVer . lVer <$> installedVersions
|
return $ fmap (T.unpack . prettyVer) . filter filter' . fmap lVer $ installedVersions
|
||||||
|
|
||||||
|
|
||||||
toolDlCompleter :: Tool -> Completer
|
toolDlCompleter :: Tool -> Completer
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ module GHCup.OptParse.Compile where
|
|||||||
|
|
||||||
|
|
||||||
import GHCup
|
import GHCup
|
||||||
|
import qualified GHCup.GHC as GHC
|
||||||
|
import qualified GHCup.HLS as HLS
|
||||||
import GHCup.Errors
|
import GHCup.Errors
|
||||||
import GHCup.Types
|
import GHCup.Types
|
||||||
import GHCup.Types.Optics
|
import GHCup.Types.Optics
|
||||||
@@ -30,7 +32,8 @@ import Control.Monad.Trans.Resource
|
|||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
import Data.Functor
|
import Data.Functor
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Versions ( Version, prettyVer, version )
|
import Data.Versions ( Version, prettyVer, version, pvp )
|
||||||
|
import qualified Data.Versions as V
|
||||||
import Data.Text ( Text )
|
import Data.Text ( Text )
|
||||||
import Haskus.Utils.Variant.Excepts
|
import Haskus.Utils.Variant.Excepts
|
||||||
import Options.Applicative hiding ( style )
|
import Options.Applicative hiding ( style )
|
||||||
@@ -41,7 +44,7 @@ import Text.PrettyPrint.HughesPJClass ( prettyShow )
|
|||||||
|
|
||||||
import URI.ByteString hiding ( uriParser )
|
import URI.ByteString hiding ( uriParser )
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Control.Exception.Safe (MonadMask)
|
import Control.Exception.Safe (MonadMask, displayException)
|
||||||
import System.FilePath (isPathSeparator)
|
import System.FilePath (isPathSeparator)
|
||||||
import Text.Read (readEither)
|
import Text.Read (readEither)
|
||||||
|
|
||||||
@@ -64,7 +67,7 @@ data CompileCommand = CompileGHC GHCCompileOptions
|
|||||||
|
|
||||||
|
|
||||||
data GHCCompileOptions = GHCCompileOptions
|
data GHCCompileOptions = GHCCompileOptions
|
||||||
{ targetGhc :: Either Version GitBranch
|
{ targetGhc :: GHC.GHCVer Version
|
||||||
, bootstrapGhc :: Either Version FilePath
|
, bootstrapGhc :: Either Version FilePath
|
||||||
, jobs :: Maybe Int
|
, jobs :: Maybe Int
|
||||||
, buildConfig :: Maybe FilePath
|
, buildConfig :: Maybe FilePath
|
||||||
@@ -78,10 +81,12 @@ data GHCCompileOptions = GHCCompileOptions
|
|||||||
, isolateDir :: Maybe FilePath
|
, isolateDir :: Maybe FilePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data HLSCompileOptions = HLSCompileOptions
|
data HLSCompileOptions = HLSCompileOptions
|
||||||
{ targetHLS :: Either Version GitBranch
|
{ targetHLS :: HLS.HLSVer
|
||||||
, jobs :: Maybe Int
|
, jobs :: Maybe Int
|
||||||
, setCompile :: Bool
|
, setCompile :: Bool
|
||||||
|
, updateCabal :: Bool
|
||||||
, ovewrwiteVer :: Either Bool Version
|
, ovewrwiteVer :: Either Bool Version
|
||||||
, isolateDir :: Maybe FilePath
|
, isolateDir :: Maybe FilePath
|
||||||
, cabalProject :: Maybe (Either FilePath URI)
|
, cabalProject :: Maybe (Either FilePath URI)
|
||||||
@@ -149,10 +154,10 @@ Examples:
|
|||||||
These need to be available in PATH prior to compilation.
|
These need to be available in PATH prior to compilation.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
# compile 1.7.0.0 for ghc 8.10.5 and 8.10.7, passing '--allow-newer' to cabal
|
# compile 1.7.0.0 from hackage for 8.10.7, running 'cabal update' before the build
|
||||||
ghcup compile hls -v 1.7.0.0 -j 12 --ghc 8.10.5 --ghc 8.10.7 -- --allow-newer
|
ghcup compile hls --version 1.7.0.0 --ghc 8.10.7 --cabal-update
|
||||||
# compile from master for ghc 9.2.3 and use 'git describe' to name the binary
|
# compile from master for ghc 9.2.3 using 'git describe' to name the binary and ignore the pinned index state
|
||||||
ghcup compile hls -g master --git-describe-version --ghc 9.2.3
|
ghcup compile hls -g master --git-describe-version --ghc 9.2.3 -- --index-state=@(date '+%s')
|
||||||
# compile a specific commit for ghc 9.2.3 and set a specifc version for the binary name
|
# compile a specific commit for ghc 9.2.3 and set a specifc version for the binary name
|
||||||
ghcup compile hls -g a32db0b -o 1.7.0.0-p1 --ghc 9.2.3|]
|
ghcup compile hls -g a32db0b -o 1.7.0.0-p1 --ghc 9.2.3|]
|
||||||
|
|
||||||
@@ -160,7 +165,7 @@ Examples:
|
|||||||
ghcCompileOpts :: Parser GHCCompileOptions
|
ghcCompileOpts :: Parser GHCCompileOptions
|
||||||
ghcCompileOpts =
|
ghcCompileOpts =
|
||||||
GHCCompileOptions
|
GHCCompileOptions
|
||||||
<$> ((Left <$> option
|
<$> ((GHC.SourceDist <$> option
|
||||||
(eitherReader
|
(eitherReader
|
||||||
(first (const "Not a valid version") . version . T.pack)
|
(first (const "Not a valid version") . version . T.pack)
|
||||||
)
|
)
|
||||||
@@ -169,7 +174,7 @@ ghcCompileOpts =
|
|||||||
<> (completer $ versionCompleter Nothing GHC)
|
<> (completer $ versionCompleter Nothing GHC)
|
||||||
)
|
)
|
||||||
) <|>
|
) <|>
|
||||||
(Right <$> (GitBranch <$> option
|
(GHC.GitDist <$> (GitBranch <$> option
|
||||||
str
|
str
|
||||||
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
||||||
"The git commit/branch/ref to build from"
|
"The git commit/branch/ref to build from"
|
||||||
@@ -178,7 +183,18 @@ ghcCompileOpts =
|
|||||||
short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)"
|
short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)"
|
||||||
<> completer (gitFileUri ["https://gitlab.haskell.org/ghc/ghc.git"])
|
<> completer (gitFileUri ["https://gitlab.haskell.org/ghc/ghc.git"])
|
||||||
))
|
))
|
||||||
)))
|
))
|
||||||
|
<|>
|
||||||
|
(
|
||||||
|
GHC.RemoteDist <$> (option
|
||||||
|
(eitherReader uriParser)
|
||||||
|
(long "remote-source-dist" <> metavar "URI" <> help
|
||||||
|
"URI (https/http/file) to a GHC source distribution"
|
||||||
|
<> completer fileUri
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
<*> option
|
<*> option
|
||||||
(eitherReader
|
(eitherReader
|
||||||
(\x ->
|
(\x ->
|
||||||
@@ -270,16 +286,17 @@ ghcCompileOpts =
|
|||||||
hlsCompileOpts :: Parser HLSCompileOptions
|
hlsCompileOpts :: Parser HLSCompileOptions
|
||||||
hlsCompileOpts =
|
hlsCompileOpts =
|
||||||
HLSCompileOptions
|
HLSCompileOptions
|
||||||
<$> ((Left <$> option
|
<$> ((HLS.HackageDist <$> option
|
||||||
(eitherReader
|
(eitherReader
|
||||||
(first (const "Not a valid version") . version . T.pack)
|
((>>= first displayException . V.version . V.prettyPVP) . first (const "Not a valid PVP version") . pvp . T.pack)
|
||||||
)
|
)
|
||||||
(short 'v' <> long "version" <> metavar "VERSION" <> help
|
(short 'v' <> long "version" <> metavar "VERSION" <> help
|
||||||
"The tool version to compile"
|
"The version to compile (pulled from hackage)"
|
||||||
<> (completer $ versionCompleter Nothing HLS)
|
<> (completer $ versionCompleter' Nothing HLS (either (const False) (const True) . V.pvp . V.prettyVer))
|
||||||
)
|
)
|
||||||
) <|>
|
)
|
||||||
(Right <$> (GitBranch <$> option
|
<|>
|
||||||
|
(HLS.GitDist <$> (GitBranch <$> option
|
||||||
str
|
str
|
||||||
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
||||||
"The git commit/branch/ref to build from (accepts anything 'git checkout' accepts)"
|
"The git commit/branch/ref to build from (accepts anything 'git checkout' accepts)"
|
||||||
@@ -287,7 +304,28 @@ hlsCompileOpts =
|
|||||||
optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to HLS upstream)"
|
optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to HLS upstream)"
|
||||||
<> completer (gitFileUri ["https://github.com/haskell/haskell-language-server.git"])
|
<> completer (gitFileUri ["https://github.com/haskell/haskell-language-server.git"])
|
||||||
))
|
))
|
||||||
)))
|
))
|
||||||
|
<|>
|
||||||
|
(HLS.SourceDist <$> (option
|
||||||
|
(eitherReader
|
||||||
|
(first (const "Not a valid version") . version . T.pack)
|
||||||
|
)
|
||||||
|
(long "source-dist" <> metavar "VERSION" <> help
|
||||||
|
"The version to compile (pulled from packaged git sources)"
|
||||||
|
<> (completer $ versionCompleter Nothing HLS)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
<|>
|
||||||
|
(
|
||||||
|
HLS.RemoteDist <$> (option
|
||||||
|
(eitherReader uriParser)
|
||||||
|
(long "remote-source-dist" <> metavar "URI" <> help
|
||||||
|
"URI (https/http/file) to a HLS source distribution"
|
||||||
|
<> completer fileUri
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
<*> optional
|
<*> optional
|
||||||
(option
|
(option
|
||||||
(eitherReader (readEither @Int))
|
(eitherReader (readEither @Int))
|
||||||
@@ -297,6 +335,7 @@ hlsCompileOpts =
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
<*> fmap (fromMaybe True) (invertableSwitch "set" Nothing True (help "Don't set as active version after install"))
|
<*> fmap (fromMaybe True) (invertableSwitch "set" Nothing True (help "Don't set as active version after install"))
|
||||||
|
<*> switch (long "cabal-update" <> help "Run 'cabal update' before the build")
|
||||||
<*>
|
<*>
|
||||||
(
|
(
|
||||||
(Right <$> option
|
(Right <$> option
|
||||||
@@ -468,7 +507,7 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do
|
|||||||
(CompileHLS HLSCompileOptions { .. }) -> do
|
(CompileHLS HLSCompileOptions { .. }) -> do
|
||||||
runCompileHLS runAppState (do
|
runCompileHLS runAppState (do
|
||||||
case targetHLS of
|
case targetHLS of
|
||||||
Left targetVer -> do
|
HLS.SourceDist targetVer -> do
|
||||||
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
||||||
let vi = getVersionInfo targetVer HLS dls
|
let vi = getVersionInfo targetVer HLS dls
|
||||||
forM_ (_viPreCompile =<< vi) $ \msg -> do
|
forM_ (_viPreCompile =<< vi) $ \msg -> do
|
||||||
@@ -476,7 +515,7 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do
|
|||||||
lift $ logInfo
|
lift $ logInfo
|
||||||
"...waiting for 5 seconds, you can still abort..."
|
"...waiting for 5 seconds, you can still abort..."
|
||||||
liftIO $ threadDelay 5000000 -- for compilation, give the user a sec to intervene
|
liftIO $ threadDelay 5000000 -- for compilation, give the user a sec to intervene
|
||||||
Right _ -> pure ()
|
_ -> pure ()
|
||||||
ghcs <- liftE $ forM targetGHCs (\ghc -> fmap (_tvVersion . fst) . fromVersion (Just ghc) $ GHC)
|
ghcs <- liftE $ forM targetGHCs (\ghc -> fmap (_tvVersion . fst) . fromVersion (Just ghc) $ GHC)
|
||||||
targetVer <- liftE $ compileHLS
|
targetVer <- liftE $ compileHLS
|
||||||
targetHLS
|
targetHLS
|
||||||
@@ -486,6 +525,7 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do
|
|||||||
(maybe GHCupInternal IsolateDir isolateDir)
|
(maybe GHCupInternal IsolateDir isolateDir)
|
||||||
cabalProject
|
cabalProject
|
||||||
cabalProjectLocal
|
cabalProjectLocal
|
||||||
|
updateCabal
|
||||||
patches
|
patches
|
||||||
cabalArgs
|
cabalArgs
|
||||||
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
||||||
@@ -519,7 +559,7 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do
|
|||||||
(CompileGHC GHCCompileOptions {..}) ->
|
(CompileGHC GHCCompileOptions {..}) ->
|
||||||
runCompileGHC runAppState (do
|
runCompileGHC runAppState (do
|
||||||
case targetGhc of
|
case targetGhc of
|
||||||
Left targetVer -> do
|
GHC.SourceDist targetVer -> do
|
||||||
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
||||||
let vi = getVersionInfo targetVer GHC dls
|
let vi = getVersionInfo targetVer GHC dls
|
||||||
forM_ (_viPreCompile =<< vi) $ \msg -> do
|
forM_ (_viPreCompile =<< vi) $ \msg -> do
|
||||||
@@ -527,9 +567,12 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do
|
|||||||
lift $ logInfo
|
lift $ logInfo
|
||||||
"...waiting for 5 seconds, you can still abort..."
|
"...waiting for 5 seconds, you can still abort..."
|
||||||
liftIO $ threadDelay 5000000 -- for compilation, give the user a sec to intervene
|
liftIO $ threadDelay 5000000 -- for compilation, give the user a sec to intervene
|
||||||
Right _ -> pure ()
|
_ -> pure ()
|
||||||
targetVer <- liftE $ compileGHC
|
targetVer <- liftE $ compileGHC
|
||||||
(first (GHCTargetVersion crossTarget) targetGhc)
|
((\case
|
||||||
|
GHC.SourceDist v -> GHC.SourceDist $ GHCTargetVersion crossTarget v
|
||||||
|
GHC.GitDist g -> GHC.GitDist g
|
||||||
|
GHC.RemoteDist r -> GHC.RemoteDist r) targetGhc)
|
||||||
ovewrwiteVer
|
ovewrwiteVer
|
||||||
bootstrapGhc
|
bootstrapGhc
|
||||||
jobs
|
jobs
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ Examples:
|
|||||||
ghcup install ghc 8.10.2
|
ghcup install ghc 8.10.2
|
||||||
|
|
||||||
# install GHC head fedora bindist
|
# install GHC head fedora bindist
|
||||||
ghcup install ghc -u https://gitlab.haskell.org/api/v4/projects/1/jobs/artifacts/master/raw/ghc-x86_64-fedora27-linux.tar.xz?job=validate-x86_64-linux-fedora27 head|]
|
ghcup install ghc -u 'https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz?job=x86_64-linux-fedora33-release' head|]
|
||||||
|
|
||||||
|
|
||||||
installOpts :: Maybe Tool -> Parser InstallOptions
|
installOpts :: Maybe Tool -> Parser InstallOptions
|
||||||
@@ -546,4 +546,3 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
logError $ T.pack $ prettyShow e
|
logError $ T.pack $ prettyShow e
|
||||||
logError $ "Also check the logs in " <> T.pack (fromGHCupPath logsDir)
|
logError $ "Also check the logs in " <> T.pack (fromGHCupPath logsDir)
|
||||||
pure $ ExitFailure 4
|
pure $ ExitFailure 4
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ module Main where
|
|||||||
import BrickMain ( brickMain )
|
import BrickMain ( brickMain )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
import qualified GHCup.GHC as GHC
|
||||||
|
import qualified GHCup.HLS as HLS
|
||||||
import GHCup.OptParse
|
import GHCup.OptParse
|
||||||
|
|
||||||
import GHCup.Download
|
import GHCup.Download
|
||||||
@@ -338,11 +340,13 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
alreadyInstalling (Install (Left (InstallStack InstallOptions{..}))) (Stack, ver) = cmp' Stack instVer ver
|
alreadyInstalling (Install (Left (InstallStack InstallOptions{..}))) (Stack, ver) = cmp' Stack instVer ver
|
||||||
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ ovewrwiteVer = Just over }))
|
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ ovewrwiteVer = Just over }))
|
||||||
(GHC, ver) = cmp' GHC (Just $ GHCVersion (mkTVer over)) ver
|
(GHC, ver) = cmp' GHC (Just $ GHCVersion (mkTVer over)) ver
|
||||||
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ targetGhc = Left tver }))
|
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ targetGhc = GHC.SourceDist tver }))
|
||||||
(GHC, ver) = cmp' GHC (Just $ ToolVersion tver) ver
|
(GHC, ver) = cmp' GHC (Just $ ToolVersion tver) ver
|
||||||
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ ovewrwiteVer = Right over }))
|
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ ovewrwiteVer = Right over }))
|
||||||
(HLS, ver) = cmp' HLS (Just $ ToolVersion over) ver
|
(HLS, ver) = cmp' HLS (Just $ ToolVersion over) ver
|
||||||
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ targetHLS = Left tver }))
|
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ targetHLS = HLS.SourceDist tver }))
|
||||||
|
(HLS, ver) = cmp' HLS (Just $ ToolVersion tver) ver
|
||||||
|
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ targetHLS = HLS.HackageDist tver }))
|
||||||
(HLS, ver) = cmp' HLS (Just $ ToolVersion tver) ver
|
(HLS, ver) = cmp' HLS (Just $ ToolVersion tver) ver
|
||||||
alreadyInstalling (Upgrade {}) (GHCup, _) = pure True
|
alreadyInstalling (Upgrade {}) (GHCup, _) = pure True
|
||||||
alreadyInstalling _ _ = pure False
|
alreadyInstalling _ _ = pure False
|
||||||
|
|||||||
Submodule data/metadata updated: 7d8f7eaf66...42f43a6b2d
126
docs/guide.md
126
docs/guide.md
@@ -4,7 +4,7 @@ This is a more in-depth guide specific to GHCup. `ghcup --help` is your friend.
|
|||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
For the simple interactive TUI (not available on windows), run:
|
For the simple, interactive, text-based user interface (TUI) (not available on windows), run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
ghcup tui
|
ghcup tui
|
||||||
@@ -186,6 +186,51 @@ url-source:
|
|||||||
|
|
||||||
# More on installation
|
# More on installation
|
||||||
|
|
||||||
|
## Customisation of the installation scripts
|
||||||
|
|
||||||
|
The scripts offered to install GHCup are available here:
|
||||||
|
|
||||||
|
* [bootstrap-haskell](https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell#L7)
|
||||||
|
for Unix-like operating systems
|
||||||
|
* [bootstrap-haskell.ps1](https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell.ps1#L17)
|
||||||
|
for Windows (PowerShell). This will, in turn, run the final bootstrap script
|
||||||
|
(by default, that for the Unix-like operating systems).
|
||||||
|
|
||||||
|
The effect of the scripts can be customised by setting one or more
|
||||||
|
`BOOTSTRAP_HASKELL_*` environment variables (as set out in the first script)
|
||||||
|
and, in the case of Windows, by specifying parameters (as set out in the
|
||||||
|
PowerShell script).
|
||||||
|
|
||||||
|
For example, you can toggle:
|
||||||
|
|
||||||
|
* non-interactive installation
|
||||||
|
* a more verbose installation
|
||||||
|
* whether to install only GHCup (and, on Windows, MSYS2)
|
||||||
|
* not to trigger the upgrade of GHCup
|
||||||
|
* whether to install the latest version of HLS
|
||||||
|
* whether to install the latest version of Stack
|
||||||
|
* whether to respect the XDG Base Directory Specification
|
||||||
|
* whether to adjust (prepend) the PATH in `bashrc`
|
||||||
|
* on Windows, whether to adjust MINGW paths in `cabal.config`
|
||||||
|
|
||||||
|
You can also specify:
|
||||||
|
|
||||||
|
* the GHC version to install
|
||||||
|
* the Cabal version to install
|
||||||
|
* which downloader to use (the default is `curl`)
|
||||||
|
* the base URL for the download of the GHCup binary distribution
|
||||||
|
|
||||||
|
On Windows, you can also use the parameters to:
|
||||||
|
|
||||||
|
* toggle whether to overwrite a previous installation
|
||||||
|
* specify the GHCup installation root directory
|
||||||
|
* specify the Cabal root directory
|
||||||
|
* specify the directory of an existing installation of MSYS2 (for example,
|
||||||
|
the one supplied by Stack)
|
||||||
|
* specify the URL of the final bootstrap script
|
||||||
|
* toggle whether to run the final bootstrap script via `bash` (instead of in a
|
||||||
|
new MSYS2 shell)
|
||||||
|
|
||||||
## Installing custom bindists
|
## Installing custom bindists
|
||||||
|
|
||||||
There are a couple of good use cases to install custom bindists:
|
There are a couple of good use cases to install custom bindists:
|
||||||
@@ -193,7 +238,8 @@ There are a couple of good use cases to install custom bindists:
|
|||||||
1. manually built bindists (e.g. with patches)
|
1. manually built bindists (e.g. with patches)
|
||||||
- example: `ghcup install ghc -u 'file:///home/mearwald/tmp/ghc-eff-patches/ghc-8.10.2-x86_64-deb10-linux.tar.xz' 8.10.2-eff`
|
- example: `ghcup install ghc -u 'file:///home/mearwald/tmp/ghc-eff-patches/ghc-8.10.2-x86_64-deb10-linux.tar.xz' 8.10.2-eff`
|
||||||
2. GHC head CI bindists
|
2. GHC head CI bindists
|
||||||
- example: `ghcup install ghc -u 'https://gitlab.haskell.org/api/v4/projects/1/jobs/artifacts/master/raw/ghc-x86_64-fedora27-linux.tar.xz?job=validate-x86_64-linux-fedora27' head`
|
- example specifying a branch (`master`): `ghcup install ghc -u 'https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz?job=x86_64-linux-fedora33-release' head`
|
||||||
|
- example specifying a job id (`1129565`): `ghcup install ghc -u ' https://gitlab.haskell.org/api/v4/projects/1/jobs/1129565/artifacts/ghc-x86_64-linux-alpine3_12-validate+fully_static.tar.xz' mr7847`
|
||||||
3. DWARF bindists
|
3. DWARF bindists
|
||||||
- example: `ghcup install ghc -u 'https://downloads.haskell.org/~ghc/8.10.2/ghc-8.10.2-x86_64-deb10-linux-dwarf.tar.xz' 8.10.2-dwarf`
|
- example: `ghcup install ghc -u 'https://downloads.haskell.org/~ghc/8.10.2/ghc-8.10.2-x86_64-deb10-linux-dwarf.tar.xz' 8.10.2-dwarf`
|
||||||
|
|
||||||
@@ -202,7 +248,9 @@ and produce the binaries `ghc-8.10.2-eff` and `ghc-head` respectively.
|
|||||||
GHCup always needs to know which version the bindist corresponds to (this is not automatically
|
GHCup always needs to know which version the bindist corresponds to (this is not automatically
|
||||||
detected).
|
detected).
|
||||||
|
|
||||||
## Compiling GHC from source
|
## Compiling from source
|
||||||
|
|
||||||
|
### GHC
|
||||||
|
|
||||||
Compiling from source is supported for both source tarballs and arbitrary git refs. See `ghcup compile ghc --help`
|
Compiling from source is supported for both source tarballs and arbitrary git refs. See `ghcup compile ghc --help`
|
||||||
for a list of all available options.
|
for a list of all available options.
|
||||||
@@ -214,6 +262,64 @@ Common `build.mk` options are explained [here](https://gitlab.haskell.org/ghc/gh
|
|||||||
|
|
||||||
Make sure your system meets all the [prerequisites](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation).
|
Make sure your system meets all the [prerequisites](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation).
|
||||||
|
|
||||||
|
### HLS
|
||||||
|
|
||||||
|
There are 3 main ways to compile HLS from source.
|
||||||
|
|
||||||
|
1. from hackage (should have up to date version bounds)
|
||||||
|
- `ghcup compile hls --version 1.7.0.0 --ghc 9.2.3`
|
||||||
|
2. from git (allows to build latest sources and PRs)
|
||||||
|
- `ghcup compile hls --git-ref master --ghc 9.2.3`
|
||||||
|
- `ghcup compile hls --git-ref a32db0b --ghc 9.2.3`
|
||||||
|
- `ghcup compile hls --git-ref 1.7.0.0 --ghc 9.2.3`
|
||||||
|
3. from source distribution that's packaged during release from the corresponding git sources
|
||||||
|
- `ghcup compile hls --source-dist 1.7.0.0 --ghc 9.2.3`
|
||||||
|
|
||||||
|
All these use `cabal v2-install` under the hood, so all build components are cached.
|
||||||
|
You can pass arbitrary arguments to cabal, e.g. set the index state like so:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ghcup compile hls --git-ref master --ghc 9.2.3 -- --index-state=2022-06-12T00:00:00Z --allow-newer
|
||||||
|
```
|
||||||
|
|
||||||
|
You can pass `--ghc <ver>` multiple times to install for many GHCs at once.
|
||||||
|
|
||||||
|
When building from git sources, ghcup will auto-detect the HLS version that the git commit corresponds to
|
||||||
|
from the `haskell-language-server.cabal` file. This version might not have been updated since the last release.
|
||||||
|
If you want to avoid overwriting the existing installed HLS version, you can instruct ghcup to use `git describe`
|
||||||
|
to set the HLS version instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ghcup compile hls --git-ref master --ghc 9.2.3 --git-describe-version
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also set the version explicitly:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ghcup compile hls --git-ref master --ghc 9.2.3 --overwrite-version 1.7.0.0-p1
|
||||||
|
```
|
||||||
|
|
||||||
|
To instruct cabal to run `cabal update` before building, run `ghcup compile hls --version 1.7.0.0 --ghc 9.2.3 --cabal-update`
|
||||||
|
|
||||||
|
As always, check `ghcup compile hls --help`.
|
||||||
|
|
||||||
|
#### Updating HLS for a new GHC version
|
||||||
|
|
||||||
|
First try to build from hackage with some tricks:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ghcup compile hls --version 1.7.0.0 --ghc 9.2.4 --cabal-update -- --allow-newer --index-state=2022-06-12T00:00:00Z
|
||||||
|
```
|
||||||
|
|
||||||
|
This augments the currently installed 1.7.0.0 official bindists in ghcup with new GHC versions support.
|
||||||
|
|
||||||
|
If that fails (since `--allow-newer` is quite brutal), you can install from HLS master branch (which may contain new fixes) like so:
|
||||||
|
```
|
||||||
|
ghcup compile hls --git-ref master --git-describe-version --ghc 8.10.7 --ghc 9.2.4 --cabal-update
|
||||||
|
```
|
||||||
|
|
||||||
|
This however will create a new HLS version in ghcup, e.g. `1.7.0.0-105-gdc682ba1`, for both 8.10.7 and 9.2.4. If you want to switch back to the official bindists, run `ghcup set hls 1.7.0.0`.
|
||||||
|
|
||||||
### Cross support
|
### Cross support
|
||||||
|
|
||||||
ghcup can compile and install a cross GHC for any target. However, this
|
ghcup can compile and install a cross GHC for any target. However, this
|
||||||
@@ -248,7 +354,7 @@ Examples:
|
|||||||
- `ghcup install cabal --isolate /home/username/my_isolated_dir/`
|
- `ghcup install cabal --isolate /home/username/my_isolated_dir/`
|
||||||
|
|
||||||
3. do an isolated install with a custom bindist
|
3. do an isolated install with a custom bindist
|
||||||
- `ghcup install ghc --isolate /home/username/my_isolated_dir/ -u 'https://gitlab.haskell.org/api/v4/projects/1/jobs/artifacts/master/raw/ghc-x86_64-fedora27-linux.tar.xz?job=validate-x86_64-linux-fedora27' head`
|
- `ghcup install ghc --isolate /home/username/my_isolated_dir/ -u 'https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz?job=x86_64-linux-fedora33-release' head`
|
||||||
|
|
||||||
4. isolated install HLS
|
4. isolated install HLS
|
||||||
- `ghcup install hls --isolate /home/username/dir/hls/`
|
- `ghcup install hls --isolate /home/username/dir/hls/`
|
||||||
@@ -258,7 +364,9 @@ Examples:
|
|||||||
|
|
||||||
## Continuous integration
|
## Continuous integration
|
||||||
|
|
||||||
On windows, ghcup can be installed automatically on a CI runner non-interactively like so:
|
On Windows, GHCup can be installed automatically on a CI runner
|
||||||
|
non-interactively, as below. The paramaters to the PowerShell script are
|
||||||
|
specified positionally, after `-ArgumentList`:
|
||||||
|
|
||||||
```ps
|
```ps
|
||||||
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false,$true,$true,$false,$false,$false,$false,"C:\"
|
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false,$true,$true,$false,$false,$false,$false,"C:\"
|
||||||
@@ -270,12 +378,10 @@ On linux/darwin/freebsd, run the following on your runner:
|
|||||||
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh
|
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh
|
||||||
```
|
```
|
||||||
|
|
||||||
This will just install `ghcup` and on windows additionally `msys2`.
|
This will just install `ghcup` and on Windows additionally MSYS2.
|
||||||
|
|
||||||
For the full list of env variables and parameters to tweak the script behavior, see:
|
See the installation scripts referred to above for the full list of environment
|
||||||
|
variables and, in the case of Windows, parameters to tweak the script behavior.
|
||||||
* [bootstrap-haskell for linux/darwin/freebsd](https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell#L7)
|
|
||||||
* [bootstrap-haskell.ps1 for windows](https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell.ps1#L17)
|
|
||||||
|
|
||||||
### github workflows
|
### github workflows
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ GHCup supports the following tools, which are also known as the **Haskell Toolch
|
|||||||
<table>
|
<table>
|
||||||
<thead><tr><th>GHC Version</th><th>Tags</th></tr></thead>
|
<thead><tr><th>GHC Version</th><th>Tags</th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td>9.2.3</td><td><span style="color:blue">latest</span>, base-4.16.2.0</td></tr>
|
<tr><td>9.4.1</td><td><span style="color:blue">latest</span>, base-4.17.0.0</td></tr>
|
||||||
|
<tr><td>9.2.4</td><td>base-4.16.3.0</td></tr>
|
||||||
|
<tr><td>9.2.3</td><td>base-4.16.2.0</td></tr>
|
||||||
<tr><td>9.2.2</td><td>base-4.16.1.0</td></tr>
|
<tr><td>9.2.2</td><td>base-4.16.1.0</td></tr>
|
||||||
<tr><td>9.2.1</td><td>base-4.16.0.0</td></tr>
|
<tr><td>9.2.1</td><td>base-4.16.0.0</td></tr>
|
||||||
<tr><td>9.0.2</td><td>base-4.15.1.0</td></tr>
|
<tr><td>9.0.2</td><td>base-4.15.1.0</td></tr>
|
||||||
@@ -208,6 +210,8 @@ The developers of the Haskell Language Server offer an [extension](https://githu
|
|||||||
3. Make sure your project uses the GHC version installed from GHCup (otherwise HLS is likely to fail on launch):
|
3. Make sure your project uses the GHC version installed from GHCup (otherwise HLS is likely to fail on launch):
|
||||||
- instructions for [stack](https://docs.haskellstack.org/en/stable/yaml_configuration/#system-ghc)
|
- instructions for [stack](https://docs.haskellstack.org/en/stable/yaml_configuration/#system-ghc)
|
||||||
|
|
||||||
|
On Linux, some users have reported an issue when VSCode is not launched from a terminal ("cannot find ghc version"). A solution is to [let HLS know about your GHCup on $PATH](https://github.com/haskell/vscode-haskell#stackcabalghc-can-not-be-found).
|
||||||
|
|
||||||
## Get help
|
## Get help
|
||||||
|
|
||||||
* [Libera IRC chat on #haskell-ghcup or #haskell](https://kiwiirc.com/nextclient/irc.libera.chat/?nick=Guest%7C?#haskell,#haskell-ghcup)
|
* [Libera IRC chat on #haskell-ghcup or #haskell](https://kiwiirc.com/nextclient/irc.libera.chat/?nick=Guest%7C?#haskell,#haskell-ghcup)
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ see the [Cabal user guide](https://cabal.readthedocs.io/en/stable/getting-starte
|
|||||||
|
|
||||||
To learn Haskell, try any of those:
|
To learn Haskell, try any of those:
|
||||||
|
|
||||||
- A beginner friendly [4-lectures course](https://github.com/haskell-beginners-2022/course-plan) with exercises (by [Kowainik](https://kowainik.github.io/))
|
- A beginner friendly [4-lectures course](https://github.com/haskell-beginners-2022/course-plan) with exercises (by [Dmitrii Kovanikov](https://kodimensional.dev/))
|
||||||
- An in-depth university [CIS 194 Haskell course](https://www.cis.upenn.edu/~cis194/spring13/) including exercises (by [Brent Yorgey](https://byorgey.wordpress.com/))
|
- An in-depth university [CIS 194 Haskell course](https://www.cis.upenn.edu/~cis194/spring13/) including exercises (by [Brent Yorgey](https://byorgey.wordpress.com/))
|
||||||
|
|
||||||
## Projects to contribute to
|
## Projects to contribute to
|
||||||
|
|||||||
23
ghcup.cabal
23
ghcup.cabal
@@ -1,6 +1,6 @@
|
|||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: ghcup
|
name: ghcup
|
||||||
version: 0.1.18.0
|
version: 0.1.18.1
|
||||||
license: LGPL-3.0-only
|
license: LGPL-3.0-only
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
copyright: Julian Ospald 2020
|
copyright: Julian Ospald 2020
|
||||||
@@ -21,6 +21,8 @@ extra-doc-files:
|
|||||||
README.md
|
README.md
|
||||||
|
|
||||||
extra-source-files:
|
extra-source-files:
|
||||||
|
cbits/dirutils.c
|
||||||
|
cbits/dirutils.h
|
||||||
data/build_mk/cross
|
data/build_mk/cross
|
||||||
data/build_mk/default
|
data/build_mk/default
|
||||||
test/golden/GHCupInfo.json
|
test/golden/GHCupInfo.json
|
||||||
@@ -69,6 +71,7 @@ library
|
|||||||
GHCup.Prelude.Process
|
GHCup.Prelude.Process
|
||||||
GHCup.Prelude.String.QQ
|
GHCup.Prelude.String.QQ
|
||||||
GHCup.Prelude.Version.QQ
|
GHCup.Prelude.Version.QQ
|
||||||
|
GHCup.Prompts
|
||||||
GHCup.Requirements
|
GHCup.Requirements
|
||||||
GHCup.Stack
|
GHCup.Stack
|
||||||
GHCup.Types
|
GHCup.Types
|
||||||
@@ -161,14 +164,13 @@ library
|
|||||||
, terminal-progress-bar >=0.4.1
|
, terminal-progress-bar >=0.4.1
|
||||||
|
|
||||||
if os(windows)
|
if os(windows)
|
||||||
cpp-options: -DIS_WINDOWS
|
cpp-options: -DIS_WINDOWS
|
||||||
other-modules:
|
other-modules:
|
||||||
GHCup.Prelude.File.Windows
|
GHCup.Prelude.File.Windows
|
||||||
GHCup.Prelude.Windows
|
GHCup.Prelude.Windows
|
||||||
-- GHCup.OptParse.Run uses this
|
|
||||||
exposed-modules:
|
|
||||||
GHCup.Prelude.Process.Windows
|
|
||||||
|
|
||||||
|
-- GHCup.OptParse.Run uses this
|
||||||
|
exposed-modules: GHCup.Prelude.Process.Windows
|
||||||
build-depends:
|
build-depends:
|
||||||
, bzlib
|
, bzlib
|
||||||
, process ^>=1.6.11.0
|
, process ^>=1.6.11.0
|
||||||
@@ -182,7 +184,10 @@ library
|
|||||||
GHCup.Prelude.Posix
|
GHCup.Prelude.Posix
|
||||||
GHCup.Prelude.Process.Posix
|
GHCup.Prelude.Process.Posix
|
||||||
|
|
||||||
c-sources: cbits/dirutils.c
|
include-dirs: cbits
|
||||||
|
includes: dirutils.h
|
||||||
|
install-includes: dirutils.h
|
||||||
|
c-sources: cbits/dirutils.c
|
||||||
build-depends:
|
build-depends:
|
||||||
, bz2 >=0.5.0.5 && <1.1
|
, bz2 >=0.5.0.5 && <1.1
|
||||||
, terminal-size ^>=0.3.2.1
|
, terminal-size ^>=0.3.2.1
|
||||||
@@ -236,7 +241,7 @@ executable ghcup
|
|||||||
, aeson-pretty ^>=0.8.8
|
, aeson-pretty ^>=0.8.8
|
||||||
, async ^>=2.2.3
|
, async ^>=2.2.3
|
||||||
, base >=4.12 && <5
|
, base >=4.12 && <5
|
||||||
, bytestring >=0.10 && <0.12
|
, bytestring >=0.10 && <0.12
|
||||||
, cabal-plan ^>=0.7.2
|
, cabal-plan ^>=0.7.2
|
||||||
, containers ^>=0.6
|
, containers ^>=0.6
|
||||||
, deepseq ^>=1.4
|
, deepseq ^>=1.4
|
||||||
@@ -313,11 +318,11 @@ test-suite ghcup-test
|
|||||||
|
|
||||||
build-depends:
|
build-depends:
|
||||||
, base >=4.12 && <5
|
, base >=4.12 && <5
|
||||||
, bytestring >=0.10 && <0.12
|
, bytestring >=0.10 && <0.12
|
||||||
, containers ^>=0.6
|
, containers ^>=0.6
|
||||||
, directory ^>=1.3.6.0
|
, directory ^>=1.3.6.0
|
||||||
, filepath ^>=1.4.2.1
|
, filepath ^>=1.4.2.1
|
||||||
, generic-arbitrary >=0.1.0 && < 0.2.1 || >=0.2.2 && <0.3
|
, generic-arbitrary >=0.1.0 && <0.2.1 || >=0.2.2 && <0.3
|
||||||
, ghcup
|
, ghcup
|
||||||
, hspec >=2.7.10 && <2.10
|
, hspec >=2.7.10 && <2.10
|
||||||
, hspec-golden-aeson ^>=0.9
|
, hspec-golden-aeson ^>=0.9
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ module GHCup (
|
|||||||
|
|
||||||
|
|
||||||
import GHCup.Cabal
|
import GHCup.Cabal
|
||||||
import GHCup.GHC
|
import GHCup.GHC hiding ( GHCVer(..) )
|
||||||
import GHCup.HLS
|
import GHCup.HLS hiding ( HLSVer(..) )
|
||||||
import GHCup.Stack
|
import GHCup.Stack
|
||||||
import GHCup.List
|
import GHCup.List
|
||||||
import GHCup.Download
|
import GHCup.Download
|
||||||
@@ -206,9 +206,8 @@ rmGhcupDirs = do
|
|||||||
| isWindows = removeDirIfEmptyOrIsSymlink binDir
|
| isWindows = removeDirIfEmptyOrIsSymlink binDir
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
isXDGStyle <- liftIO useXDG
|
isXDGStyle <- liftIO useXDG
|
||||||
if not isXDGStyle
|
when (not isXDGStyle) $
|
||||||
then removeDirIfEmptyOrIsSymlink binDir
|
removeDirIfEmptyOrIsSymlink binDir
|
||||||
else pure ()
|
|
||||||
|
|
||||||
reportRemainingFiles :: (MonadMask m, MonadIO m) => FilePath -> m [FilePath]
|
reportRemainingFiles :: (MonadMask m, MonadIO m) => FilePath -> m [FilePath]
|
||||||
reportRemainingFiles dir = do
|
reportRemainingFiles dir = do
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ data AlreadyInstalled = AlreadyInstalled Tool Version
|
|||||||
instance Pretty AlreadyInstalled where
|
instance Pretty AlreadyInstalled where
|
||||||
pPrint (AlreadyInstalled tool ver') =
|
pPrint (AlreadyInstalled tool ver') =
|
||||||
(pPrint tool <> text "-" <> pPrint ver') <+> text "is already installed;"
|
(pPrint tool <> text "-" <> pPrint ver') <+> text "is already installed;"
|
||||||
<+> text "if you really want to reinstall it, you may want to run 'ghcup install cabal --force" <+> (pPrint ver' <> text "'")
|
<+> text "if you really want to reinstall it, you may want to run 'ghcup install" <+> pPrint tool <+> text "--force" <+> (pPrint ver' <> text "'")
|
||||||
|
|
||||||
|
|
||||||
-- | The Directory is supposed to be empty, but wasn't.
|
-- | The Directory is supposed to be empty, but wasn't.
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ import qualified Data.Text.Encoding as E
|
|||||||
import qualified Text.Megaparsec as MP
|
import qualified Text.Megaparsec as MP
|
||||||
|
|
||||||
|
|
||||||
|
data GHCVer v = SourceDist v
|
||||||
|
| GitDist GitBranch
|
||||||
|
| RemoteDist URI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
--[ Tool fetching ]--
|
--[ Tool fetching ]--
|
||||||
---------------------
|
---------------------
|
||||||
@@ -295,8 +301,9 @@ installUnpackedGHC path inst ver forceInstall addConfArgs
|
|||||||
| otherwise = do
|
| otherwise = do
|
||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
|
|
||||||
let alpineArgs
|
let ldOverride
|
||||||
| ver >= [vver|8.2.2|], Linux Alpine <- _rPlatform
|
| ver >= [vver|8.2.2|]
|
||||||
|
, _rPlatform `elem` [Linux Alpine, Darwin]
|
||||||
= ["--disable-ld-override"]
|
= ["--disable-ld-override"]
|
||||||
| otherwise
|
| otherwise
|
||||||
= []
|
= []
|
||||||
@@ -304,7 +311,7 @@ installUnpackedGHC path inst ver forceInstall addConfArgs
|
|||||||
lift $ logInfo "Installing GHC (this may take a while)"
|
lift $ logInfo "Installing GHC (this may take a while)"
|
||||||
lEM $ execLogged "sh"
|
lEM $ execLogged "sh"
|
||||||
("./configure" : ("--prefix=" <> fromInstallDir inst)
|
("./configure" : ("--prefix=" <> fromInstallDir inst)
|
||||||
: (alpineArgs <> (T.unpack <$> addConfArgs))
|
: (ldOverride <> (T.unpack <$> addConfArgs))
|
||||||
)
|
)
|
||||||
(Just $ fromGHCupPath path)
|
(Just $ fromGHCupPath path)
|
||||||
"ghc-configure"
|
"ghc-configure"
|
||||||
@@ -607,7 +614,7 @@ compileGHC :: ( MonadMask m
|
|||||||
, MonadUnliftIO m
|
, MonadUnliftIO m
|
||||||
, MonadFail m
|
, MonadFail m
|
||||||
)
|
)
|
||||||
=> Either GHCTargetVersion GitBranch -- ^ version to install
|
=> GHCVer GHCTargetVersion
|
||||||
-> Maybe Version -- ^ overwrite version
|
-> Maybe Version -- ^ overwrite version
|
||||||
-> Either Version FilePath -- ^ version to bootstrap with
|
-> Either Version FilePath -- ^ version to bootstrap with
|
||||||
-> Maybe Int -- ^ jobs
|
-> Maybe Int -- ^ jobs
|
||||||
@@ -650,7 +657,7 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
|
|
||||||
(workdir, tmpUnpack, tver) <- case targetGhc of
|
(workdir, tmpUnpack, tver) <- case targetGhc of
|
||||||
-- unpack from version tarball
|
-- unpack from version tarball
|
||||||
Left tver -> do
|
SourceDist tver -> do
|
||||||
lift $ logDebug $ "Requested to compile: " <> tVerToText tver <> " with " <> either prettyVer T.pack bstrap
|
lift $ logDebug $ "Requested to compile: " <> tVerToText tver <> " with " <> either prettyVer T.pack bstrap
|
||||||
|
|
||||||
-- download source tarball
|
-- download source tarball
|
||||||
@@ -671,8 +678,31 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
|
|
||||||
pure (workdir, tmpUnpack, tver)
|
pure (workdir, tmpUnpack, tver)
|
||||||
|
|
||||||
|
RemoteDist uri -> do
|
||||||
|
lift $ logDebug $ "Requested to compile (from uri): " <> T.pack (show uri)
|
||||||
|
|
||||||
|
-- download source tarball
|
||||||
|
tmpDownload <- lift withGHCupTmpDir
|
||||||
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
|
tar <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpDownload) Nothing False
|
||||||
|
(bf, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError] tmpUnpack $ do
|
||||||
|
liftE $ unpackToDir (fromGHCupPath tmpUnpack) tar
|
||||||
|
let regex = [s|^(.*/)*boot$|] :: B.ByteString
|
||||||
|
[bootFile] <- liftIO $ findFilesDeep
|
||||||
|
tmpUnpack
|
||||||
|
(makeRegexOpts compExtended
|
||||||
|
execBlank
|
||||||
|
regex
|
||||||
|
)
|
||||||
|
tver <- liftE $ getGHCVer (appendGHCupPath tmpUnpack (takeDirectory bootFile))
|
||||||
|
pure (bootFile, tver)
|
||||||
|
|
||||||
|
let workdir = appendGHCupPath tmpUnpack (takeDirectory bf)
|
||||||
|
|
||||||
|
pure (workdir, tmpUnpack, mkTVer tver)
|
||||||
|
|
||||||
-- clone from git
|
-- clone from git
|
||||||
Right GitBranch{..} -> do
|
GitDist GitBranch{..} -> do
|
||||||
tmpUnpack <- lift mkGhcupTmpDir
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
||||||
tver <- reThrowAll @_ @'[PatchFailed, ProcessError, NotFoundInPATH, DigestError, DownloadFailed, GPGError] DownloadFailed $ do
|
tver <- reThrowAll @_ @'[PatchFailed, ProcessError, NotFoundInPATH, DigestError, DownloadFailed, GPGError] DownloadFailed $ do
|
||||||
@@ -715,14 +745,7 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)
|
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)
|
||||||
|
|
||||||
-- bootstrap
|
-- bootstrap
|
||||||
lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
tver <- liftE $ getGHCVer tmpUnpack
|
||||||
lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
|
||||||
CapturedProcess {..} <- lift $ makeOut
|
|
||||||
["show!", "--quiet", "VALUE=ProjectVersion" ] (Just $ fromGHCupPath tmpUnpack)
|
|
||||||
tver <- case _exitCode of
|
|
||||||
ExitSuccess -> throwEither . MP.parse ghcProjectVersion "" . T.pack . stripNewlineEnd . T.unpack . decUTF8Safe' $ _stdOut
|
|
||||||
ExitFailure c -> fail ("Could not figure out GHC project version. Exit code was: " <> show c <> ". Error was: " <> T.unpack (decUTF8Safe' _stdErr))
|
|
||||||
|
|
||||||
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
||||||
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
||||||
"GHC version (from Makefile): " <> prettyVer tver <>
|
"GHC version (from Makefile): " <> prettyVer tver <>
|
||||||
@@ -795,11 +818,29 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
pure installVer
|
pure installVer
|
||||||
|
|
||||||
where
|
where
|
||||||
|
getGHCVer :: ( MonadReader env m
|
||||||
|
, HasSettings env
|
||||||
|
, HasDirs env
|
||||||
|
, HasLog env
|
||||||
|
, MonadIO m
|
||||||
|
, MonadThrow m
|
||||||
|
)
|
||||||
|
=> GHCupPath
|
||||||
|
-> Excepts '[ProcessError] m Version
|
||||||
|
getGHCVer tmpUnpack = do
|
||||||
|
lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
||||||
|
lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
||||||
|
CapturedProcess {..} <- lift $ makeOut
|
||||||
|
["show!", "--quiet", "VALUE=ProjectVersion" ] (Just $ fromGHCupPath tmpUnpack)
|
||||||
|
case _exitCode of
|
||||||
|
ExitSuccess -> throwEither . MP.parse ghcProjectVersion "" . T.pack . stripNewlineEnd . T.unpack . decUTF8Safe' $ _stdOut
|
||||||
|
ExitFailure c -> throwE $ NonZeroExit c "make" ["show!", "--quiet", "VALUE=ProjectVersion" ]
|
||||||
|
|
||||||
defaultConf =
|
defaultConf =
|
||||||
let cross_mk = $(LitE . StringL <$> (qAddDependentFile "data/build_mk/cross" >> runIO (readFile "data/build_mk/cross")))
|
let cross_mk = $(LitE . StringL <$> (qAddDependentFile "data/build_mk/cross" >> runIO (readFile "data/build_mk/cross")))
|
||||||
default_mk = $(LitE . StringL <$> (qAddDependentFile "data/build_mk/default" >> runIO (readFile "data/build_mk/default")))
|
default_mk = $(LitE . StringL <$> (qAddDependentFile "data/build_mk/default" >> runIO (readFile "data/build_mk/default")))
|
||||||
in case targetGhc of
|
in case targetGhc of
|
||||||
Left (GHCTargetVersion (Just _) _) -> cross_mk
|
SourceDist (GHCTargetVersion (Just _) _) -> cross_mk
|
||||||
_ -> default_mk
|
_ -> default_mk
|
||||||
|
|
||||||
compileHadrianBindist :: ( MonadReader env m
|
compileHadrianBindist :: ( MonadReader env m
|
||||||
@@ -976,7 +1017,7 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
|
|
||||||
-- for cross, we need Stage1Only
|
-- for cross, we need Stage1Only
|
||||||
case targetGhc of
|
case targetGhc of
|
||||||
Left (GHCTargetVersion (Just _) _) -> when ("Stage1Only = YES" `notElem` lines') $ throwE
|
SourceDist (GHCTargetVersion (Just _) _) -> when ("Stage1Only = YES" `notElem` lines') $ throwE
|
||||||
(InvalidBuildConfig
|
(InvalidBuildConfig
|
||||||
[s|Cross compiling needs to be a Stage1 build, add "Stage1Only = YES" to your config!|]
|
[s|Cross compiling needs to be a Stage1 build, add "Stage1Only = YES" to your config!|]
|
||||||
)
|
)
|
||||||
|
|||||||
107
lib/GHCup/HLS.hs
107
lib/GHCup/HLS.hs
@@ -71,6 +71,12 @@ import qualified Text.Megaparsec as MP
|
|||||||
import Text.PrettyPrint.HughesPJClass (prettyShow)
|
import Text.PrettyPrint.HughesPJClass (prettyShow)
|
||||||
|
|
||||||
|
|
||||||
|
data HLSVer = SourceDist Version
|
||||||
|
| GitDist GitBranch
|
||||||
|
| HackageDist Version
|
||||||
|
| RemoteDist URI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
--[ Installation ]--
|
--[ Installation ]--
|
||||||
@@ -324,13 +330,14 @@ compileHLS :: ( MonadMask m
|
|||||||
, MonadUnliftIO m
|
, MonadUnliftIO m
|
||||||
, MonadFail m
|
, MonadFail m
|
||||||
)
|
)
|
||||||
=> Either Version GitBranch
|
=> HLSVer
|
||||||
-> [Version]
|
-> [Version]
|
||||||
-> Maybe Int
|
-> Maybe Int
|
||||||
-> Either Bool Version
|
-> Either Bool Version
|
||||||
-> InstallDir
|
-> InstallDir
|
||||||
-> Maybe (Either FilePath URI)
|
-> Maybe (Either FilePath URI)
|
||||||
-> Maybe URI
|
-> Maybe URI
|
||||||
|
-> Bool
|
||||||
-> Maybe (Either FilePath [URI]) -- ^ patches
|
-> Maybe (Either FilePath [URI]) -- ^ patches
|
||||||
-> [Text] -- ^ additional args to cabal install
|
-> [Text] -- ^ additional args to cabal install
|
||||||
-> Excepts '[ NoDownload
|
-> Excepts '[ NoDownload
|
||||||
@@ -343,15 +350,18 @@ compileHLS :: ( MonadMask m
|
|||||||
, BuildFailed
|
, BuildFailed
|
||||||
, NotInstalled
|
, NotInstalled
|
||||||
] m Version
|
] m Version
|
||||||
compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patches cabalArgs = do
|
compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal updateCabal patches cabalArgs = do
|
||||||
PlatformRequest { .. } <- lift getPlatformReq
|
PlatformRequest { .. } <- lift getPlatformReq
|
||||||
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo
|
||||||
Dirs { .. } <- lift getDirs
|
Dirs { .. } <- lift getDirs
|
||||||
|
|
||||||
|
when updateCabal $ reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
||||||
|
lift $ logInfo "Updating cabal DB"
|
||||||
|
lEM $ exec "cabal" ["update"] (Just $ fromGHCupPath tmpDir) Nothing
|
||||||
|
|
||||||
(workdir, tver, git_describe) <- case targetHLS of
|
(workdir, tmpUnpack, tver, git_describe) <- case targetHLS of
|
||||||
-- unpack from version tarball
|
-- unpack from version tarball
|
||||||
Left tver -> do
|
SourceDist tver -> do
|
||||||
lift $ logDebug $ "Requested to compile: " <> prettyVer tver
|
lift $ logDebug $ "Requested to compile: " <> prettyVer tver
|
||||||
|
|
||||||
-- download source tarball
|
-- download source tarball
|
||||||
@@ -369,10 +379,47 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
(liftE . intoSubdir tmpUnpack)
|
(liftE . intoSubdir tmpUnpack)
|
||||||
(view dlSubdir dlInfo)
|
(view dlSubdir dlInfo)
|
||||||
|
|
||||||
pure (workdir, tver, Nothing)
|
pure (workdir, tmpUnpack, tver, Nothing)
|
||||||
|
|
||||||
|
HackageDist tver -> do
|
||||||
|
lift $ logDebug $ "Requested to compile (from hackage): " <> prettyVer tver
|
||||||
|
|
||||||
|
-- download source tarball
|
||||||
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
|
let hls = "haskell-language-server-" <> T.unpack (prettyVer tver)
|
||||||
|
reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
||||||
|
-- unpack
|
||||||
|
lEM $ exec "cabal" ["unpack", hls] (Just $ fromGHCupPath tmpUnpack) Nothing
|
||||||
|
|
||||||
|
let workdir = appendGHCupPath tmpUnpack hls
|
||||||
|
|
||||||
|
pure (workdir, tmpUnpack, tver, Nothing)
|
||||||
|
|
||||||
|
RemoteDist uri -> do
|
||||||
|
lift $ logDebug $ "Requested to compile (from uri): " <> T.pack (show uri)
|
||||||
|
|
||||||
|
-- download source tarball
|
||||||
|
tmpDownload <- lift withGHCupTmpDir
|
||||||
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
|
tar <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpDownload) Nothing False
|
||||||
|
(cf, tver) <- liftE $ cleanUpOnError tmpUnpack $ do
|
||||||
|
unpackToDir (fromGHCupPath tmpUnpack) tar
|
||||||
|
let regex = [s|^(.*/)*haskell-language-server\.cabal$|] :: B.ByteString
|
||||||
|
[cabalFile] <- liftIO $ findFilesDeep
|
||||||
|
tmpUnpack
|
||||||
|
(makeRegexOpts compExtended
|
||||||
|
execBlank
|
||||||
|
regex
|
||||||
|
)
|
||||||
|
tver <- getCabalVersion (fromGHCupPath tmpUnpack </> cabalFile)
|
||||||
|
pure (cabalFile, tver)
|
||||||
|
|
||||||
|
let workdir = appendGHCupPath tmpUnpack (takeDirectory cf)
|
||||||
|
|
||||||
|
pure (workdir, tmpUnpack, tver, Nothing)
|
||||||
|
|
||||||
-- clone from git
|
-- clone from git
|
||||||
Right GitBranch{..} -> do
|
GitDist GitBranch{..} -> do
|
||||||
tmpUnpack <- lift mkGhcupTmpDir
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
||||||
reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
||||||
@@ -409,15 +456,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
then pure Nothing
|
then pure Nothing
|
||||||
else fmap Just $ gitOut ["describe", "--tags"] (fromGHCupPath tmpUnpack)
|
else fmap Just $ gitOut ["describe", "--tags"] (fromGHCupPath tmpUnpack)
|
||||||
chash <- gitOut ["rev-parse", "HEAD" ] (fromGHCupPath tmpUnpack)
|
chash <- gitOut ["rev-parse", "HEAD" ] (fromGHCupPath tmpUnpack)
|
||||||
(Just gpd) <- parseGenericPackageDescriptionMaybe
|
tver <- getCabalVersion (fromGHCupPath tmpUnpack </> "haskell-language-server.cabal")
|
||||||
<$> liftIO (B.readFile (fromGHCupPath tmpUnpack </> "haskell-language-server.cabal"))
|
|
||||||
let tver = (\c -> Version Nothing c [] Nothing)
|
|
||||||
. NE.fromList . fmap (NE.fromList . (:[]) . digits . fromIntegral)
|
|
||||||
. versionNumbers
|
|
||||||
. pkgVersion
|
|
||||||
. package
|
|
||||||
. packageDescription
|
|
||||||
$ gpd
|
|
||||||
|
|
||||||
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
||||||
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
||||||
@@ -425,7 +464,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
(if not shallow_clone then "\n " <> "'git describe' output: " <> fromJust git_describe else mempty) <>
|
(if not shallow_clone then "\n " <> "'git describe' output: " <> fromJust git_describe else mempty) <>
|
||||||
(if isCommitHash ref then mempty else "\n " <> "commit hash: " <> chash)
|
(if isCommitHash ref then mempty else "\n " <> "commit hash: " <> chash)
|
||||||
|
|
||||||
pure (tmpUnpack, tver, git_describe)
|
pure (tmpUnpack, tmpUnpack, tver, git_describe)
|
||||||
|
|
||||||
-- the version that's installed may differ from the
|
-- the version that's installed may differ from the
|
||||||
-- compiled version, so the user can overwrite it
|
-- compiled version, so the user can overwrite it
|
||||||
@@ -441,7 +480,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
Right v -> pure v
|
Right v -> pure v
|
||||||
|
|
||||||
liftE $ runBuildAction
|
liftE $ runBuildAction
|
||||||
workdir
|
tmpUnpack
|
||||||
(reThrowAll @_ @'[GPGError, DownloadFailed, DigestError, PatchFailed, ProcessError, FileAlreadyExistsError, CopyError] @'[BuildFailed] (BuildFailed $ fromGHCupPath workdir) $ do
|
(reThrowAll @_ @'[GPGError, DownloadFailed, DigestError, PatchFailed, ProcessError, FileAlreadyExistsError, CopyError] @'[BuildFailed] (BuildFailed $ fromGHCupPath workdir) $ do
|
||||||
let tmpInstallDir = fromGHCupPath workdir </> "out"
|
let tmpInstallDir = fromGHCupPath workdir </> "out"
|
||||||
liftIO $ createDirRecursive' tmpInstallDir
|
liftIO $ createDirRecursive' tmpInstallDir
|
||||||
@@ -457,14 +496,22 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
pure "cabal.project"
|
pure "cabal.project"
|
||||||
| otherwise -> pure (takeFileName cp)
|
| otherwise -> pure (takeFileName cp)
|
||||||
Just (Right uri) -> do
|
Just (Right uri) -> do
|
||||||
tmpUnpack <- lift withGHCupTmpDir
|
tmpUnpack' <- lift withGHCupTmpDir
|
||||||
cp <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpUnpack) (Just "cabal.project") False
|
cp <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpUnpack') (Just "cabal.project") False
|
||||||
copyFileE cp (fromGHCupPath workdir </> "cabal.project") False
|
copyFileE cp (fromGHCupPath workdir </> "cabal.project") False
|
||||||
pure "cabal.project"
|
pure "cabal.project"
|
||||||
Nothing -> pure "cabal.project"
|
Nothing
|
||||||
|
| HackageDist _ <- targetHLS -> do
|
||||||
|
liftIO $ B.writeFile (fromGHCupPath workdir </> "cabal.project") "packages: ./"
|
||||||
|
pure "cabal.project"
|
||||||
|
| RemoteDist _ <- targetHLS -> do
|
||||||
|
let cabalFile = fromGHCupPath workdir </> "cabal.project"
|
||||||
|
liftIO $ whenM (not <$> doesFileExist cabalFile) $ B.writeFile cabalFile "packages: ./"
|
||||||
|
pure "cabal.project"
|
||||||
|
| otherwise -> pure "cabal.project"
|
||||||
forM_ cabalProjectLocal $ \uri -> do
|
forM_ cabalProjectLocal $ \uri -> do
|
||||||
tmpUnpack <- lift withGHCupTmpDir
|
tmpUnpack' <- lift withGHCupTmpDir
|
||||||
cpl <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpUnpack) (Just (cp <.> "local")) False
|
cpl <- liftE $ download uri Nothing Nothing (fromGHCupPath tmpUnpack') (Just (cp <.> "local")) False
|
||||||
copyFileE cpl (fromGHCupPath workdir </> cp <.> "local") False
|
copyFileE cpl (fromGHCupPath workdir </> cp <.> "local") False
|
||||||
artifacts <- forM (sort ghcs) $ \ghc -> do
|
artifacts <- forM (sort ghcs) $ \ghc -> do
|
||||||
let ghcInstallDir = tmpInstallDir </> T.unpack (prettyVer ghc)
|
let ghcInstallDir = tmpInstallDir </> T.unpack (prettyVer ghc)
|
||||||
@@ -658,3 +705,19 @@ rmHLSVer ver = do
|
|||||||
case headMay . reverse . sort $ hlsVers of
|
case headMay . reverse . sort $ hlsVers of
|
||||||
Just latestver -> liftE $ setHLS latestver SetHLSOnly Nothing
|
Just latestver -> liftE $ setHLS latestver SetHLSOnly Nothing
|
||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
|
|
||||||
|
|
||||||
|
getCabalVersion :: (MonadIO m, MonadFail m) => FilePath -> m Version
|
||||||
|
getCabalVersion fp = do
|
||||||
|
contents <- liftIO $ B.readFile fp
|
||||||
|
gpd <- case parseGenericPackageDescriptionMaybe contents of
|
||||||
|
Nothing -> fail $ "could not parse cabal file: " <> fp
|
||||||
|
Just r -> pure r
|
||||||
|
let tver = (\c -> Version Nothing c [] Nothing)
|
||||||
|
. NE.fromList . fmap (NE.fromList . (:[]) . digits . fromIntegral)
|
||||||
|
. versionNumbers
|
||||||
|
. pkgVersion
|
||||||
|
. package
|
||||||
|
. packageDescription
|
||||||
|
$ gpd
|
||||||
|
pure tver
|
||||||
|
|||||||
28
lib/GHCup/Prompts.hs
Normal file
28
lib/GHCup/Prompts.hs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
|
|
||||||
|
module GHCup.Prompts
|
||||||
|
( PromptQuestion,
|
||||||
|
PromptResponse (..),
|
||||||
|
getUserPromptResponse,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Control.Monad.Reader
|
||||||
|
import qualified Data.Text.IO as TIO
|
||||||
|
import GHCup.Prelude.Logger
|
||||||
|
import GHCup.Types.Optics
|
||||||
|
import GHCup.Types (PromptQuestion, PromptResponse(..))
|
||||||
|
|
||||||
|
getUserPromptResponse :: ( HasLog env
|
||||||
|
, MonadReader env m
|
||||||
|
, MonadIO m)
|
||||||
|
=> PromptQuestion
|
||||||
|
-> m PromptResponse
|
||||||
|
|
||||||
|
getUserPromptResponse prompt = do
|
||||||
|
logInfo prompt
|
||||||
|
resp <- liftIO TIO.getLine
|
||||||
|
if resp `elem` ["YES", "yes", "y", "Y"]
|
||||||
|
then pure PromptYes
|
||||||
|
else pure PromptNo
|
||||||
@@ -657,10 +657,7 @@ isSafeDir (IsolateDirResolved _) = False
|
|||||||
isSafeDir (GHCupDir _) = True
|
isSafeDir (GHCupDir _) = True
|
||||||
isSafeDir (GHCupBinDir _) = False
|
isSafeDir (GHCupBinDir _) = False
|
||||||
|
|
||||||
|
type PromptQuestion = Text
|
||||||
|
|
||||||
|
data PromptResponse = PromptYes | PromptNo
|
||||||
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1097,7 +1097,8 @@ runBuildAction bdir action = do
|
|||||||
|
|
||||||
-- | Clean up the given directory if the action fails,
|
-- | Clean up the given directory if the action fails,
|
||||||
-- depending on the Settings.
|
-- depending on the Settings.
|
||||||
cleanUpOnError :: ( MonadReader env m
|
cleanUpOnError :: forall e m a env .
|
||||||
|
( MonadReader env m
|
||||||
, HasDirs env
|
, HasDirs env
|
||||||
, HasSettings env
|
, HasSettings env
|
||||||
, MonadIO m
|
, MonadIO m
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
# * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation
|
# * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation
|
||||||
# * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install
|
# * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install
|
||||||
# * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install
|
# * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install
|
||||||
# * BOOTSTRAP_HASKELL_INSTALL_STACK - whether to install latest stack
|
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK - disable installation of stack
|
||||||
|
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK - disable installation stack ghcup hook
|
||||||
# * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls
|
# * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls
|
||||||
# * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend)
|
# * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend)
|
||||||
# * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows
|
# * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
|
|
||||||
plat="$(uname -s)"
|
plat="$(uname -s)"
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
ghver="0.1.17.8"
|
ghver="0.1.18.0"
|
||||||
: "${GHCUP_BASE_URL:=https://downloads.haskell.org/~ghcup}"
|
: "${GHCUP_BASE_URL:=https://downloads.haskell.org/~ghcup}"
|
||||||
|
|
||||||
export GHCUP_SKIP_UPDATE_CHECK=yes
|
export GHCUP_SKIP_UPDATE_CHECK=yes
|
||||||
@@ -140,8 +141,12 @@ ecabal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ecabal() {
|
_ecabal() {
|
||||||
# shellcheck disable=SC2086
|
if [ -n "${CABAL_BIN}" ] ; then
|
||||||
"${GHCUP_BIN}/cabal" "$@"
|
"${CABAL_BIN}" "$@"
|
||||||
|
else
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
"${GHCUP_BIN}/cabal" "$@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_done() {
|
_done() {
|
||||||
@@ -655,7 +660,7 @@ ask_hls() {
|
|||||||
warn "Do you want to install haskell-language-server (HLS)?"
|
warn "Do you want to install haskell-language-server (HLS)?"
|
||||||
warn "HLS is a language-server that provides IDE-like functionality"
|
warn "HLS is a language-server that provides IDE-like functionality"
|
||||||
warn "and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ..."
|
warn "and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ..."
|
||||||
warn "Also see https://github.com/haskell/haskell-language-server/blob/master/README.md"
|
warn "Also see https://haskell-language-server.readthedocs.io/en/stable/"
|
||||||
warn ""
|
warn ""
|
||||||
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
||||||
warn ""
|
warn ""
|
||||||
@@ -688,40 +693,44 @@ ask_hls() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ask_stack() {
|
ask_stack() {
|
||||||
if [ -n "${BOOTSTRAP_HASKELL_INSTALL_STACK}" ] ; then
|
if [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK}" ] ; then
|
||||||
|
return 0
|
||||||
|
elif [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK}" ] ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
||||||
echo "-------------------------------------------------------------------------------"
|
echo "-------------------------------------------------------------------------------"
|
||||||
|
|
||||||
warn "Do you want to install stack?"
|
warn "Do you want to enable better integration of stack with GHCup?"
|
||||||
warn "Stack is a haskell build tool similar to cabal that is used by some projects."
|
warn "This means that stack won't install its own GHC versions, but uses GHCup's."
|
||||||
warn "Also see https://docs.haskellstack.org/"
|
warn "For more information see:"
|
||||||
|
warn " https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental"
|
||||||
|
warn "If you want to keep stacks vanilla behavior, answer 'No'."
|
||||||
warn ""
|
warn ""
|
||||||
warn "[Y] Yes [N] No [?] Help (default is \"N\")."
|
warn "[Y] Yes [N] No [?] Help (default is \"Y\")."
|
||||||
warn ""
|
warn ""
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -r stack_answer </dev/tty
|
read -r stack_answer </dev/tty
|
||||||
|
|
||||||
case $stack_answer in
|
case $stack_answer in
|
||||||
[Yy]*)
|
[Yy]* | "")
|
||||||
|
return 2 ;;
|
||||||
|
[Nn]*)
|
||||||
return 1 ;;
|
return 1 ;;
|
||||||
[Nn]* | "")
|
|
||||||
return 0 ;;
|
|
||||||
*)
|
*)
|
||||||
echo "Possible choices are:"
|
echo "Possible choices are:"
|
||||||
echo
|
echo
|
||||||
echo "Y - Yes, install stack"
|
echo "Y - Yes, enable better integration (default)"
|
||||||
echo "N - No, don't install anything more (default)"
|
echo "N - No, keep stacks vanilla behavior"
|
||||||
echo
|
echo
|
||||||
echo "Please make your choice and press ENTER."
|
echo "Please make your choice and press ENTER."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
return 0
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset stack_answer
|
unset stack_answer
|
||||||
@@ -738,7 +747,7 @@ echo "This script can download and install the following binaries:"
|
|||||||
echo " * ghcup - The Haskell toolchain installer"
|
echo " * ghcup - The Haskell toolchain installer"
|
||||||
echo " * ghc - The Glasgow Haskell Compiler"
|
echo " * ghc - The Glasgow Haskell Compiler"
|
||||||
echo " * cabal - The Cabal build tool for managing Haskell software"
|
echo " * cabal - The Cabal build tool for managing Haskell software"
|
||||||
echo " * stack - (optional) A cross-platform program for developing Haskell projects"
|
echo " * stack - A cross-platform program for developing Haskell projects (similar to cabal)"
|
||||||
echo " * hls - (optional) A language server for developers to integrate with their editor/IDE"
|
echo " * hls - (optional) A language server for developers to integrate with their editor/IDE"
|
||||||
echo
|
echo
|
||||||
if [ -z "${GHCUP_USE_XDG_DIRS}" ] ; then
|
if [ -z "${GHCUP_USE_XDG_DIRS}" ] ; then
|
||||||
@@ -817,7 +826,7 @@ else # don't install ghc and cabal
|
|||||||
# we'll remove it afterwards
|
# we'll remove it afterwards
|
||||||
tmp_dir="$(mktemp -d)"
|
tmp_dir="$(mktemp -d)"
|
||||||
eghcup --cache install cabal -i "${tmp_dir}" "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
eghcup --cache install cabal -i "${tmp_dir}" "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
||||||
PATH="${tmp_dir}:$PATH" do_cabal_config_init $ask_cabal_config_init_answer
|
CABAL_BIN="${tmp_dir}/cabal" do_cabal_config_init $ask_cabal_config_init_answer
|
||||||
rm "${tmp_dir}/cabal"
|
rm "${tmp_dir}/cabal"
|
||||||
unset tmp_dir
|
unset tmp_dir
|
||||||
;;
|
;;
|
||||||
@@ -835,7 +844,35 @@ esac
|
|||||||
|
|
||||||
case $ask_stack_answer in
|
case $ask_stack_answer in
|
||||||
1)
|
1)
|
||||||
_eghcup --cache install stack || warn "Stack installation failed, continuing anyway"
|
_eghcup --cache install stack || die "Stack installation failed"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
_eghcup --cache install stack || die "Stack installation failed"
|
||||||
|
edo mkdir -p "${STACK_ROOOT:-$HOME/.stack}"/hooks
|
||||||
|
hook_exe="${STACK_ROOOT:-$HOME/.stack}"/hooks/ghc-install.sh
|
||||||
|
hook_url="https://www.haskell.org/ghcup/sh/hooks/stack/ghc-install.sh"
|
||||||
|
|
||||||
|
if [ -e "${hook_exe}" ] ; then
|
||||||
|
warn "$hook_exe already exists, skipping hook installation."
|
||||||
|
warn "If you want to reinstall the hook, delete it manually and re-run"
|
||||||
|
warn "this script!"
|
||||||
|
else
|
||||||
|
case "${BOOTSTRAP_HASKELL_DOWNLOADER}" in
|
||||||
|
"curl")
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
edo curl -Lf ${GHCUP_CURL_OPTS} "${hook_url}" > "${hook_exe}"
|
||||||
|
;;
|
||||||
|
"wget")
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
edo wget -O /dev/stdout ${GHCUP_WGET_OPTS} "${hook_url}" > "${hook_exe}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unknown downloader: ${BOOTSTRAP_HASKELL_DOWNLOADER}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
edo chmod +x "${hook_exe}"
|
||||||
|
fi
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
21
scripts/hooks/stack/ghc-install.sh
Normal file
21
scripts/hooks/stack/ghc-install.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# see https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental
|
||||||
|
# for documentation about hooks
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
case $HOOK_GHC_TYPE in
|
||||||
|
bindist)
|
||||||
|
echo "$(ghcup run --ghc "$HOOK_GHC_VERSION" --install)/ghc"
|
||||||
|
;;
|
||||||
|
git)
|
||||||
|
# TODO: should be somewhat possible
|
||||||
|
>&2 echo "Hook doesn't support installing from source"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
>&2 echo "Unsupported GHC installation type: $HOOK_GHC_TYPE"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user