Skip to content

Commit

Permalink
rework process unit
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jun 7, 2024
1 parent 22a27bc commit 76a050b
Show file tree
Hide file tree
Showing 14 changed files with 619 additions and 650 deletions.
2 changes: 1 addition & 1 deletion DocGen/docgen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ begin
CleanAPI();
BuildAPI();

WriteLn('Sphinx exit code: ', RunCommand('sphinx-build', ['-q', '-E', 'DocGen/source', 'DocGen/build'], SphinxOutput));
WriteLn('Sphinx exit code: ', RunProcess('sphinx-build', ['-q', '-E', 'DocGen/source', 'DocGen/build'], SphinxOutput));
if (SphinxOutput <> '') then
WriteLn(SphinxOutput);

Expand Down
4 changes: 2 additions & 2 deletions Source/ide/simba.ide_codetools_setup.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ implementation

uses
simba.base, simba.ide_codetools_parser, simba.ide_codetools_insight,
simba.ide_initialization, simba.process, simba.env, simba.ide_events;
simba.ide_initialization, simba.ide_utils, simba.env, simba.ide_events;

procedure SetupCodeTools;
var
Expand All @@ -25,7 +25,7 @@ procedure SetupCodeTools;
List := nil;

try
List := SimbaProcess.RunDump(Application.ExeName, ['--dumpcompiler']);
List := RunDump(Application.ExeName, ['--dumpcompiler']);

for I := 0 to List.Count - 1 do
begin
Expand Down
4 changes: 2 additions & 2 deletions Source/ide/simba.ide_maintoolbar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ procedure TSimbaMainToolBar.DoClickWindowSelector(Sender: TObject; Button: TMous
DebugLn([EDebugLn.FOCUS], ' - Dimensions: %dx%d', [FWindowSelection.GetBounds().Width - 1, FWindowSelection.GetBounds().Height - 1]);
DebugLn([EDebugLn.FOCUS], ' - Title: "%s"', [FWindowSelection.GetTitle()]);
DebugLn([EDebugLn.FOCUS], ' - Class: "%s"', [FWindowSelection.GetClassName()]);
DebugLn([EDebugLn.FOCUS], ' - PID: %d (%s)', [FWindowSelection.GetPID(), BoolToStr(SimbaProcess.IsProcess64Bit(FWindowSelection.GetPID()), '64 bit', '32 bit')]);
DebugLn([EDebugLn.FOCUS], ' - Executable: "%s"', [SimbaProcess.GetProcessPath(FWindowSelection.GetPID())]);
DebugLn([EDebugLn.FOCUS], ' - PID: %d (%s)', [FWindowSelection.GetPID(), BoolToStr(IsProcess64Bit(FWindowSelection.GetPID()), '64 bit', '32 bit')]);
DebugLn([EDebugLn.FOCUS], ' - Executable: "%s"', [GetProcessPath(FWindowSelection.GetPID())]);

SimbaIDEEvents.Notify(SimbaIDEEvent.WINDOW_SELECTED, Self);
except
Expand Down
32 changes: 31 additions & 1 deletion Source/ide/simba.ide_utils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface
function ImageWidthForDPI(DPI: Integer): Integer;
procedure MenuItemHeight(Item: TMenuItem; Canvas: TCanvas; var Height: Integer);

function RunDump(FileName: String; Commands: TStringArray): TStringList;

type
TApplicationHelper = class helper for TApplication
public type
Expand All @@ -40,7 +42,7 @@ TRunInThread = class(TThread)
implementation

uses
simba.settings;
simba.settings, simba.process, simba.fs, simba.env;

function ImageWidthForDPI(DPI: Integer): Integer;
begin
Expand Down Expand Up @@ -74,6 +76,34 @@ procedure MenuItemHeight(Item: TMenuItem; Canvas: TCanvas; var Height: Integer);
end;
end;

function RunDump(FileName: String; Commands: TStringArray): TStringList;
var
DumpFileName, Output: String;
begin
DumpFileName := SimbaEnv.DumpsPath + TSimbaFile.FileHash(FileName);

Result := TStringList.Create();
Result.LineBreak := #0;

if FileExists(DumpFileName) then
Result.LoadFromFile(DumpFileName)
else
begin
try
if not RunProcessTimeout(Application.ExeName, Commands + [DumpFileName], 5000, Output) then
SimbaException('Timed out');

Result.LoadFromFile(DumpFileName);
except
on E: Exception do
if (Output <> '') then
SimbaException(E.Message + ': ' + Output)
else
SimbaException(E.Message);
end;
end;
end;

function TApplicationHelper.RunInThreadAndWait(Proc: TProcedureNested): String;
begin
Result := '';
Expand Down
Loading

0 comments on commit 76a050b

Please sign in to comment.