@@ -161,7 +161,7 @@ import Distribution.Types.UnqualComponentName
161161
162162import Distribution.Solver.Types.OptionalStanza
163163
164- import Control.Exception (assert , handle )
164+ import Control.Exception (assert )
165165import qualified Data.List.NonEmpty as NE
166166import qualified Data.Map as Map
167167import qualified Data.Set as Set
@@ -192,8 +192,8 @@ import Distribution.Simple.Utils
192192 , notice
193193 , noticeNoWrap
194194 , ordNub
195- , warn , die'
196- , installExecutableFile
195+ , warn
196+ , installExecutableFile , infoNoWrap
197197 )
198198import Distribution.Types.Flag
199199 ( FlagAssignment
@@ -532,22 +532,24 @@ installExecutables
532532 ProjectBaseContext {distDirLayout}
533533 ProjectBuildContext {elaboratedPlanOriginal, elaboratedShared, targetsMap}
534534 postBuildStatus =
535- for_ (Map. toList targetsMap) $ \ (key@ (WithStage stage _unitId), targets) -> do
536- guard $ stage == Stage. Host
537- guard $ key `Set.member` packagesDefinitelyUpToDate postBuildStatus
538- case InstallPlan. lookup elaboratedPlanOriginal key of
539- Nothing -> die' verbosity " target missing from the plan"
540- Just (InstallPlan. PreExisting _) -> return ()
541- Just (InstallPlan. Installed _) -> return ()
542- Just (InstallPlan. Configured elab) -> do
543- for_ targets $ \ case
544- (ComponentTarget (CExeName cname) _subtarget, _targetSelectors) -> do
545- let exe = unUnqualComponentName cname
546- dir = binDirectoryFor distDirLayout elaboratedShared elab exe
547- handle (\ (e :: IOException ) -> do putStrLn " Error copying executable files:" ; print e) $ do
548- -- Copy the executable to the dist/bin directory
549- installExecutableFile verbosity (dir </> exe) (distBinDirectory distDirLayout </> exe)
550- _ -> return () -- nothing to do for non-executables
535+ unless (null srcdst) $ do
536+ infoNoWrap verbosity $ " Copying executables to " <> bindir
537+ -- Create the bin directory if it does not exist
538+ createDirectoryIfMissingVerbose verbosity True bindir
539+ -- Install the executables
540+ for_ srcdst $ \ (exe, src) -> do
541+ installExecutableFile verbosity src (bindir </> exe)
542+ where
543+ bindir = distBinDirectory distDirLayout
544+ srcdst = [ (exe, dir </> exe)
545+ | (pkg, targets) <- Map. toList targetsMap
546+ , stageOf pkg == Stage. Host
547+ , pkg `Set.member` packagesDefinitelyUpToDate postBuildStatus
548+ , Just (InstallPlan. Configured elab) <- [InstallPlan. lookup elaboratedPlanOriginal pkg]
549+ , (ComponentTarget (CExeName cname) _subtarget, _targetSelectors) <- targets
550+ , let exe = unUnqualComponentName cname
551+ , let dir = binDirectoryFor distDirLayout elaboratedShared elab exe
552+ ]
551553
552554-- Note that it is a deliberate design choice that the 'buildTargets' is
553555-- not passed to phase 1, and the various bits of input config is not
0 commit comments