Commit 3d9f35cb authored by Camil Staps's avatar Camil Staps 🐧

Show process output

parent 0e67b6cf
......@@ -22,7 +22,8 @@ from StdLibMisc import :: Date{..}, :: Time{..}
import Data.Error
import System.FilePath
from System.Process import :: ProcessHandle, runProcess, waitForProcess
import System.Process => qualified :: Either
from Text import class Text(split), instance Text String
verboseInfo verbose info ps :== verbi verbose info ps
where
......@@ -1675,10 +1676,12 @@ OptimiseABC mdn abc_path ps
# abcopt_path = abc_path % (0,size abc_path-4) +++ "opt.abc"
# ps = showInfo (Level2 ("Optimising ABC for '" +++ mdn.mdn_name +++ "'.")) ps
# (h,ps) = acc_world_instead_of_ps (runProcess abcopt [abc_path,"-o",abcopt_path] Nothing) ps
# (h,ps) = acc_world_instead_of_ps (runProcessIO abcopt [abc_path,"-o",abcopt_path] Nothing) ps
| isError h = (False, updateErrorWindow ["failed to execute the ABC optimiser"] ps)
# (r,ps) = acc_world_instead_of_ps (waitForProcess (fromOk h)) ps
# (h,io) = fromOk h
# (r,ps) = acc_world_instead_of_ps (waitForProcess h) ps
| isError r = (False, updateErrorWindow ["failed to wait for the ABC optimiser"] ps)
# ps = processIOToErrorWindow io ps
| fromOk r <> 0 = (False, updateErrorWindow ["ABC optimiser failed with non-zero exit code " +++ toString (fromOk r) +++ " for " +++ mdn.mdn_name] ps)
= (True, ps)
......@@ -1691,10 +1694,12 @@ ByteCodeGen use_optimised_abc mdn abc_path ps
bc_path = abc_path % (0,size abc_path-4) +++ "bc"
# ps = showInfo (Level2 ("Generating bytecode for '" +++ mdn.mdn_name +++ "'.")) ps
# (h,ps) = acc_world_instead_of_ps (runProcess bcgen [if use_optimised_abc abcopt_path abc_path,"-o",bc_path] Nothing) ps
# (h,ps) = acc_world_instead_of_ps (runProcessIO bcgen [if use_optimised_abc abcopt_path abc_path,"-o",bc_path] Nothing) ps
| isError h = (False, updateErrorWindow ["failed to execute the bytecode generator"] ps)
# (r,ps) = acc_world_instead_of_ps (waitForProcess (fromOk h)) ps
# (h,io) = fromOk h
# (r,ps) = acc_world_instead_of_ps (waitForProcess h) ps
| isError r = (False, updateErrorWindow ["failed to wait for the bytecode generator"] ps)
# ps = processIOToErrorWindow io ps
| fromOk r <> 0 = (False, updateErrorWindow ["bytecode generator failed with non-zero exit code " +++ toString (fromOk r) +++ " for " +++ mdn.mdn_name] ps)
= (True, ps)
......@@ -1712,9 +1717,20 @@ ByteCodeLink fileinfo project ps
abcpaths = [root:removeMember root abcpaths]
# ps = showInfo (Level2 ("Linking bytecode for '" +++ RemovePath bcpath +++ "'")) ps
# (h,ps) = acc_world_instead_of_ps (runProcess bclink (abcpaths ++ ["-o",bcpath]) Nothing) ps
# (h,ps) = acc_world_instead_of_ps (runProcessIO bclink (abcpaths ++ ["-o",bcpath]) Nothing) ps
| isError h = (False, updateErrorWindow ["failed to execute the bytecode linker"] ps)
# (r,ps) = acc_world_instead_of_ps (waitForProcess (fromOk h)) ps
# (h,io) = fromOk h
# (r,ps) = acc_world_instead_of_ps (waitForProcess h) ps
| isError r = (False, updateErrorWindow ["failed to wait for the bytecode linker"] ps)
# ps = processIOToErrorWindow io ps
| fromOk r <> 0 = (False, updateErrorWindow ["bytecode linker failed with non-zero exit code " +++ toString (fromOk r)] ps)
= (True, ps)
processIOToErrorWindow :: !ProcessIO !*GeneralSt -> *GeneralSt
processIOToErrorWindow io ps
# (out,ps) = acc_world_instead_of_ps (readPipeBlocking io.stdOut) ps
# (err,ps) = acc_world_instead_of_ps (readPipeBlocking io.stdErr) ps
| isError out || isError err = updateErrorWindow ["failed to get process output"] ps
# ps = showInfo (Level3 [s \\ s <- split "\n" (fromOk err) | size s > 1]) ps // 1, to also strip \r
# ps = showInfo (Level3 [s \\ s <- split "\n" (fromOk out) | size s > 1]) ps
= ps
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