Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
6309f825
Commit
6309f825
authored
Aug 11, 2016
by
Duncan Coutts
Committed by
GitHub
Aug 11, 2016
Browse files
Merge pull request #3686 from dcoutts/new-build-exception-handling
Rework new-build failure reporting to include build logs
parents
715b0380
a9247b15
Changes
12
Hide whitespace changes
Inline
Side-by-side
cabal-install/Distribution/Client/BuildReports/Anonymous.hs
View file @
6309f825
...
...
@@ -27,7 +27,7 @@ module Distribution.Client.BuildReports.Anonymous (
)
where
import
qualified
Distribution.Client.Types
as
BR
(
Build
Result
,
BuildFailure
(
..
),
Build
Success
(
..
)
(
Build
Outcome
,
BuildFailure
(
..
),
Build
Result
(
..
)
,
DocsResult
(
..
),
TestsResult
(
..
)
)
import
Distribution.Client.Utils
(
mergeBy
,
MergeResult
(
..
)
)
...
...
@@ -120,7 +120,7 @@ data Outcome = NotTried | Failed | Ok
deriving
Eq
new
::
OS
->
Arch
->
CompilerId
->
PackageIdentifier
->
FlagAssignment
->
[
PackageIdentifier
]
->
BR
.
Build
Result
->
BuildReport
->
[
PackageIdentifier
]
->
BR
.
Build
Outcome
->
BuildReport
new
os'
arch'
comp
pkgid
flags
deps
result
=
BuildReport
{
package
=
pkgid
,
...
...
@@ -145,17 +145,17 @@ new os' arch' comp pkgid flags deps result =
Left
(
BR
.
BuildFailed
_
)
->
BuildFailed
Left
(
BR
.
TestsFailed
_
)
->
TestsFailed
Left
(
BR
.
InstallFailed
_
)
->
InstallFailed
Right
(
BR
.
Build
Ok
_
_
_
)
->
InstallOk
Right
(
BR
.
Build
Result
_
_
_
)
->
InstallOk
convertDocsOutcome
=
case
result
of
Left
_
->
NotTried
Right
(
BR
.
Build
Ok
BR
.
DocsNotTried
_
_
)
->
NotTried
Right
(
BR
.
Build
Ok
BR
.
DocsFailed
_
_
)
->
Failed
Right
(
BR
.
Build
Ok
BR
.
DocsOk
_
_
)
->
Ok
Left
_
->
NotTried
Right
(
BR
.
Build
Result
BR
.
DocsNotTried
_
_
)
->
NotTried
Right
(
BR
.
Build
Result
BR
.
DocsFailed
_
_
)
->
Failed
Right
(
BR
.
Build
Result
BR
.
DocsOk
_
_
)
->
Ok
convertTestsOutcome
=
case
result
of
Left
(
BR
.
TestsFailed
_
)
->
Failed
Left
_
->
NotTried
Right
(
BR
.
Build
Ok
_
BR
.
TestsNotTried
_
)
->
NotTried
Right
(
BR
.
Build
Ok
_
BR
.
TestsOk
_
)
->
Ok
Left
(
BR
.
TestsFailed
_
)
->
Failed
Left
_
->
NotTried
Right
(
BR
.
Build
Result
_
BR
.
TestsNotTried
_
)
->
NotTried
Right
(
BR
.
Build
Result
_
BR
.
TestsOk
_
)
->
Ok
cabalInstallID
::
PackageIdentifier
cabalInstallID
=
...
...
cabal-install/Distribution/Client/BuildReports/Storage.hs
View file @
6309f825
...
...
@@ -123,19 +123,19 @@ storeLocal cinfo templates reports platform = sequence_
fromInstallPlan
::
Platform
->
CompilerId
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
[(
BuildReport
,
Maybe
Repo
)]
fromInstallPlan
platform
comp
plan
build
Result
s
=
fromInstallPlan
platform
comp
plan
build
Outcome
s
=
catMaybes
.
map
(
\
pkg
->
fromPlanPackage
platform
comp
pkg
(
InstallPlan
.
lookupBuild
Result
pkg
build
Result
s
))
(
InstallPlan
.
lookupBuild
Outcome
pkg
build
Outcome
s
))
.
InstallPlan
.
toList
$
plan
fromPlanPackage
::
Platform
->
CompilerId
->
InstallPlan
.
PlanPackage
->
Maybe
Build
Result
->
Maybe
Build
Outcome
->
Maybe
(
BuildReport
,
Maybe
Repo
)
fromPlanPackage
(
Platform
arch
os
)
comp
(
InstallPlan
.
Configured
(
ConfiguredPackage
_
srcPkg
flags
_
deps
))
...
...
cabal-install/Distribution/Client/CmdBuild.hs
View file @
6309f825
...
...
@@ -55,7 +55,7 @@ buildAction (configFlags, configExFlags, installFlags, haddockFlags)
unless
(
buildSettingDryRun
buildSettings
)
$
do
buildResults
<-
runProjectBuildPhase
verbosity
buildCtx
reportBuildFailures
elaboratedPlan
buildResults
reportBuildFailures
verbosity
elaboratedPlan
buildResults
where
verbosity
=
fromFlagOrDefault
normal
(
configVerbosity
configFlags
)
...
...
cabal-install/Distribution/Client/CmdRepl.hs
View file @
6309f825
...
...
@@ -59,7 +59,7 @@ replAction (configFlags, configExFlags, installFlags, haddockFlags)
unless
(
buildSettingDryRun
buildSettings
)
$
do
buildResults
<-
runProjectBuildPhase
verbosity
buildCtx
reportBuildFailures
elaboratedPlan
buildResults
reportBuildFailures
verbosity
elaboratedPlan
buildResults
where
verbosity
=
fromFlagOrDefault
normal
(
configVerbosity
configFlags
)
...
...
cabal-install/Distribution/Client/Install.hs
View file @
6309f825
...
...
@@ -339,9 +339,9 @@ processInstallPlan verbosity
installFlags
pkgSpecifiers
unless
(
dryRun
||
nothingToInstall
)
$
do
build
Result
s
<-
performInstallations
verbosity
args
installedPkgIndex
installPlan
postInstallActions
verbosity
args
userTargets
installPlan
build
Result
s
build
Outcome
s
<-
performInstallations
verbosity
args
installedPkgIndex
installPlan
postInstallActions
verbosity
args
userTargets
installPlan
build
Outcome
s
where
installPlan
=
InstallPlan
.
configureInstallPlan
installPlan0
dryRun
=
fromFlag
(
installDryRun
installFlags
)
...
...
@@ -808,12 +808,12 @@ postInstallActions :: Verbosity
->
InstallArgs
->
[
UserTarget
]
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
IO
()
postInstallActions
verbosity
(
packageDBs
,
_
,
comp
,
platform
,
conf
,
useSandbox
,
mSandboxPkgInfo
,
globalFlags
,
configFlags
,
_
,
installFlags
,
_
)
targets
installPlan
build
Result
s
=
do
targets
installPlan
build
Outcome
s
=
do
unless
oneShot
$
World
.
insert
verbosity
worldFile
...
...
@@ -822,7 +822,7 @@ postInstallActions verbosity
|
UserTargetNamed
dep
<-
targets
]
let
buildReports
=
BuildReports
.
fromInstallPlan
platform
(
compilerId
comp
)
installPlan
build
Result
s
installPlan
build
Outcome
s
BuildReports
.
storeLocal
(
compilerInfo
comp
)
(
fromNubList
$
installSummaryFile
installFlags
)
buildReports
...
...
@@ -833,15 +833,15 @@ postInstallActions verbosity
storeDetailedBuildReports
verbosity
logsDir
buildReports
regenerateHaddockIndex
verbosity
packageDBs
comp
platform
conf
useSandbox
configFlags
installFlags
build
Result
s
configFlags
installFlags
build
Outcome
s
symlinkBinaries
verbosity
platform
comp
configFlags
installFlags
installPlan
build
Result
s
installPlan
build
Outcome
s
printBuildFailures
build
Result
s
printBuildFailures
build
Outcome
s
updateSandboxTimestampsFile
useSandbox
mSandboxPkgInfo
comp
platform
installPlan
build
Result
s
comp
platform
installPlan
build
Outcome
s
where
reportingLevel
=
fromFlag
(
installBuildReports
installFlags
)
...
...
@@ -891,10 +891,10 @@ regenerateHaddockIndex :: Verbosity
->
UseSandbox
->
ConfigFlags
->
InstallFlags
->
Build
Result
s
->
Build
Outcome
s
->
IO
()
regenerateHaddockIndex
verbosity
packageDBs
comp
platform
conf
useSandbox
configFlags
installFlags
build
Result
s
configFlags
installFlags
build
Outcome
s
|
haddockIndexFileIsRequested
&&
shouldRegenerateHaddockIndex
=
do
defaultDirs
<-
InstallDirs
.
defaultInstallDirs
...
...
@@ -922,11 +922,11 @@ regenerateHaddockIndex verbosity packageDBs comp platform conf useSandbox
-- #1337), we don't do it for global installs or special cases where we're
-- installing into a specific db.
shouldRegenerateHaddockIndex
=
(
isUseSandbox
useSandbox
||
normalUserInstall
)
&&
someDocsWereInstalled
build
Result
s
&&
someDocsWereInstalled
build
Outcome
s
where
someDocsWereInstalled
=
any
installedDocs
.
Map
.
elems
installedDocs
(
Right
(
Build
Ok
DocsOk
_
_
))
=
True
installedDocs
_
=
False
installedDocs
(
Right
(
Build
Result
DocsOk
_
_
))
=
True
installedDocs
_
=
False
normalUserInstall
=
(
UserPackageDB
`
elem
`
packageDBs
)
&&
all
(
not
.
isSpecificPackageDB
)
packageDBs
...
...
@@ -951,13 +951,13 @@ symlinkBinaries :: Verbosity
->
ConfigFlags
->
InstallFlags
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
IO
()
symlinkBinaries
verbosity
platform
comp
configFlags
installFlags
plan
build
Result
s
=
do
plan
build
Outcome
s
=
do
failed
<-
InstallSymlink
.
symlinkBinaries
platform
comp
configFlags
installFlags
plan
build
Result
s
plan
build
Outcome
s
case
failed
of
[]
->
return
()
[(
_
,
exe
,
path
)]
->
...
...
@@ -979,10 +979,10 @@ symlinkBinaries verbosity platform comp configFlags installFlags
bindir
=
fromFlag
(
installSymlinkBinDir
installFlags
)
printBuildFailures
::
Build
Result
s
->
IO
()
printBuildFailures
build
Result
s
=
printBuildFailures
::
Build
Outcome
s
->
IO
()
printBuildFailures
build
Outcome
s
=
case
[
(
pkgid
,
failure
)
|
(
pkgid
,
Left
failure
)
<-
Map
.
toList
build
Result
s
]
of
|
(
pkgid
,
Left
failure
)
<-
Map
.
toList
build
Outcome
s
]
of
[]
->
return
()
failed
->
die
.
unlines
$
"Error: some packages failed to install:"
...
...
@@ -1025,16 +1025,16 @@ printBuildFailures buildResults =
updateSandboxTimestampsFile
::
UseSandbox
->
Maybe
SandboxPackageInfo
->
Compiler
->
Platform
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
IO
()
updateSandboxTimestampsFile
(
UseSandbox
sandboxDir
)
(
Just
(
SandboxPackageInfo
_
_
_
allAddSourceDeps
))
comp
platform
installPlan
build
Result
s
=
comp
platform
installPlan
build
Outcome
s
=
withUpdateTimestamps
sandboxDir
(
compilerId
comp
)
platform
$
\
_
->
do
let
allInstalled
=
[
pkg
|
InstallPlan
.
Configured
pkg
<-
InstallPlan
.
toList
installPlan
,
case
InstallPlan
.
lookupBuild
Result
pkg
build
Result
s
of
,
case
InstallPlan
.
lookupBuild
Outcome
pkg
build
Outcome
s
of
Just
(
Right
_success
)
->
True
_
->
False
]
...
...
@@ -1062,7 +1062,7 @@ performInstallations :: Verbosity
->
InstallArgs
->
InstalledPackageIndex
->
InstallPlan
->
IO
Build
Result
s
->
IO
Build
Outcome
s
performInstallations
verbosity
(
packageDBs
,
repoCtxt
,
comp
,
platform
,
conf
,
useSandbox
,
_
,
globalFlags
,
configFlags
,
configExFlags
,
installFlags
,
haddockFlags
)
...
...
@@ -1170,26 +1170,26 @@ performInstallations verbosity
executeInstallPlan
::
Verbosity
->
JobControl
IO
(
UnitId
,
Build
Result
)
->
JobControl
IO
(
UnitId
,
Build
Outcome
)
->
Bool
->
UseLogFile
->
InstallPlan
->
(
ReadyPackage
->
IO
Build
Result
)
->
IO
Build
Result
s
->
(
ReadyPackage
->
IO
Build
Outcome
)
->
IO
Build
Outcome
s
executeInstallPlan
verbosity
jobCtl
keepGoing
useLogFile
plan0
installPkg
=
InstallPlan
.
execute
jobCtl
keepGoing
depsFailure
plan0
$
\
pkg
->
do
build
Result
<-
installPkg
pkg
printBuildResult
(
packageId
pkg
)
(
installedPackageId
pkg
)
build
Result
return
build
Result
build
Outcome
<-
installPkg
pkg
printBuildResult
(
packageId
pkg
)
(
installedPackageId
pkg
)
build
Outcome
return
build
Outcome
where
depsFailure
=
DependentFailed
.
packageId
-- Print build log if something went wrong, and 'Installed $PKGID'
-- otherwise.
printBuildResult
::
PackageId
->
UnitId
->
Build
Result
->
IO
()
printBuildResult
pkgid
ipid
build
Result
=
case
build
Result
of
printBuildResult
::
PackageId
->
UnitId
->
Build
Outcome
->
IO
()
printBuildResult
pkgid
ipid
build
Outcome
=
case
build
Outcome
of
(
Right
_
)
->
notice
verbosity
$
"Installed "
++
display
pkgid
(
Left
_
)
->
do
notice
verbosity
$
"Failed to install "
++
display
pkgid
...
...
@@ -1252,8 +1252,8 @@ fetchSourcePackage
->
RepoContext
->
JobLimit
->
UnresolvedPkgLoc
->
(
ResolvedPkgLoc
->
IO
Build
Result
)
->
IO
Build
Result
->
(
ResolvedPkgLoc
->
IO
Build
Outcome
)
->
IO
Build
Outcome
fetchSourcePackage
verbosity
repoCtxt
fetchLimit
src
installPkg
=
do
fetched
<-
checkFetched
src
case
fetched
of
...
...
@@ -1267,8 +1267,8 @@ fetchSourcePackage verbosity repoCtxt fetchLimit src installPkg = do
installLocalPackage
::
Verbosity
->
PackageIdentifier
->
ResolvedPkgLoc
->
FilePath
->
(
Maybe
FilePath
->
IO
Build
Result
)
->
IO
Build
Result
->
(
Maybe
FilePath
->
IO
Build
Outcome
)
->
IO
Build
Outcome
installLocalPackage
verbosity
pkgid
location
distPref
installPkg
=
case
location
of
...
...
@@ -1292,8 +1292,8 @@ installLocalPackage verbosity pkgid location distPref installPkg =
installLocalTarballPackage
::
Verbosity
->
PackageIdentifier
->
FilePath
->
FilePath
->
(
Maybe
FilePath
->
IO
Build
Result
)
->
IO
Build
Result
->
(
Maybe
FilePath
->
IO
Build
Outcome
)
->
IO
Build
Outcome
installLocalTarballPackage
verbosity
pkgid
tarballPath
distPref
installPkg
=
do
tmp
<-
getTemporaryDirectory
...
...
@@ -1356,7 +1356,7 @@ installUnpackedPackage
->
PackageDescriptionOverride
->
Maybe
FilePath
-- ^ Directory to change to before starting the installation.
->
UseLogFile
-- ^ File to log output to (if any)
->
IO
Build
Result
->
IO
Build
Outcome
installUnpackedPackage
verbosity
installLock
numJobs
scriptOptions
configFlags
installFlags
haddockFlags
comp
conf
...
...
@@ -1439,7 +1439,7 @@ installUnpackedPackage verbosity installLock numJobs
NoMultiInstance
packageDBs
ipkg'
return
(
Right
(
Build
Ok
docsResult
testsResult
ipkgs'
))
return
(
Right
(
Build
Result
docsResult
testsResult
ipkgs'
))
where
pkgid
=
packageId
pkg
...
...
@@ -1551,14 +1551,14 @@ installUnpackedPackage verbosity installLock numJobs
-- helper
onFailure
::
(
SomeException
->
BuildFailure
)
->
IO
Build
Result
->
IO
Build
Result
onFailure
::
(
SomeException
->
BuildFailure
)
->
IO
Build
Outcome
->
IO
Build
Outcome
onFailure
result
action
=
action
`
catches
`
[
Handler
$
\
ioe
->
handler
(
ioe
::
IOException
)
,
Handler
$
\
exit
->
handler
(
exit
::
ExitCode
)
]
where
handler
::
Exception
e
=>
e
->
IO
Build
Result
handler
::
Exception
e
=>
e
->
IO
Build
Outcome
handler
=
return
.
Left
.
result
.
toException
...
...
cabal-install/Distribution/Client/InstallPlan.hs
View file @
6309f825
...
...
@@ -37,8 +37,8 @@ module Distribution.Client.InstallPlan (
-- * Traversal
executionOrder
,
execute
,
Build
Result
s
,
lookupBuild
Result
,
Build
Outcome
s
,
lookupBuild
Outcome
,
-- ** Traversal helpers
-- $traversal
Processing
,
...
...
@@ -55,7 +55,7 @@ module Distribution.Client.InstallPlan (
reverseDependencyClosure
,
)
where
import
Distribution.Client.Types
hiding
(
Build
Result
s
)
import
Distribution.Client.Types
hiding
(
Build
Outcome
s
)
import
qualified
Distribution.PackageDescription
as
PD
import
qualified
Distribution.Simple.Configure
as
Configure
import
qualified
Distribution.Simple.Setup
as
Cabal
...
...
@@ -704,19 +704,19 @@ executionOrder plan =
-- | The set of results we get from executing an install plan.
--
type
Build
Result
s
failure
result
=
Map
UnitId
(
Either
failure
result
)
type
Build
Outcome
s
failure
result
=
Map
UnitId
(
Either
failure
result
)
-- | Lookup the build result for a single package.
--
lookupBuild
Result
::
HasUnitId
pkg
=>
pkg
->
Build
Result
s
failure
result
->
Maybe
(
Either
failure
result
)
lookupBuild
Result
=
Map
.
lookup
.
installedUnitId
lookupBuild
Outcome
::
HasUnitId
pkg
=>
pkg
->
Build
Outcome
s
failure
result
->
Maybe
(
Either
failure
result
)
lookupBuild
Outcome
=
Map
.
lookup
.
installedUnitId
-- | Execute an install plan. This traverses the plan in dependency order.
--
-- Executing each individual package can fail and if so all dependents fail
-- too. The result for each package is collected as a 'Build
Result
s' map.
-- too. The result for each package is collected as a 'Build
Outcome
s' map.
--
-- Visiting each package happens with optional parallelism, as determined by
-- the 'JobControl'. By default, after any failure we stop as soon as possible
...
...
@@ -732,15 +732,15 @@ execute :: forall m ipkg srcpkg result failure.
->
(
srcpkg
->
failure
)
-- ^ Value for dependents of failed packages
->
GenericInstallPlan
ipkg
srcpkg
->
(
GenericReadyPackage
srcpkg
->
m
(
Either
failure
result
))
->
m
(
Build
Result
s
failure
result
)
->
m
(
Build
Outcome
s
failure
result
)
execute
jobCtl
keepGoing
depFailure
plan
installPkg
=
let
(
newpkgs
,
processing
)
=
ready
plan
in
tryNewTasks
Map
.
empty
False
False
processing
newpkgs
where
tryNewTasks
::
Build
Result
s
failure
result
tryNewTasks
::
Build
Outcome
s
failure
result
->
Bool
->
Bool
->
Processing
->
[
GenericReadyPackage
srcpkg
]
->
m
(
Build
Result
s
failure
result
)
->
m
(
Build
Outcome
s
failure
result
)
tryNewTasks
!
results
tasksFailed
tasksRemaining
!
processing
newpkgs
-- we were in the process of cancelling and now we're finished
...
...
@@ -767,9 +767,9 @@ execute jobCtl keepGoing depFailure plan installPkg =
|
pkg
<-
newpkgs
]
waitForTasks
results
tasksFailed
processing
waitForTasks
::
Build
Result
s
failure
result
waitForTasks
::
Build
Outcome
s
failure
result
->
Bool
->
Processing
->
m
(
Build
Result
s
failure
result
)
->
m
(
Build
Outcome
s
failure
result
)
waitForTasks
!
results
tasksFailed
!
processing
=
do
(
pkgid
,
result
)
<-
collectJob
jobCtl
...
...
cabal-install/Distribution/Client/InstallSymlink.hs
View file @
6309f825
...
...
@@ -20,7 +20,7 @@ module Distribution.Client.InstallSymlink (
import
Distribution.Package
(
PackageIdentifier
)
import
Distribution.Client.InstallPlan
(
InstallPlan
)
import
Distribution.Client.Types
(
Build
Result
s
)
import
Distribution.Client.Types
(
Build
Outcome
s
)
import
Distribution.Client.Setup
(
InstallFlags
)
import
Distribution.Simple.Setup
(
ConfigFlags
)
import
Distribution.Simple.Compiler
...
...
@@ -30,7 +30,7 @@ symlinkBinaries :: Platform -> Compiler
->
ConfigFlags
->
InstallFlags
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
IO
[(
PackageIdentifier
,
String
,
FilePath
)]
symlinkBinaries
_
_
_
_
_
_
=
return
[]
...
...
@@ -40,7 +40,7 @@ symlinkBinary _ _ _ _ = fail "Symlinking feature not available on Windows"
#
else
import
Distribution.Client.Types
(
ConfiguredPackage
(
..
),
Build
Result
s
)
(
ConfiguredPackage
(
..
),
Build
Outcome
s
)
import
Distribution.Client.Setup
(
InstallFlags
(
installSymlinkBinDir
)
)
import
qualified
Distribution.Client.InstallPlan
as
InstallPlan
...
...
@@ -107,9 +107,9 @@ symlinkBinaries :: Platform -> Compiler
->
ConfigFlags
->
InstallFlags
->
InstallPlan
->
Build
Result
s
->
Build
Outcome
s
->
IO
[(
PackageIdentifier
,
String
,
FilePath
)]
symlinkBinaries
platform
comp
configFlags
installFlags
plan
build
Result
s
=
symlinkBinaries
platform
comp
configFlags
installFlags
plan
build
Outcome
s
=
case
flagToMaybe
(
installSymlinkBinDir
installFlags
)
of
Nothing
->
return
[]
Just
symlinkBinDir
...
...
@@ -139,7 +139,7 @@ symlinkBinaries platform comp configFlags installFlags plan buildResults =
exes
=
[
(
cpkg
,
pkg
,
exe
)
|
InstallPlan
.
Configured
cpkg
<-
InstallPlan
.
toList
plan
,
case
InstallPlan
.
lookupBuild
Result
cpkg
build
Result
s
of
,
case
InstallPlan
.
lookupBuild
Outcome
cpkg
build
Outcome
s
of
Just
(
Right
_success
)
->
True
_
->
False
,
let
pkg
::
PackageDescription
...
...
cabal-install/Distribution/Client/ProjectBuilding.hs
View file @
6309f825
...
...
@@ -14,10 +14,11 @@ module Distribution.Client.ProjectBuilding (
rebuildTargetsDryRun
,
-- * Build phase
BuildResult
,
BuildResults
,
BuildOutcome
,
BuildOutcomes
,
BuildResult
(
..
),
BuildFailure
(
..
),
Build
Success
(
..
),
Build
FailureReason
(
..
),
rebuildTargets
)
where
...
...
@@ -27,6 +28,8 @@ import Distribution.Client.ProjectConfig
import
Distribution.Client.ProjectPlanning
import
Distribution.Client.Types
hiding
(
BuildOutcomes
,
BuildOutcome
,
BuildResult
(
..
),
BuildFailure
(
..
))
import
Distribution.Client.InstallPlan
(
GenericInstallPlan
,
GenericPlanPackage
)
import
qualified
Distribution.Client.InstallPlan
as
InstallPlan
...
...
@@ -72,6 +75,7 @@ import Control.Monad
import
Control.Exception
import
Data.List
import
Data.Maybe
import
Data.Typeable
import
System.FilePath
import
System.IO
...
...
@@ -123,8 +127,8 @@ type BuildStatusMap = Map InstalledPackageId BuildStatus
-- | The build status for an individual package is the state that the
-- package is in /prior/ to initiating a (re)build.
--
-- This should not be confused with a 'BuildResult' which is the
outcome
-- /after/ building a package.
-- This should not be confused with a 'BuildResult' which is the
result
-- /after/
successfully
building a package.
--
-- It serves two purposes:
--
...
...
@@ -156,7 +160,7 @@ data BuildStatus =
-- | The package exists in a local dir already, and is fully up to date.
-- So this package can be put into the 'InstallPlan.Installed' state
-- and it does not need to be built.
|
BuildStatusUpToDate
Build
Success
|
BuildStatusUpToDate
Build
Result
-- | For a package that is going to be built or rebuilt, the state it's in now.
--
...
...
@@ -297,8 +301,8 @@ rebuildTargetsDryRun distDirLayout@DistDirLayout{..} = \installPlan -> do
return
(
BuildStatusRebuild
srcdir
rebuild
)
-- No changes, the package is up to date. Use the saved build results.
Right
build
Success
->
return
(
BuildStatusUpToDate
build
Success
)
Right
build
Result
->
return
(
BuildStatusUpToDate
build
Result
)
where
packageFileMonitor
=
newPackageFileMonitor
distDirLayout
(
packageId
pkg
)
...
...
@@ -350,7 +354,8 @@ improveInstallPlanWithUpToDatePackages installPlan pkgsBuildStatus =
<-
InstallPlan
.
reverseTopologicalOrder
installPlan
,
let
ipkgid
=
installedPackageId
pkg
Just
pkgBuildStatus
=
Map
.
lookup
ipkgid
pkgsBuildStatus
,
BuildStatusUpToDate
(
BuildOk
_
_
ipkgs
)
<-
[
pkgBuildStatus
]
,
BuildStatusUpToDate
(
BuildResult
{
buildResultLibInfo
=
ipkgs
})
<-
[
pkgBuildStatus
]
]
where
replaceWithPrePreExisting
=
...
...
@@ -378,17 +383,17 @@ improveInstallPlanWithUpToDatePackages installPlan pkgsBuildStatus =
--
data
PackageFileMonitor
=
PackageFileMonitor
{
pkgFileMonitorConfig
::
FileMonitor
ElaboratedConfiguredPackage
()
,
pkgFileMonitorBuild
::
FileMonitor
(
Set
ComponentName
)
Build
Success
Misc
,
pkgFileMonitorBuild
::
FileMonitor
(
Set
ComponentName
)
Build
Result
Misc
,
pkgFileMonitorReg
::
FileMonitor
()
[
InstalledPackageInfo
]
}
-- | This is all the components of the 'Build
Success
' other than the
-- | This is all the components of the 'Build
Result
' other than the
-- @['InstalledPackageInfo']@.
--
-- We have to split up the 'Build
Success
' components since they get produced
-- We have to split up the 'Build
Result
' components since they get produced
-- at different times (or rather, when different things change).
--
type
Build
Success
Misc
=
(
DocsResult
,
TestsResult
)
type
Build
Result
Misc
=
(
DocsResult
,
TestsResult
)
newPackageFileMonitor
::
DistDirLayout
->
PackageId
->
PackageFileMonitor
newPackageFileMonitor
DistDirLayout
{
distPackageCacheFile
}
pkgid
=
...
...
@@ -445,7 +450,7 @@ checkPackageFileMonitorChanged :: PackageFileMonitor
->
ElaboratedConfiguredPackage
->
FilePath
->
ComponentDeps
[
BuildStatus
]
->
IO
(
Either
BuildStatusRebuild
Build
Success
)
->
IO
(
Either
BuildStatusRebuild
Build
Result
)
checkPackageFileMonitorChanged
PackageFileMonitor
{
..
}
pkg
srcdir
depsBuildStatus
=
do
--TODO: [nice to have] some debug-level message about file changes, like rerunIfChanged
...
...
@@ -499,10 +504,15 @@ checkPackageFileMonitorChanged PackageFileMonitor{..}
where
buildReason
=
BuildReasonEphemeralTargets
(
MonitorUnchanged
buildSuccess
_
,
MonitorUnchanged
ipkgs
_
)
->
return
(
Right
(
BuildOk
docsResult
testsResult
ipkgs
))
(
MonitorUnchanged
buildResult
_
,
MonitorUnchanged
ipkgs
_
)
->
return
$
Right
BuildResult
{
buildResultDocs
=
docsResult
,
buildResultTests
=
testsResult
,
buildResultLogFile
=
Nothing
,
buildResultLibInfo
=
ipkgs
}
where
(
docsResult
,
testsResult
)
=
build
Success
(
docsResult
,
testsResult
)
=
build
Result
where
(
pkgconfig
,
buildComponents
)
=
packageFileMonitorKeyValues
pkg
changedToMaybe
(
MonitorChanged
_
)
=
Nothing
...
...
@@ -526,14 +536,14 @@ updatePackageBuildFileMonitor :: PackageFileMonitor
->
ElaboratedConfiguredPackage
->
BuildStatusRebuild
->
[
FilePath
]
->
Build
Success
Misc
->
Build
Result
Misc
->
IO
()
updatePackageBuildFileMonitor
PackageFileMonitor
{
pkgFileMonitorBuild
}
srcdir
timestamp
pkg
pkgBuildStatus
allSrcFiles
build
Success
=
allSrcFiles
build
Result
=
updateFileMonitor
pkgFileMonitorBuild
srcdir
(
Just
timestamp
)
(
map
monitorFileHashed
allSrcFiles
)
buildComponents'
build
Success
buildComponents'
build
Result
where
(
_pkgconfig
,
buildComponents
)
=
packageFileMonitorKeyValues
pkg
...
...
@@ -568,6 +578,47 @@ invalidatePackageRegFileMonitor PackageFileMonitor{pkgFileMonitorReg} =
-- * Doing it: executing an 'ElaboratedInstallPlan'
------------------------------------------------------------------------------
-- | A summary of the outcome for building a whole set of packages.
--
type
BuildOutcomes
=
Map
UnitId
BuildOutcome
-- | A summary of the outcome for building a single package: either success
-- or failure.
--
type
BuildOutcome
=
Either
BuildFailure
BuildResult