From 50264de9e1e0ab7ec59a3cb7721d7209726bb105 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 12 Jan 2025 22:03:17 +0800 Subject: [PATCH 1/2] More beef for debug-info --- lib-opt/GHCup/OptParse/DInfo.hs | 27 ++++++++++++++++++++------- lib/GHCup.hs | 8 +++----- lib/GHCup/Types.hs | 11 +++++------ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib-opt/GHCup/OptParse/DInfo.hs b/lib-opt/GHCup/OptParse/DInfo.hs index 6310d689..0337c752 100644 --- a/lib-opt/GHCup/OptParse/DInfo.hs +++ b/lib-opt/GHCup/OptParse/DInfo.hs @@ -29,11 +29,14 @@ import Control.Monad.Reader import Control.Monad.Trans.Resource import Data.Functor import Data.Maybe +import Data.List ( intercalate ) import Data.Variant.Excepts import Options.Applicative hiding ( style ) import Prelude hiding ( appendFile ) import System.Exit +import System.FilePath import Text.PrettyPrint.HughesPJClass ( prettyShow ) +import URI.ByteString (serializeURIRef') import qualified Data.Text as T import Control.Exception.Safe (MonadMask) @@ -63,15 +66,25 @@ describe_result = $( LitE . StringL <$> prettyDebugInfo :: DebugInfo -> String -prettyDebugInfo DebugInfo {..} = "Debug Info" <> "\n" <> - "==========" <> "\n" <> - "GHCup base dir: " <> diBaseDir <> "\n" <> - "GHCup bin dir: " <> diBinDir <> "\n" <> - "GHCup GHC directory: " <> diGHCDir <> "\n" <> - "GHCup cache directory: " <> diCacheDir <> "\n" <> +prettyDebugInfo DebugInfo { diDirs = Dirs { .. }, ..} = + "===== Main ======" <> "\n" <> "Architecture: " <> prettyShow diArch <> "\n" <> "Platform: " <> prettyShow diPlatform <> "\n" <> - "Version: " <> describe_result + "GHCup Version: " <> describe_result <> "\n" <> + "===== Directories ======" <> "\n" <> + "base: " <> fromGHCupPath baseDir <> "\n" <> + "bin: " <> binDir <> "\n" <> + "GHCs: " <> (fromGHCupPath baseDir "ghc") <> "\n" <> + "cache: " <> fromGHCupPath cacheDir <> "\n" <> + "logs: " <> fromGHCupPath logsDir <> "\n" <> + "config: " <> fromGHCupPath confDir <> "\n" <> + "db: " <> fromGHCupPath dbDir <> "\n" <> + "recycle: " <> fromGHCupPath recycleDir <> "\n" <> + "temp: " <> fromGHCupPath tmpDir <> "\n" <> + "msys2: " <> msys2Dir <> "\n" <> + "\n===== Metadata ======\n" <> + intercalate "\n" ((\(c, u) -> (T.unpack . channelAliasText) c <> ": " <> (T.unpack . decUTF8Safe . serializeURIRef') u) <$> diChannels) + diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 4ea4bf23..10198e64 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -258,11 +258,9 @@ getDebugInfo :: ( Alternative m m DebugInfo getDebugInfo = do - Dirs {..} <- lift getDirs - let diBaseDir = fromGHCupPath baseDir - let diBinDir = binDir - diGHCDir <- fromGHCupPath <$> lift ghcupGHCBaseDir - let diCacheDir = fromGHCupPath cacheDir + diDirs <- lift getDirs + let diChannels = fmap (\c -> (c, channelURL c)) [minBound..maxBound] + let diShimGenURL = shimGenURL diArch <- lE getArchitecture diPlatform <- liftE getPlatform pure $ DebugInfo { .. } diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index 7f6e6aaf..befbb6da 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -666,12 +666,11 @@ data GPGSetting = GPGStrict instance NFData GPGSetting data DebugInfo = DebugInfo - { diBaseDir :: FilePath - , diBinDir :: FilePath - , diGHCDir :: FilePath - , diCacheDir :: FilePath - , diArch :: Architecture - , diPlatform :: PlatformResult + { diDirs :: Dirs + , diArch :: Architecture + , diPlatform :: PlatformResult + , diChannels :: [(ChannelAlias, URI)] + , diShimGenURL :: URI } deriving Show From 905df40cfdf4638e5d8339bf0c76da6bfa053844 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 12 Jan 2025 22:05:39 +0800 Subject: [PATCH 2/2] Hide windows stuff on unix --- lib-opt/GHCup/OptParse/DInfo.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib-opt/GHCup/OptParse/DInfo.hs b/lib-opt/GHCup/OptParse/DInfo.hs index 0337c752..e00da1a4 100644 --- a/lib-opt/GHCup/OptParse/DInfo.hs +++ b/lib-opt/GHCup/OptParse/DInfo.hs @@ -79,9 +79,9 @@ prettyDebugInfo DebugInfo { diDirs = Dirs { .. }, ..} = "logs: " <> fromGHCupPath logsDir <> "\n" <> "config: " <> fromGHCupPath confDir <> "\n" <> "db: " <> fromGHCupPath dbDir <> "\n" <> - "recycle: " <> fromGHCupPath recycleDir <> "\n" <> + (if isWindows then ("recycle: " <> fromGHCupPath recycleDir <> "\n") else mempty) <> "temp: " <> fromGHCupPath tmpDir <> "\n" <> - "msys2: " <> msys2Dir <> "\n" <> + (if isWindows then ("msys2: " <> msys2Dir <> "\n") else mempty) <> "\n===== Metadata ======\n" <> intercalate "\n" ((\(c, u) -> (T.unpack . channelAliasText) c <> ": " <> (T.unpack . decUTF8Safe . serializeURIRef') u) <$> diChannels)