Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump for brick windows #912

Merged
merged 9 commits into from
Nov 10, 2023
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
38 changes: 33 additions & 5 deletions app/ghcup/BrickMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-unused-record-wildcards #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}

module BrickMain where

Expand All @@ -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
Expand Down Expand Up @@ -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 )
Expand All @@ -61,8 +61,33 @@ 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 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 = []
Expand Down Expand Up @@ -165,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)
Expand Down Expand Up @@ -500,12 +525,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
Expand Down
17 changes: 4 additions & 13 deletions cabal.project.release
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,26 @@ optional-packages: ./vendored/*/*.cabal

optimization: 2

source-repository-package
type: git
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
text -simdutf,
vty-windows >=0.1.0.3
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,
Expand Down
19 changes: 9 additions & 10 deletions ghcup.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -236,9 +236,9 @@ library
, unix ^>=2.7
, unix-bytestring ^>=0.3.7.3

if (flag(tui) && !os(windows))
if flag(tui)
cpp-options: -DBRICK
build-depends: vty ^>=5.39
build-depends: vty ^>=6.0

library ghcup-optparse
import: app-common-depends
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -320,14 +320,13 @@ 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 ^>=1.5
, brick ^>=2.1
, transformers ^>=0.5
, unix ^>=2.7
, vty ^>=5.39
, vty ^>=6.0

if os(windows)
cpp-options: -DIS_WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion lib/GHCup/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions scripts/bootstrap/bootstrap-haskell
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tool> <version>"
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\""
Expand Down
Loading