Skip to content

Commit

Permalink
Merge branch 'issue-1019'
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Mar 11, 2024
2 parents 5d0a7b7 + 065b307 commit e5c941b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cabal.project.release
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ constraints: http-io-streams -brotli,
any.hsc2hs ==0.68.8,
bzlib-conduit >= 0.3.0.3,
bz2 >= 1.0.1.1,
bzlib >= 0.5.2.0
bzlib >= 0.5.2.0,
directory >= 1.3.8.3,
filepath == 1.4.101.0 || == 1.4.300.1 || >= 1.5.2.0

Expand Down
5 changes: 5 additions & 0 deletions lib-opt/GHCup/OptParse/GC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ data GCOptions = GCOptions
, gcHLSNoGHC :: Bool
, gcCache :: Bool
, gcTmp :: Bool
, gcUnset :: Bool
} deriving (Eq, Show)


Expand Down Expand Up @@ -77,6 +78,9 @@ gcP =
<*>
switch
(short 't' <> long "tmpdirs" <> help "Remove tmpdir leftovers")
<*>
switch
(short 'u' <> long "unset" <> help "Remove all tool versions that are not 'set'")



Expand Down Expand Up @@ -134,6 +138,7 @@ gc GCOptions{..} runAppState runLogger = runGC runAppState (do
liftE $ when gcHLSNoGHC rmHLSNoGHC
lift $ when gcCache rmCache
lift $ when gcTmp rmTmp
liftE $ when gcUnset rmUnsetTools
) >>= \case
VRight _ -> do
pure ExitSuccess
Expand Down
20 changes: 20 additions & 0 deletions lib/GHCup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,26 @@ rmOldGHC = do
forM_ ghcs $ \ghc -> when (ghc `elem` oldGHCs) $ rmGHCVer ghc


rmUnsetTools :: ( MonadReader env m
, HasGHCupInfo env
, HasPlatformReq env
, HasDirs env
, HasLog env
, MonadIO m
, MonadFail m
, MonadMask m
, MonadUnliftIO m
)
=> Excepts '[NotInstalled, UninstallFailed] m ()
rmUnsetTools = do
vers <- lift $ listVersions Nothing [ListInstalled True, ListSet False] False True (Nothing, Nothing)
forM_ vers $ \ListResult{..} -> case lTool of
GHC -> liftE $ rmGHCVer (GHCTargetVersion lCross lVer)
HLS -> liftE $ rmHLSVer lVer
Cabal -> liftE $ rmCabalVer lVer
Stack -> liftE $ rmStackVer lVer
GHCup -> pure ()


rmProfilingLibs :: ( MonadReader env m
, HasDirs env
Expand Down
5 changes: 4 additions & 1 deletion test/optparse-test/GCTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defaultOptions =
False
False
False
False

gcCheckList :: [(String, GCOptions)]
gcCheckList =
Expand All @@ -33,7 +34,9 @@ gcCheckList =
, ("gc --cache", defaultOptions{gcCache = True})
, ("gc -t", defaultOptions{gcTmp = True})
, ("gc --tmpdirs", defaultOptions{gcTmp = True})
, ("gc -o -p -s -h -c -t", GCOptions True True True True True True)
, ("gc -u", defaultOptions{gcUnset = True})
, ("gc --unset", defaultOptions{gcUnset = True})
, ("gc -o -p -s -h -c -t -u", GCOptions True True True True True True True)
]

gcParseWith :: [String] -> IO GCOptions
Expand Down

0 comments on commit e5c941b

Please sign in to comment.