Index: CHANGES.txt ================================================================== --- CHANGES.txt +++ CHANGES.txt @@ -3,10 +3,11 @@ [Feature] Support for hdtbl. [Changed] Build extras and build preprocessors are now listed in a multi-select box. [Improved] If no error has occurred, the log file will contain a success message. [Improved] The default font looked gross on macOS. This should be better now. [Bugfix] Calling troff over the system default shell now, potentially finding more paths. +[Improved] BuildDocument uses a simpler execution approach now. ------------------------------- Version 0.12.0 2022-03-14 Index: src/buildoutputwindow.pas ================================================================== --- src/buildoutputwindow.pas +++ src/buildoutputwindow.pas @@ -42,68 +42,34 @@ {$R *.lfm} function TBuildStatusWindow.BuildDocument(CommandLine: String; LogFile: String): Boolean; var - p: TProcess; - n, total: LongInt; str: String; lh: TextFile; + ret: Boolean; begin - p := TProcess.Create(nil); - p.Options := p.Options + [poUsePipes, poStderrToOutPut]; - p.ShowWindow := swoHIDE; - - ShowMessage(CommandLine); - {$IFDEF WINDOWS} - p.Executable := 'cmd'; - p.Parameters.Add('/c'); + ret := RunCommand('cmd', ['/c', CommandLine], str, [], swoHIDE); {$ELSE} - p.Executable := '/bin/sh'; - p.Parameters.Add('-c'); + ret := RunCommand('sh', ['-c', CommandLine], str, [], swoHIDE); {$ENDIF} - p.Parameters.Add(CommandLine); - p.Execute; if LogFile <> '' then begin AssignFile(lh, LogFile); - Rewrite(lh); - - total := 0; - - while p.Running do - begin - n := p.Output.Read(str, 2048); - total := total + n; - if n > 0 then - begin - writeln(lh, str); - end - else Sleep(100); - end; - - { We might have some buffer contents left. } - repeat - n := p.Output.Read(str, 2048); - total := total + n; - if n > 0 then - begin - writeln(lh, str); - end; - until n <= 0; - - if total = 0 then writeln(lh, 'No errors occurred. :-)'); - - CloseFile(lh); - end; - - result := p.ExitStatus > 0; - p.Free; + try + ReWrite(lh); + Write(lh, str); + finally + CloseFile(lh); + end; + end; { Close the status window: } Close; + + Result := ret; end; end.