Skip to content

Commit 57d796e

Browse files
committed
add --version-full and compiler info
This may count as "significant" since it's a new command line option, but it's deliberately out of the way.
1 parent 012e9da commit 57d796e

8 files changed

Lines changed: 59 additions & 1 deletion

File tree

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ library
130130
Distribution.Client.Compat.Orphans
131131
Distribution.Client.Compat.Prelude
132132
Distribution.Client.Compat.Semaphore
133+
Distribution.Client.Compat.SysInfo
133134
Distribution.Client.Compat.Tar
134135
Distribution.Client.Config
135136
Distribution.Client.Configure
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{-# LANGUAGE CPP #-}
2+
3+
module Distribution.Client.Compat.SysInfo
4+
( fullCompilerVersion
5+
) where
6+
7+
import Data.Version (Version)
8+
import qualified System.Info as SI
9+
10+
fullCompilerVersion :: Version
11+
#if MIN_VERSION_base(4,15,0)
12+
fullCompilerVersion = SI.fullCompilerVersion
13+
#else
14+
fullCompilerVersion = SI.compilerVersion
15+
#endif

cabal-install/src/Distribution/Client/Config.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ instance Semigroup SavedConfig where
358358
combinedSavedGlobalFlags =
359359
GlobalFlags
360360
{ globalVersion = combine globalVersion
361+
, globalFullVersion = combine globalFullVersion
361362
, globalNumericVersion = combine globalNumericVersion
362363
, globalConfigFile = combine globalConfigFile
363364
, globalConstraintsFile = combine globalConstraintsFile

cabal-install/src/Distribution/Client/GlobalFlags.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import qualified Hackage.Security.Util.Pretty as Sec
8181
-- | Flags that apply at the top level, not to any sub-command.
8282
data GlobalFlags = GlobalFlags
8383
{ globalVersion :: Flag Bool
84+
, globalFullVersion :: Flag Bool
8485
, globalNumericVersion :: Flag Bool
8586
, globalConfigFile :: Flag FilePath
8687
, globalConstraintsFile :: Flag FilePath
@@ -103,6 +104,7 @@ defaultGlobalFlags :: GlobalFlags
103104
defaultGlobalFlags =
104105
GlobalFlags
105106
{ globalVersion = Flag False
107+
, globalFullVersion = Flag False
106108
, globalNumericVersion = Flag False
107109
, globalConfigFile = mempty
108110
, globalConstraintsFile = mempty

cabal-install/src/Distribution/Client/Main.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ import Distribution.Client.Utils
170170
, relaxEncodingErrors
171171
)
172172
import Distribution.Client.Version
173-
( cabalInstallGitInfo
173+
( cabalInstallCompilerInfo
174+
, cabalInstallGitInfo
174175
, cabalInstallVersion
175176
)
176177

@@ -346,6 +347,8 @@ mainWorker args = do
346347
_
347348
| fromFlagOrDefault False (globalVersion globalFlags) ->
348349
printVersion
350+
| fromFlagOrDefault False (globalFullVersion globalFlags) ->
351+
printFullVersion
349352
| fromFlagOrDefault False (globalNumericVersion globalFlags) ->
350353
printNumericVersion
351354
CommandHelp help -> printCommandHelp help
@@ -415,6 +418,13 @@ mainWorker args = do
415418
printErrors errs = dieNoVerbosity $ intercalate "\n" errs
416419
printNumericVersion = putStrLn $ display cabalInstallVersion
417420
printVersion =
421+
putStrLn $
422+
"cabal-install version "
423+
++ display cabalInstallVersion
424+
++ "\ncompiled using version "
425+
++ display cabalVersion
426+
++ " of the Cabal library "
427+
printFullVersion =
418428
putStrLn $
419429
"cabal-install version "
420430
++ display cabalInstallVersion
@@ -423,6 +433,8 @@ mainWorker args = do
423433
++ display cabalVersion
424434
++ " of the Cabal library "
425435
++ cabalGitInfo'
436+
++ "\nwith "
437+
++ cabalInstallCompilerInfo
426438
where
427439
cabalInstallGitInfo'
428440
| null cabalInstallGitInfo = ""

cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ convertToLegacySharedConfig
984984
globalFlags =
985985
GlobalFlags
986986
{ globalVersion = mempty
987+
, globalFullVersion = mempty
987988
, globalNumericVersion = mempty
988989
, globalConfigFile = projectConfigConfigFile
989990
, globalConstraintsFile = mempty

cabal-install/src/Distribution/Client/Setup.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@ globalCommand commands =
487487
globalVersion
488488
(\v flags -> flags{globalVersion = v})
489489
trueArg
490+
, option
491+
[]
492+
["version-full"]
493+
"Print full version information with git revision (if available) and compiler"
494+
globalFullVersion
495+
(\v flags -> flags{globalFullVersion = v})
496+
trueArg
490497
, option
491498
[]
492499
["numeric-version"]

cabal-install/src/Distribution/Client/Version.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
module Distribution.Client.Version
88
( cabalInstallVersion
99
, cabalInstallGitInfo
10+
, cabalInstallCompilerInfo
1011
) where
1112

13+
import Data.List (intercalate)
14+
import qualified Data.Version as DV
15+
import qualified Distribution.Client.Compat.SysInfo as SIC
1216
import Distribution.Version
17+
import qualified System.Info as SI
1318

1419
import qualified Paths_cabal_install as PackageInfo
1520

@@ -28,6 +33,20 @@ import GitHash
2833
cabalInstallVersion :: Version
2934
cabalInstallVersion = mkVersion' PackageInfo.version
3035

36+
-- |
37+
-- `cabal-install` compiler information.
38+
cabalInstallCompilerInfo :: String
39+
cabalInstallCompilerInfo =
40+
concat
41+
[ SI.compilerName
42+
, " "
43+
, intercalate "." (map show (DV.versionBranch SIC.fullCompilerVersion))
44+
, " on "
45+
, SI.os
46+
, " "
47+
, SI.arch
48+
]
49+
3150
-- |
3251
-- `cabal-install` Git information. Only filled in if built in a Git tree in
3352
-- development mode and Template Haskell is available.

0 commit comments

Comments
 (0)