Skip to content

Commit c602b66

Browse files
committed
print out dependency build failure during cabal build (fix #5974 #7727)
1 parent a5106be commit c602b66

File tree

12 files changed

+17
-10
lines changed

12 files changed

+17
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ defaultBuildFlags = BuildFlags
101101
--
102102
buildAction :: NixStyleFlags BuildFlags -> [String] -> GlobalFlags -> IO ()
103103
buildAction flags@NixStyleFlags { extraFlags = buildFlags, ..} targetStrings globalFlags
104-
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
104+
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags BuildCommand $ \targetCtx ctx targetSelectors -> do
105105
-- TODO: This flags defaults business is ugly
106106
let onlyConfigure = fromFlag (buildOnlyConfigure defaultBuildFlags
107107
<> buildOnlyConfigure buildFlags)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import qualified Distribution.Client.NixStyleOptions as NixStyleOptions
1919
import Distribution.Client.ProjectOrchestration
2020
(AvailableTarget(..)
2121
,AvailableTargetStatus(..)
22+
,CurrentCommand(..)
2223
,ProjectBaseContext(..)
2324
,ProjectBuildContext(..)
2425
,TargetSelector(..)
@@ -141,7 +142,7 @@ haddockProjectAction flags _extraArgs globalFlags = do
141142
-- we need.
142143
--
143144

144-
withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags $ \targetCtx ctx targetSelectors -> do
145+
withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags HaddockCommand $ \targetCtx ctx targetSelectors -> do
145146
baseCtx <- case targetCtx of
146147
ProjectContext -> return ctx
147148
GlobalContext -> return ctx

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ listbinAction flags@NixStyleFlags{..} args globalFlags = do
7878
_ -> die' verbosity "One target is required, given multiple"
7979

8080
-- configure and elaborate target selectors
81-
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags $ \targetCtx ctx targetSelectors -> do
81+
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
8282
baseCtx <- case targetCtx of
8383
ProjectContext -> return ctx
8484
GlobalContext -> return ctx

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ replCommand = Client.installCommand {
187187
--
188188
replAction :: NixStyleFlags (ReplOptions, EnvFlags) -> [String] -> GlobalFlags -> IO ()
189189
replAction flags@NixStyleFlags { extraFlags = (replOpts, envFlags), ..} targetStrings globalFlags
190-
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
190+
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags ReplCommand $ \targetCtx ctx targetSelectors -> do
191191
when (buildSettingOnlyDeps (buildSettings ctx)) $
192192
die' verbosity $ "The repl command does not support '--only-dependencies'. "
193193
++ "You may wish to use 'build --only-dependencies' and then "

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ runCommand = CommandUI
122122
--
123123
runAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
124124
runAction flags@NixStyleFlags {..} targetAndArgs globalFlags
125-
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags $ \targetCtx ctx targetSelectors -> do
125+
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
126126
(baseCtx, defaultVerbosity) <- case targetCtx of
127127
ProjectContext -> return (ctx, normal)
128128
GlobalContext -> return (ctx, normal)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ import System.Posix.Signals (sigKILL, sigSEGV)
186186

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

192192
-- | This holds the context of a project prior to solving: the content of the
@@ -1152,7 +1152,7 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes
11521152
, [pkg] <- rootpkgs
11531153
, installedUnitId pkg == pkgid
11541154
, isFailureSelfExplanatory (buildFailureReason failure)
1155-
, currentCommand /= InstallCommand
1155+
, currentCommand `notElem` [InstallCommand, BuildCommand, ReplCommand]
11561156
= True
11571157
| otherwise
11581158
= False

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ withContextAndSelectors
171171
-> NixStyleFlags a -- ^ Command line flags
172172
-> [String] -- ^ Target strings or a script and args.
173173
-> GlobalFlags -- ^ Global flags.
174+
-> CurrentCommand -- ^ Current Command (usually for error reporting).
174175
-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
175176
-- ^ The body of your command action.
176177
-> IO b
177-
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags act
178+
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags cmd act
178179
= withTemporaryTempDirectory $ \mkTmpDir -> do
179180
(tc, ctx) <- withProjectOrGlobalConfig verbosity ignoreProject globalConfigFlag with (without mkTmpDir)
180181

@@ -209,11 +210,11 @@ withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings gl
209210
defaultTarget = [TargetPackage TargetExplicitNamed [fakePackageId] Nothing]
210211

211212
with = do
212-
ctx <- establishProjectBaseContext verbosity cliConfig OtherCommand
213+
ctx <- establishProjectBaseContext verbosity cliConfig cmd
213214
return (ProjectContext, ctx)
214215
without mkDir globalConfig = do
215216
distDirLayout <- establishDummyDistDirLayout verbosity (globalConfig <> cliConfig) =<< mkDir
216-
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] OtherCommand
217+
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] cmd
217218
return (GlobalContext, ctx)
218219
scriptOrError script err = do
219220
exists <- doesFileExist script

cabal-testsuite/PackageTests/CustomWithoutCabal/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Resolving dependencies...
33
Build profile: -w ghc-<GHCVER> -O1
44
In order, the following will be built:
55
- custom-setup-without-cabal-1.0 (lib:custom-setup-without-cabal) (first run)
6+
Error: cabal: Failed to build custom-setup-without-cabal-1.0-inplace. The failure occurred during the configure step.

cabal-testsuite/PackageTests/CustomWithoutCabalDefaultMain/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Resolving dependencies...
33
Build profile: -w ghc-<GHCVER> -O1
44
In order, the following will be built:
55
- custom-setup-without-cabal-defaultMain-1.0 (lib:custom-setup-without-cabal-defaultMain) (first run)
6+
Error: cabal: Failed to build custom-setup-without-cabal-defaultMain-1.0-inplace. The failure occurred during the configure step.

cabal-testsuite/PackageTests/NewBuild/MonitorCabalFiles/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ In order, the following will be built:
66
Configuring executable 'q' for q-0.1.0.0..
77
Preprocessing executable 'q' for q-0.1.0.0..
88
Building executable 'q' for q-0.1.0.0..
9+
Error: cabal: Failed to build q-0.1.0.0-inplace-q.
910
# cabal v2-build
1011
Resolving dependencies...
1112
Build profile: -w ghc-<GHCVER> -O1

cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ In order, the following will be built:
66
Configuring library for example-1.0..
77
Preprocessing library for example-1.0..
88
Building library for example-1.0..
9+
Error: cabal: Failed to build example-1.0-inplace.
910
# cabal v2-haddock
1011
Build profile: -w ghc-<GHCVER> -O1
1112
In order, the following will be built:

cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Building library for CompileFail-0.1.0.0..
1010
Configuring test suite 'CompileFail-test' for CompileFail-0.1.0.0..
1111
Preprocessing test suite 'CompileFail-test' for CompileFail-0.1.0.0..
1212
Building test suite 'CompileFail-test' for CompileFail-0.1.0.0..
13+
Error: cabal: Failed to build CompileFail-0.1.0.0-inplace-CompileFail-test.
1314
# cabal build
1415
Build profile: -w ghc-<GHCVER> -O1
1516
In order, the following will be built:

0 commit comments

Comments
 (0)