Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4040] Align output for parallel builds #5456

Merged
merged 4 commits into from
Jul 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cabal-install/Distribution/Client/FetchUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ import Distribution.Client.HttpUtils
import Distribution.Package
( PackageId, packageName, packageVersion )
import Distribution.Simple.Utils
( notice, info, debug, setupMessage, die' )
( notice, info, debug, die' )
import Distribution.Text
( display )
import Distribution.Verbosity
( Verbosity, verboseUnmarkOutput )
import Distribution.Client.GlobalFlags
( RepoContext(..) )
import Distribution.Client.Utils
( ProgressPhase(..), progressMessage )

import Data.Maybe
import Data.Map (Map)
Expand Down Expand Up @@ -165,8 +167,12 @@ fetchRepoTarball verbosity repoCtxt repo pkgid = do
if fetched
then do info verbosity $ display pkgid ++ " has already been downloaded."
return (packageFile repo pkgid)
else do setupMessage verbosity "Downloading" pkgid
downloadRepoPackage
else do progressMessage verbosity ProgressDownloading (display pkgid)
res <- downloadRepoPackage
progressMessage verbosity ProgressDownloaded (display pkgid)
return res


where
downloadRepoPackage = case repo of
RepoLocal{..} -> return (packageFile repo pkgid)
Expand Down
16 changes: 10 additions & 6 deletions cabal-install/Distribution/Client/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ import Distribution.Simple.Utils as Utils
, withTempDirectory )
import Distribution.Client.Utils
( determineNumJobs, logDirChange, mergeBy, MergeResult(..)
, tryCanonicalizePath )
, tryCanonicalizePath, ProgressPhase(..), progressMessage )
import Distribution.System
( Platform, OS(Windows), buildOS, buildPlatform )
import Distribution.Text
Expand Down Expand Up @@ -1197,7 +1197,7 @@ executeInstallPlan verbosity jobCtl keepGoing useLogFile plan0 installPkg =
-- otherwise.
printBuildResult :: PackageId -> UnitId -> BuildOutcome -> IO ()
printBuildResult pkgid uid buildOutcome = case buildOutcome of
(Right _) -> notice verbosity $ "Installed " ++ display pkgid
(Right _) -> progressMessage verbosity ProgressCompleted (display pkgid)
(Left _) -> do
notice verbosity $ "Failed to install " ++ display pkgid
when (verbosity >= normal) $
Expand Down Expand Up @@ -1399,14 +1399,12 @@ installUnpackedPackage verbosity installLock numJobs
logDirChange (maybe (const (return ())) appendFile mLogPath) workingDir $ do
-- Configure phase
onFailure ConfigureFailed $ do
when (numJobs > 1) $ notice verbosity $
"Configuring " ++ display pkgid ++ "..."
noticeProgress ProgressStarting
setup configureCommand configureFlags mLogPath

-- Build phase
onFailure BuildFailed $ do
when (numJobs > 1) $ notice verbosity $
"Building " ++ display pkgid ++ "..."
noticeProgress ProgressBuilding
setup buildCommand' buildFlags mLogPath

-- Doc generation phase
Expand Down Expand Up @@ -1453,6 +1451,12 @@ installUnpackedPackage verbosity installLock numJobs
uid = installedUnitId rpkg
cinfo = compilerInfo comp
buildCommand' = buildCommand progdb
dispname = display pkgid
isParallelBuild = numJobs >= 2

noticeProgress phase = when isParallelBuild $
progressMessage verbosity phase dispname

buildFlags _ = emptyBuildFlags {
buildDistPref = configDistPref configFlags,
buildVerbosity = toFlag verbosity'
Expand Down
32 changes: 19 additions & 13 deletions cabal-install/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ import Distribution.Client.Setup
, filterHaddockFlags )
import Distribution.Client.SourceFiles
import Distribution.Client.SrcDist (allPackageSourceFiles)
import Distribution.Client.Utils (removeExistingFile)
import Distribution.Client.Utils
( ProgressPhase(..), progressMessage, removeExistingFile )

import Distribution.Compat.Lens
import Distribution.Package hiding (InstalledPackageId, installedPackageId)
Expand Down Expand Up @@ -939,32 +940,26 @@ buildAndInstallUnpackedPackage verbosity
--TODO: [required feature] docs and tests
--TODO: [required feature] sudo re-exec

let dispname = case elabPkgOrComp pkg of
ElabPackage _ -> display pkgid
++ " (all, legacy fallback)"
ElabComponent comp -> display pkgid
++ " (" ++ maybe "custom" display (compComponentName comp) ++ ")"

-- Configure phase
when isParallelBuild $
notice verbosity $ "Configuring " ++ dispname ++ "..."
noticeProgress ProgressStarting

annotateFailure mlogFile ConfigureFailed $
setup' configureCommand configureFlags configureArgs

-- Build phase
when isParallelBuild $
notice verbosity $ "Building " ++ dispname ++ "..."
noticeProgress ProgressBuilding

annotateFailure mlogFile BuildFailed $
setup buildCommand buildFlags

-- Haddock phase
whenHaddock $ do
when isParallelBuild $
notice verbosity $ "Generating " ++ dispname ++ " documentation..."
noticeProgress ProgressHaddock
annotateFailureNoLog HaddocksFailed $
setup haddockCommand haddockFlags

-- Install phase
noticeProgress ProgressInstalling
annotateFailure mlogFile InstallFailed $ do

let copyPkgFiles tmpDir = do
Expand Down Expand Up @@ -1037,6 +1032,8 @@ buildAndInstallUnpackedPackage verbosity
let docsResult = DocsNotTried
testsResult = TestsNotTried

noticeProgress ProgressCompleted

return BuildResult {
buildResultDocs = docsResult,
buildResultTests = testsResult,
Expand All @@ -1048,6 +1045,15 @@ buildAndInstallUnpackedPackage verbosity
uid = installedUnitId rpkg
compid = compilerId compiler

dispname = case elabPkgOrComp pkg of
ElabPackage _ -> display pkgid
++ " (all, legacy fallback)"
ElabComponent comp -> display pkgid
++ " (" ++ maybe "custom" display (compComponentName comp) ++ ")"

noticeProgress phase = when isParallelBuild $
progressMessage verbosity phase dispname

isParallelBuild = buildSettingNumJobs >= 2

whenHaddock action
Expand Down
30 changes: 28 additions & 2 deletions cabal-install/Distribution/Client/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module Distribution.Client.Utils ( MergeResult(..)
, moreRecentFile, existsAndIsMoreRecentThan
, tryFindAddSourcePackageDesc
, tryFindPackageDesc
, relaxEncodingErrors)
, relaxEncodingErrors
, ProgressPhase (..)
, progressMessage)
where

import Prelude ()
Expand All @@ -28,7 +30,7 @@ import Distribution.Compat.Exception ( catchIO )
import Distribution.Compat.Time ( getModTime )
import Distribution.Simple.Setup ( Flag(..) )
import Distribution.Verbosity
import Distribution.Simple.Utils ( die', findPackageDesc )
import Distribution.Simple.Utils ( die', findPackageDesc, noticeNoWrap )
import qualified Data.ByteString.Lazy as BS
import Data.Bits
( (.|.), shiftL, shiftR )
Expand Down Expand Up @@ -336,3 +338,27 @@ tryFindPackageDesc verbosity depPath err = do
case errOrCabalFile of
Right file -> return file
Left _ -> die' verbosity err

-- | Phase of building a dependency. Represents current status of package
-- dependency processing. See #4040 for details.
data ProgressPhase
= ProgressDownloading
| ProgressDownloaded
| ProgressStarting
| ProgressBuilding
| ProgressHaddock
| ProgressInstalling
| ProgressCompleted

progressMessage :: Verbosity -> ProgressPhase -> String -> IO ()
progressMessage verbosity phase subject = do
noticeNoWrap verbosity $ phaseStr ++ subject ++ "\n"
where
phaseStr = case phase of
ProgressDownloading -> "Downloading "
ProgressDownloaded -> "Downloaded "
ProgressStarting -> "Starting "
ProgressBuilding -> "Building "
ProgressHaddock -> "Haddock "
ProgressInstalling -> "Installing "
ProgressCompleted -> "Completed "
1 change: 1 addition & 0 deletions cabal-install/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Support packages from local tarballs in the cabal.project file.
* Default changelog generated by 'cabal init' is now named
'CHANGELOG.md' (#5441).
* Align output of 'new-build' command phases (#4040).

2.2.0.0 Mikhail Glushenkov <[email protected]> March 2018
* '--with-PROG' and '--PROG-options' are applied to all packages
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Exec/T4049/sandbox.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Configuring my-foreign-lib-0.1.0.0...
Preprocessing foreign library 'myforeignlib' for my-foreign-lib-0.1.0.0..
Building foreign library 'myforeignlib' for my-foreign-lib-0.1.0.0..
Installing foreign library myforeignlib in <PATH>
Installed my-foreign-lib-0.1.0.0
Completed my-foreign-lib-0.1.0.0
# cabal v1-exec
Hi from a foreign library! Foo has value 5678
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Exec/sandbox-ghc-pkg.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Preprocessing library for my-0.1..
Building library for my-0.1..
Installing executable my-executable in <PATH>
Installing library in <PATH>
Installed my-0.1
Completed my-0.1
# cabal v1-exec
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Preprocessing library for my-0.1..
Building library for my-0.1..
Installing executable my-executable in <PATH>
Installing library in <PATH>
Installed my-0.1
Completed my-0.1
# cabal v1-exec
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Exec/sandbox-path.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Preprocessing library for my-0.1..
Building library for my-0.1..
Installing executable my-executable in <PATH>
Installing library in <PATH>
Installed my-0.1
Completed my-0.1
# cabal v1-exec
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Exec/sandbox.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Preprocessing library for my-0.1..
Building library for my-0.1..
Installing executable my-executable in <PATH>
Installing library in <PATH>
Installed my-0.1
Completed my-0.1
# cabal v1-exec
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Building library for p-0.1.0.0..
Installing internal library q in <PATH>
Installing executable foo in <PATH>
Installing library in <PATH>
Installed p-0.1.0.0
Completed p-0.1.0.0
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/InternalLibraries/sandbox.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Building library for p-0.1.0.0..
Installing internal library q in <PATH>
Installing executable foo in <PATH>
Installing library in <PATH>
Installed p-0.1.0.0
Completed p-0.1.0.0
4 changes: 2 additions & 2 deletions cabal-testsuite/PackageTests/Regression/T3436/sandbox.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Configuring Cabal-1.2...
Preprocessing library for Cabal-1.2..
Building library for Cabal-1.2..
Installing library in <PATH>
Installed Cabal-1.2
Completed Cabal-1.2
# cabal v1-sandbox add-source
# cabal v1-install
Resolving dependencies...
Configuring Cabal-2.0...
Preprocessing library for Cabal-2.0..
Building library for Cabal-2.0..
Installing library in <PATH>
Installed Cabal-2.0
Completed Cabal-2.0
Failed to install custom-setup-1.0
cabal: Error: some packages failed to install:
custom-setup-1.0-KL06TzJxSBkDtcPp9Xd2v1 failed during the configure step. The exception was:
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Regression/T5318/install.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Preprocessing executable 'foo' for empty-data-dir-0..
Building executable 'foo' for empty-data-dir-0..
Installing executable foo in <PATH>
Warning: The directory <ROOT>/install.dist/home/.cabal/bin is not in the system search path.
Installed empty-data-dir-0
Completed empty-data-dir-0
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Configuring q-0.1.0.0...
Preprocessing library for q-0.1.0.0..
Building library for q-0.1.0.0..
Installing library in <PATH>
Installed q-0.1.0.0
Completed q-0.1.0.0
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/Sandbox/Reinstall/sandbox.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Configuring q-1.0...
Preprocessing library for q-1.0..
Building library for q-1.0..
Installing library in <PATH>
Installed q-1.0
Completed q-1.0
# cabal v1-run
message
# cabal v1-run
Expand Down