diff options
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r-- | Biz/Bild.hs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 22d3882..1e0422a 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -147,6 +147,7 @@ import System.FilePath (replaceExtension, (</>)) import qualified System.IO as IO import System.IO.Unsafe (unsafePerformIO) import qualified System.Process as Process +import qualified System.Timeout as Timeout import qualified Text.Regex.Applicative as Regex main :: IO () @@ -204,7 +205,22 @@ move args = /> Map.filter (namespace .> isBuildableNs) +> printOrBuild +> exitSummary + -- convert minutes to microseconds + |> Timeout.timeout (minutes * 60_000_000) + +> \case + Nothing -> + Log.wipe + >> Log.fail ["bild", "timeout after " <> tshow minutes <> " minutes"] + >> exitWith (ExitFailure 124) + Just _ -> + pure () where + minutes = + Cli.getArgWithDefault args (Cli.longOption "time") + |> readMaybe + |> \case + Nothing -> panic "could not read --time argument" + Just n -> n printOrBuild :: Analysis -> IO [ExitCode] printOrBuild targets | args `Cli.has` Cli.longOption "json" = @@ -230,10 +246,11 @@ Usage: bild [options] <target>... Options: - --test Run tests on a target after building - --loud Show all output from compiler - --json Print the build plan as JSON, don't build - -h, --help Print this info + --test, -t Run tests on a target after building + --loud, -l Show all output from compiler + --json, -j Print the build plan as JSON, don't build + --time N Set timeout to N minutes [default: 10] + --help, -h Print this info |] exitSummary :: [Exit.ExitCode] -> IO () |