From 763ac9a2e8b1ad72f3dbe328c62ed42eac8ca264 Mon Sep 17 00:00:00 2001 From: tydeu Date: Tue, 2 Nov 2021 07:03:48 -0400 Subject: [PATCH] refactor: pipe `proc` output to logger --- Lake/Compile.lean | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Lake/Compile.lean b/Lake/Compile.lean index 12a5cc578a..6876808a2f 100644 --- a/Lake/Compile.lean +++ b/Lake/Compile.lean @@ -8,7 +8,7 @@ import Lake.BuildMonad namespace Lake open System -def createParentDirs (path : FilePath) : BuildM PUnit := do +def createParentDirs (path : FilePath) : IO PUnit := do if let some dir := path.parent then IO.FS.createDirAll dir def proc (args : IO.Process.SpawnArgs) : BuildM PUnit := do @@ -18,10 +18,13 @@ def proc (args : IO.Process.SpawnArgs) : BuildM PUnit := do match args.cwd with | some cwd => s!"{cmdStr} # in directory {cwd}" | none => cmdStr - let child ← IO.Process.spawn args - let exitCode ← child.wait - if exitCode != 0 then -- log errors early - logError s!"external command {args.cmd} exited with status {exitCode}" + let out ← IO.Process.output args + unless out.stdout.isEmpty do + logInfo out.stdout + unless out.stderr.isEmpty do + logError out.stderr + if out.exitCode != 0 then + logError s!"external command {args.cmd} exited with status {out.exitCode}" failure def compileOlean (leanFile oleanFile : FilePath)