-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor setupMessage use in Cabal library.
I noticed that I was repeatedly writing the same code to print out more elaborate information when we do builds, so I refactored it all into one place. In the process, I think that I have made the build output more generally useful. The key changes: - There is a new function setupMessage' which takes in more information than the conventional setupMessage does, and prints a more informative message: whereas setupMessage will only tell you about the package it is being run in, setupMessage' will also tell you about the component and instantiation. - I applied this function to applicable sites, in some cases moving around messages to be closer to the place where an actual operation takes place. For example, the 'Building' message previously only was triggered at the beginning of the build process; now it is emitted immediately before we call out to GHC. This is a lot more informative, and avoids people thinking that we are slow because of preprocessing (we're not.) Something similar happened for Haddock as well. Before: Preprocessing library 'spider' for reflex-backpack-0.5.0.. [1 of 1] Compiling Reflex.Spider.Backpack ( src/Reflex/Spider/Backpack.hs, /srv/code/reflex-backpack/dist-newstyle/build/x86_64-linux/ghc-8.1.20170123/reflex-backpack-0.5.0/c/spider/build/spider/Reflex/Spider/Backpack.o ) After: Preprocessing library 'host' for reflex-backpack-0.5.0.. Building library 'host' instantiated with Reflex.Host.Sig = reflex-backpack-0.5.0-inplace-spider:Reflex.Spider.Backpack Reflex.Sig = reflex-backpack-0.5.0-inplace-spider:Reflex.Spider.Backpack for reflex-backpack-0.5.0.. [1 of 8] Compiling Reflex.Host.Sig[sig] ( host/Reflex/Host/Sig.hsig, /srv/code/reflex-backpack/dist-newstyle/build/x86_64-linux/ghc-8.1.20170123/reflex-backpack-0.5.0/c/host/reflex-backpack-0.5.0-inplace-host+FDoWUmUc0MMBtBRwItgjj9/build/reflex-backpack-0.5.0-inplace-host+FDoWUmUc0MMBtBRwItgjj9/Reflex/Host/Sig.o ) [Reflex.Basics changed] Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
- Loading branch information
Showing
10 changed files
with
124 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{-# LANGUAGE Rank2Types #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
module Distribution.Backpack.DescribeUnitId where | ||
|
||
import Prelude () | ||
import Distribution.Compat.Prelude | ||
|
||
import Distribution.Types.ComponentName | ||
import Distribution.Compat.Stack | ||
import Distribution.Verbosity | ||
import Distribution.ModuleName | ||
import Distribution.Package | ||
import Distribution.Text | ||
import Distribution.Simple.Utils | ||
|
||
import Text.PrettyPrint | ||
|
||
-- Unit identifiers have a well defined, machine-readable format, | ||
-- but this format isn't very user-friendly for users. This | ||
-- module defines some functions for solving common rendering | ||
-- problems one has for displaying these. | ||
-- | ||
-- There are three basic problems we tackle: | ||
-- | ||
-- - Users don't want to see pkg-0.5-inplace-libname, | ||
-- they want to see "library 'libname' from 'pkg-0.5'" | ||
-- | ||
-- - Users don't want to see the raw component identifier, which | ||
-- usually contains a wordy hash that doesn't matter. | ||
-- | ||
-- - Users don't want to see a hash of the instantiation: they | ||
-- want to see the actual instantiation, and they want it in | ||
-- interpretable form. | ||
-- | ||
|
||
-- | Print a Setup message stating (1) what operation we are doing, | ||
-- for (2) which component (with enough details to uniquely identify | ||
-- the build in question.) | ||
-- | ||
setupMessage' :: Text a => Verbosity | ||
-> String -- ^ Operation being done (capitalized), on: | ||
-> PackageIdentifier -- ^ Package | ||
-> ComponentName -- ^ Component name | ||
-> Maybe [(ModuleName, a)] -- ^ Instantiation, if available. | ||
-- Polymorphic to take | ||
-- 'OpenModule' or 'Module' | ||
-> IO () | ||
setupMessage' verbosity msg pkgid cname mb_insts = withFrozenCallStack $ do | ||
noticeDoc verbosity $ | ||
case mb_insts of | ||
Just insts | not (null insts) -> | ||
hang (msg_doc <+> text "instantiated with") 2 | ||
(vcat [ disp k <+> text "=" <+> disp v | ||
| (k,v) <- insts ]) $$ | ||
for_doc | ||
_ -> | ||
msg_doc <+> for_doc | ||
|
||
where | ||
msg_doc = text msg <+> text (showComponentName cname) | ||
for_doc = text "for" <+> disp pkgid <<>> text ".." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters