[commit: ghc] wip/nfs-locking: Actions: Factor out box drawing (9d2868b)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:26:11 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/9d2868b107cce0af8445ec6ce8471ba1d45e3042/ghc

>---------------------------------------------------------------

commit 9d2868b107cce0af8445ec6ce8471ba1d45e3042
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sun Dec 20 17:21:47 2015 +0100

    Actions: Factor out box drawing
    
    Also add (currently broken) Unicode support although this is broken by
    Shake, the console output interface of which is badly broken (see
    Shake #364)


>---------------------------------------------------------------

9d2868b107cce0af8445ec6ce8471ba1d45e3042
 src/Rules/Actions.hs | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/Rules/Actions.hs b/src/Rules/Actions.hs
index 805c771..775524a 100644
--- a/src/Rules/Actions.hs
+++ b/src/Rules/Actions.hs
@@ -7,6 +7,22 @@ import Settings.Args
 import Settings.Builders.Ar
 import qualified Target
 
+insideBox :: [String] -> String
+insideBox ls =
+    unlines $ [begin] ++ map (bar++) ls ++ [end]
+  where
+    (begin,bar,end)
+      | useUnicode = ( "╭──────────"
+                     , "│ "
+                     , "╰──────────"
+                     )
+      | otherwise  = ( "/----------"
+                     , "| "
+                     , "\\----------"
+                     )
+    -- FIXME: See Shake #364.
+    useUnicode = False
+
 -- Build a given target using an appropriate builder and acquiring necessary
 -- resources. Force a rebuilt if the argument list has changed since the last
 -- built (that is, track changes in the build system).
@@ -17,15 +33,14 @@ buildWithResources rs target = do
     path    <- builderPath builder
     argList <- interpret target getArgs
     verbose <- interpret target verboseCommands
-    let quitelyUnlessVerbose = if verbose then withVerbosity Loud else quietly
+    let quietlyUnlessVerbose = if verbose then withVerbosity Loud else quietly
     -- The line below forces the rule to be rerun if the args hash has changed
     checkArgsHash target
     withResources rs $ do
         unless verbose $ do
-            putBuild $ "/--------\n| Running " ++ show builder ++ " with arguments:"
-            mapM_ (putBuild . ("|   " ++)) $ interestingInfo builder argList
-            putBuild $ "\\--------"
-        quitelyUnlessVerbose $ case builder of
+            putBuild $ insideBox $ [ "Running " ++ show builder ++ " with arguments:" ]
+                                ++ map ("  "++) (interestingInfo builder argList)
+        quietlyUnlessVerbose $ case builder of
             Ar -> arCmd path argList
 
             HsCpp -> do



More information about the ghc-commits mailing list