Skip to content

Commit

Permalink
Notify the user that an executable got symlinked
Browse files Browse the repository at this point in the history
Before there wasn't much feedback. Most times the only thing that got
printed was "Up to date".
  • Loading branch information
fgaz committed Mar 6, 2018
1 parent 1c0db3f commit 5e106be
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cabal-install/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import Distribution.Types.UnqualComponentName
import Distribution.Verbosity
( Verbosity, normal )
import Distribution.Simple.Utils
( wrapText, die', withTempDirectory, createDirectoryIfMissingVerbose )
( wrapText, die', notice
, withTempDirectory, createDirectoryIfMissingVerbose )

import qualified Data.Map as Map
import System.Directory ( getTemporaryDirectory, makeAbsolute )
Expand Down Expand Up @@ -195,7 +196,7 @@ installAction (configFlags, configExFlags, installFlags, haddockFlags)
$ projectConfigBuildOnly
$ projectConfig $ baseCtx
createDirectoryIfMissingVerbose verbosity False symlinkBindir
traverse_ (symlinkBuiltPackage mkPkgBinDir symlinkBindir)
traverse_ (symlinkBuiltPackage verbosity mkPkgBinDir symlinkBindir)
$ Map.toList $ targetsMap buildCtx
runProjectPostBuildPhase verbosity baseCtx buildCtx buildOutcomes
where
Expand All @@ -213,22 +214,24 @@ disableTestsBenchsByDefault configFlags =
, configBenchmarks = Flag False <> configBenchmarks configFlags }

-- | Symlink every exe from a package from the store to a given location
symlinkBuiltPackage :: (UnitId -> FilePath) -- ^ A function to get an UnitId's
symlinkBuiltPackage :: Verbosity
-> (UnitId -> FilePath) -- ^ A function to get an UnitId's
-- store directory
-> FilePath -- ^ Where to put the symlink
-> ( UnitId
, [(ComponentTarget, [TargetSelector])] )
-> IO ()
symlinkBuiltPackage mkSourceBinDir destDir (pkg, components) =
traverse_ (symlinkBuiltExe (mkSourceBinDir pkg) destDir) exes
symlinkBuiltPackage verbosity mkSourceBinDir destDir (pkg, components) =
traverse_ (symlinkBuiltExe verbosity (mkSourceBinDir pkg) destDir) exes
where
exes = catMaybes $ (exeMaybe . fst) <$> components
exeMaybe (ComponentTarget (CExeName exe) _) = Just exe
exeMaybe _ = Nothing

-- | Symlink a specific exe.
symlinkBuiltExe :: FilePath -> FilePath -> UnqualComponentName -> IO Bool
symlinkBuiltExe sourceDir destDir exe =
symlinkBuiltExe :: Verbosity -> FilePath -> FilePath -> UnqualComponentName -> IO Bool
symlinkBuiltExe verbosity sourceDir destDir exe = do
notice verbosity $ "Symlinking " ++ unUnqualComponentName exe
symlinkBinary
destDir
sourceDir
Expand Down

0 comments on commit 5e106be

Please sign in to comment.