Commit 26e64ed5 authored by Ben Gamari's avatar Ben Gamari 🐢
Browse files

Move `renderBox` to `Base`

parent aad2247e
......@@ -21,6 +21,7 @@ module Base (
-- * Output
putColoured, putOracle, putBuild, putSuccess, putError,
renderBox,
module System.Console.ANSI,
-- * Miscellaneous utilities
......@@ -130,6 +131,23 @@ putError msg = do
putColoured Red msg
error $ "GHC build system error: " ++ msg
-- | Render the given set of lines in a ASCII box
renderBox :: [String] -> String
renderBox ls =
unlines $ [begin] ++ map (bar++) ls ++ [end]
where
(begin,bar,end)
| useUnicode = ( "╭──────────"
, "│ "
, "╰──────────"
)
| otherwise = ( "/----------"
, "| "
, "\\----------"
)
-- FIXME: See Shake #364.
useUnicode = False
-- Depending on Data.Bifunctor only for this function seems an overkill
bimap :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
bimap f g (x, y) = (f x, g y)
......
......@@ -7,22 +7,6 @@ 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).
......@@ -38,8 +22,8 @@ buildWithResources rs target = do
checkArgsHash target
withResources rs $ do
unless verbose $ do
putBuild $ insideBox $ [ "Running " ++ show builder ++ " with arguments:" ]
++ map (" "++) (interestingInfo builder argList)
putBuild $ renderBox $ [ "Running " ++ show builder ++ " with arguments:" ]
++ map (" "++) (interestingInfo builder argList)
quietlyUnlessVerbose $ case builder of
Ar -> arCmd path argList
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment