From 0300d8f2cc82a1993cabb92af514c1739f747f90 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 17:20:29 +0800 Subject: [PATCH 1/9] Bump for brick windows --- ghcup.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ghcup.cabal b/ghcup.cabal index e97d9bb..c8dd8cc 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -238,7 +238,7 @@ library if (flag(tui) && !os(windows)) cpp-options: -DBRICK - build-depends: vty ^>=5.39 + build-depends: vty ^>=6.0 library ghcup-optparse import: app-common-depends @@ -324,10 +324,10 @@ executable ghcup cpp-options: -DBRICK other-modules: BrickMain build-depends: - , brick ^>=1.5 + , brick ^>=2.1 , transformers ^>=0.5 , unix ^>=2.7 - , vty ^>=5.39 + , vty ^>=6.0 if os(windows) cpp-options: -DIS_WINDOWS From 64c1d63d33f139d51e590214b4f27e0c6b8596f5 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 17:24:43 +0800 Subject: [PATCH 2/9] Allow tui flag for windows as well --- ghcup.cabal | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ghcup.cabal b/ghcup.cabal index c8dd8cc..3c5c3ac 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -36,7 +36,7 @@ source-repository head flag tui description: - Build the brick powered tui (ghcup tui). This is disabled on windows. + Build the brick powered tui (ghcup tui). default: False manual: True @@ -236,7 +236,7 @@ library , unix ^>=2.7 , unix-bytestring ^>=0.3.7.3 - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK build-depends: vty ^>=6.0 @@ -284,7 +284,7 @@ library ghcup-optparse if flag(internal-downloader) cpp-options: -DINTERNAL_DOWNLOADER - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK if os(windows) @@ -320,13 +320,12 @@ executable ghcup if flag(internal-downloader) cpp-options: -DINTERNAL_DOWNLOADER - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK other-modules: BrickMain build-depends: , brick ^>=2.1 , transformers ^>=0.5 - , unix ^>=2.7 , vty ^>=6.0 if os(windows) From a44bf5884d54bc9d85c6bd3ae2fa8c01f2c59059 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 17:29:20 +0800 Subject: [PATCH 3/9] Enable tui for windows in release builds --- cabal.project.release | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cabal.project.release b/cabal.project.release index c8c11c4..70f92ef 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -9,30 +9,25 @@ source-repository-package location: https://github.com/fosskers/versions.git tag: 7bc3355348aac3510771d4622aff09ac38c9924d +package ghcup + flags: +tui + if os(linux) - package ghcup - flags: +tui if arch(x86_64) || arch(i386) package * ghc-options: -split-sections -optl-static elif os(darwin) constraints: zlib +bundled-c-zlib, lzma +static - package ghcup - flags: +tui elif os(mingw32) constraints: zlib +bundled-c-zlib, lzma +static, text -simdutf - package ghcup - flags: -tui elif os(freebsd) constraints: zlib +bundled-c-zlib, zip +disable-zstd package * ghc-options: -split-sections -pgmc clang++14 - package ghcup - flags: +tui constraints: http-io-streams -brotli, any.aeson >= 2.0.1.0, From f2b139b58b62bbeeb0d997e88f3da962ee20dc00 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 17:29:40 +0800 Subject: [PATCH 4/9] Drop temp source-repository stanza for 'versions' --- cabal.project.release | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cabal.project.release b/cabal.project.release index 70f92ef..35155ff 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -4,11 +4,6 @@ optional-packages: ./vendored/*/*.cabal optimization: 2 -source-repository-package - type: git - location: https://github.com/fosskers/versions.git - tag: 7bc3355348aac3510771d4622aff09ac38c9924d - package ghcup flags: +tui From ba4c6e5b99d06c10f8ce5683b25dcf055b9e1f08 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 17:33:54 +0800 Subject: [PATCH 5/9] Relax vector upper bound --- ghcup.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghcup.cabal b/ghcup.cabal index 3c5c3ac..3b0ff9b 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -86,7 +86,7 @@ common app-common-depends , unordered-containers ^>=0.2 , uri-bytestring ^>=0.3.2.2 , utf8-string ^>=1.0 - , vector ^>=0.12 + , vector >=0.12 && <0.14 , versions >=6.0.3 && <6.1 , yaml-streamly ^>=0.12.0 @@ -190,7 +190,7 @@ library , unliftio-core ^>=0.2.0.1 , unordered-containers ^>=0.2.10.0 , uri-bytestring ^>=0.3.2.2 - , vector ^>=0.12 + , vector >=0.12 && <0.14 , versions >=6.0.3 && <6.1 , word8 ^>=0.1.3 , yaml-streamly ^>=0.12.0 From 9fcacbd96b8b9e795a8a24c1885738f48ff30774 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 18:00:23 +0800 Subject: [PATCH 6/9] Fix CPP defines for windows+brick --- app/ghcup/BrickMain.hs | 5 +++++ lib/GHCup/Types.hs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs index 7143f52..4e449a7 100644 --- a/app/ghcup/BrickMain.hs +++ b/app/ghcup/BrickMain.hs @@ -61,7 +61,9 @@ import qualified Data.Text.Lazy as L import qualified Graphics.Vty as Vty import qualified Data.Vector as V import System.Environment (getExecutablePath) +#if !IS_WINDOWS import qualified System.Posix.Process as SPP +#endif hiddenTools :: [Tool] @@ -500,12 +502,15 @@ install' _ (_, ListResult {..}) = do forM_ (_viPostInstall =<< vi) $ \msg -> logInfo msg case lTool of GHCup -> do +#if !IS_WINDOWS up <- liftIO $ fmap (either (const Nothing) Just) $ try @_ @SomeException $ canonicalizePath (binDir "ghcup" <.> exeExt) when ((normalise <$> up) == Just (normalise ce)) $ -- TODO: track cli arguments of previous invocation liftIO $ SPP.executeFile ce False ["tui"] Nothing +#else logInfo "Please restart 'ghcup' for the changes to take effect" +#endif _ -> pure () pure $ Right () VRight (vi, _, _) -> do diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index 974a9ab..53b3c3c 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -475,7 +475,7 @@ data KeyBindings = KeyBindings deriving (Show, GHC.Generic) instance NFData KeyBindings -#if defined(IS_WINDOWS) || !defined(BRICK) +#if !defined(BRICK) instance NFData Key instance NFData Modifier From 675ab17fff05f017dcc3ab7a15c23bc64abfe876 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Nov 2023 22:28:23 +0800 Subject: [PATCH 7/9] Improve signs on windows (no unicode) --- app/ghcup/BrickMain.hs | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs index 4e449a7..66c851a 100644 --- a/app/ghcup/BrickMain.hs +++ b/app/ghcup/BrickMain.hs @@ -5,6 +5,8 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ViewPatterns #-} +{-# OPTIONS_GHC -Wno-unused-record-wildcards #-} +{-# OPTIONS_GHC -Wno-unused-matches #-} module BrickMain where @@ -16,7 +18,6 @@ import GHCup.Types hiding ( LeanAppState(..) ) import GHCup.Utils import GHCup.OptParse.Common (logGHCPostRm) import GHCup.Prelude ( decUTF8Safe ) -import GHCup.Prelude.File import GHCup.Prelude.Logger import GHCup.Prelude.Process import GHCup.Prompts @@ -49,7 +50,6 @@ import Data.Vector ( Vector import Data.Versions import Haskus.Utils.Variant.Excepts import Prelude hiding ( appendFile ) -import System.FilePath import System.Exit import System.IO.Unsafe import Text.PrettyPrint.HughesPJClass ( prettyShow ) @@ -62,10 +62,33 @@ import qualified Graphics.Vty as Vty import qualified Data.Vector as V import System.Environment (getExecutablePath) #if !IS_WINDOWS +import GHCup.Prelude.File +import System.FilePath import qualified System.Posix.Process as SPP #endif +installedSign :: String +#if IS_WINDOWS +installedSign = "I " +#else +installedSign = "✓ " +#endif + +setSign :: String +#if IS_WINDOWS +setSign = "IS" +#else +setSign = "✔✔" +#endif + +notInstalledSign :: String +#if IS_WINDOWS +notInstalledSign = "X " +#else +notInstalledSign = "✗ " +#endif + hiddenTools :: [Tool] hiddenTools = [] @@ -167,9 +190,9 @@ ui dimAttrs BrickState{ appSettings = as@BrickSettings{}, ..} in withDefAttr listAttr . drawListElements (renderItem minTagSize minVerSize) True $ bis renderItem minTagSize minVerSize _ b listResult@ListResult{lTag = lTag', ..} = let marks = if - | lSet -> (withAttr (attrName "set") $ str "✔✔") - | lInstalled -> (withAttr (attrName "installed") $ str "✓ ") - | otherwise -> (withAttr (attrName "not-installed") $ str "✗ ") + | lSet -> (withAttr (attrName "set") $ str setSign) + | lInstalled -> (withAttr (attrName "installed") $ str installedSign) + | otherwise -> (withAttr (attrName "not-installed") $ str notInstalledSign) ver = case lCross of Nothing -> T.unpack . prettyVer $ lVer Just c -> T.unpack (c <> "-" <> prettyVer lVer) From dde32fa72e3197020e91a012b25747c930d0940a Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 6 Nov 2023 17:35:20 +0800 Subject: [PATCH 8/9] Ensure patched version of vty-windows is used --- cabal.project.release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cabal.project.release b/cabal.project.release index 35155ff..67f00cc 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -17,7 +17,8 @@ elif os(darwin) elif os(mingw32) constraints: zlib +bundled-c-zlib, lzma +static, - text -simdutf + text -simdutf, + vty-windows >=0.1.0.3 elif os(freebsd) constraints: zlib +bundled-c-zlib, zip +disable-zstd From 30a10d871ab6235a642a54b8b3b09bef376ef9b8 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 9 Nov 2023 23:42:31 +0800 Subject: [PATCH 9/9] Update bootstrap script --- scripts/bootstrap/bootstrap-haskell | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index b693cb3..0098eb5 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -172,9 +172,8 @@ _done() { green "Start a new haskell project in the current directory via:" green " cabal init --interactive" green - green "Install other GHC versions and tools via:" - green " ghcup list" - green " ghcup install " + green "To install other GHC versions and tools, run:" + green " ghcup tui" green green "To install system libraries and update msys2/mingw64," green "open the \"Mingw haskell shell\""