Commit 0e0c2e94 authored by Camil Staps's avatar Camil Staps 🐧

Workaround for System.Process issues on 64-bit Windows

parent 3d9f35cb
implementation module PmDriver
import StdArray,StdBool,StdList,StdMisc,StdEnum,StdStrictLists
import StdArray,StdBool,StdList,StdMisc,StdEnum,StdStrictLists,StdTuple
from StdOverloadedList import Foldr,++|,Hd,Any
import UtilNewlinesFile, UtilIO
......@@ -22,7 +22,8 @@ from StdLibMisc import :: Date{..}, :: Time{..}
import Data.Error
import System.FilePath
import System.Process => qualified :: Either
from System.OS import IF_WINDOWS64
import System.Process => qualified :: Either(..)
from Text import class Text(split), instance Text String
verboseInfo verbose info ps :== verbi verbose info ps
......@@ -1677,10 +1678,10 @@ OptimiseABC mdn abc_path ps
# ps = showInfo (Level2 ("Optimising ABC for '" +++ mdn.mdn_name +++ "'.")) 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)
| isError h = (False, updateErrorWindow ["failed to execute the ABC optimiser: " +++ snd (fromError 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)
| isError r = (False, updateErrorWindow ["failed to wait for the ABC optimiser: " +++ snd (fromError r)] 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)
......@@ -1695,10 +1696,10 @@ ByteCodeGen use_optimised_abc mdn abc_path ps
# ps = showInfo (Level2 ("Generating bytecode for '" +++ mdn.mdn_name +++ "'.")) 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)
| isError h = (False, updateErrorWindow ["failed to execute the bytecode generator: " +++ snd (fromError 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)
| isError r = (False, updateErrorWindow ["failed to wait for the bytecode generator: " +++ snd (fromError r)] 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)
......@@ -1718,19 +1719,22 @@ ByteCodeLink fileinfo project ps
# ps = showInfo (Level2 ("Linking bytecode for '" +++ RemovePath bcpath +++ "'")) 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)
| isError h = (False, updateErrorWindow ["failed to execute the bytecode linker: " +++ snd (fromError 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)
| isError r = (False, updateErrorWindow ["failed to wait for the bytecode linker: " +++ snd (fromError r)] 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
| IF_WINDOWS64 True False = ps // FIXME: System.Process is broken on 64-bit windows (see Platform#65)
# (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
| isError out || isError err
= updateErrorWindow ["failed to get process output"] ps
# ps = updateErrorWindow [s \\ s <- split "\n" (fromOk err) | size s > 1] ps // 1, to also strip \r
# ps = updateErrorWindow [s \\ s <- split "\n" (fromOk out) | size s > 1] ps
# (_,ps) = acc_world_instead_of_ps (closeProcessIO io) 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