Skip to content

Commit

Permalink
print out dependency build failure during cabal build (fix haskell#5974
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses4ever committed Jul 18, 2022
1 parent 207d4ee commit fb97925
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defaultBuildFlags = BuildFlags
--
buildAction :: NixStyleFlags BuildFlags -> [String] -> GlobalFlags -> IO ()
buildAction flags@NixStyleFlags { extraFlags = buildFlags, ..} targetStrings globalFlags
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags BuildCommand $ \targetCtx ctx targetSelectors -> do
-- TODO: This flags defaults business is ugly
let onlyConfigure = fromFlag (buildOnlyConfigure defaultBuildFlags
<> buildOnlyConfigure buildFlags)
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/CmdHaddockProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import qualified Distribution.Client.NixStyleOptions as NixStyleOptions
import Distribution.Client.ProjectOrchestration
(AvailableTarget(..)
,AvailableTargetStatus(..)
,CurrentCommand(..)
,ProjectBaseContext(..)
,ProjectBuildContext(..)
,TargetSelector(..)
Expand Down Expand Up @@ -141,7 +142,7 @@ haddockProjectAction flags _extraArgs globalFlags = do
-- we need.
--

withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags $ \targetCtx ctx targetSelectors -> do
withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags HaddockCommand $ \targetCtx ctx targetSelectors -> do
baseCtx <- case targetCtx of
ProjectContext -> return ctx
GlobalContext -> return ctx
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdListBin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ listbinAction flags@NixStyleFlags{..} args globalFlags = do
_ -> die' verbosity "One target is required, given multiple"

-- configure and elaborate target selectors
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags $ \targetCtx ctx targetSelectors -> do
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
baseCtx <- case targetCtx of
ProjectContext -> return ctx
GlobalContext -> return ctx
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdRepl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ replCommand = Client.installCommand {
--
replAction :: NixStyleFlags (ReplOptions, EnvFlags) -> [String] -> GlobalFlags -> IO ()
replAction flags@NixStyleFlags { extraFlags = (replOpts, envFlags), ..} targetStrings globalFlags
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags ReplCommand $ \targetCtx ctx targetSelectors -> do
when (buildSettingOnlyDeps (buildSettings ctx)) $
die' verbosity $ "The repl command does not support '--only-dependencies'. "
++ "You may wish to use 'build --only-dependencies' and then "
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdRun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ runCommand = CommandUI
--
runAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
runAction flags@NixStyleFlags {..} targetAndArgs globalFlags
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
(baseCtx, defaultVerbosity) <- case targetCtx of
ProjectContext -> return (ctx, normal)
GlobalContext -> return (ctx, normal)
Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ import System.Posix.Signals (sigKILL, sigSEGV)

-- | Tracks what command is being executed, because we need to hide this somewhere
-- for cases that need special handling (usually for error reporting).
data CurrentCommand = InstallCommand | HaddockCommand | OtherCommand
data CurrentCommand = InstallCommand | HaddockCommand | BuildCommand | ReplCommand | OtherCommand
deriving (Show, Eq)

-- | This holds the context of a project prior to solving: the content of the
Expand Down Expand Up @@ -1153,7 +1153,7 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes
, [pkg] <- rootpkgs
, installedUnitId pkg == pkgid
, isFailureSelfExplanatory (buildFailureReason failure)
, currentCommand /= InstallCommand
, not $ currentCommand `elem` [InstallCommand, BuildCommand, ReplCommand]
= True
| otherwise
= False
Expand Down
7 changes: 4 additions & 3 deletions cabal-install/src/Distribution/Client/ScriptUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ withContextAndSelectors
-> NixStyleFlags a -- ^ Command line flags
-> [String] -- ^ Target strings or a script and args.
-> GlobalFlags -- ^ Global flags.
-> CurrentCommand -- ^ Current Command (usually for error reporting).
-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
-- ^ The body of your command action.
-> IO b
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags act
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags cmd act
= withTemporaryTempDirectory $ \mkTmpDir -> do
(tc, ctx) <- withProjectOrGlobalConfig verbosity ignoreProject globalConfigFlag with (without mkTmpDir)

Expand Down Expand Up @@ -217,11 +218,11 @@ withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings gl
defaultTarget = [TargetPackage TargetExplicitNamed [fakePackageId] Nothing]

with = do
ctx <- establishProjectBaseContext verbosity cliConfig OtherCommand
ctx <- establishProjectBaseContext verbosity cliConfig cmd
return (ProjectContext, ctx)
without mkDir globalConfig = do
distDirLayout <- establishDummyDistDirLayout verbosity (globalConfig <> cliConfig) =<< mkDir
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] OtherCommand
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] cmd
return (GlobalContext, ctx)
scriptOrError script err = do
exists <- doesFileExist script
Expand Down

0 comments on commit fb97925

Please sign in to comment.