Ignore:
Timestamp:
Dec 3, 2014, 10:45:24 PM (9 years ago)
Author:
chronos
Message:
  • Added: Free Pascal Compiler as supported target.
  • Added: Log window to examine output from background execute compilers.
  • Fixed: Execution of targets except Java target.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target/UTarget.pas

    r58 r60  
    6969    cmOutput, cmInput, cmLoopStart, cmLoopEnd, cmDebug);
    7070
     71  TLogEvent = procedure (Lines: TStrings) of object;
     72
    7173  { TTarget }
    7274
    7375  TTarget = class
     76  private
     77    FOnLog: TLogEvent;
    7478  protected
    7579    FCompiled: Boolean;
     
    101105    ExecutorPath: string;
    102106    SourceExtension: string;
     107    RunExtension: string;
    103108    CompiledExtension: string;
    104109    ProjectFileName: string;
     
    124129    procedure SaveToRegistry(Root: HKEY; Key: string); virtual;
    125130    property State: TRunState read FState write SetState;
    126     property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
    127131    property SourceCode: string write SetSourceCode;
    128132    property TargetCode: string read GetTargetCode;
     
    130134    property ExecutionPosition: Integer read GetExecutionPosition;
    131135    property ProgramIndex: Integer read FProgramIndex;
     136    property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
     137    property OnLog: TLogEvent read FOnLog write FOnLog;
    132138  end;
    133139
     
    396402  Process: TProcess;
    397403  CompiledFile: string;
     404  Lines: TStringList;
     405  I: Integer;
    398406begin
    399407  CompiledFile := ExtractFilePath(ProjectFileName) +
     
    412420    try
    413421      Process := TProcess.Create(nil);
    414       Process.CurrentDirectory := ExtractFilePath(CompilerPath);
    415       Process.CommandLine := LongFileName(CompilerPath) + ' ' + LongFileName(CompiledFile);
    416       Process.Options := [poWaitOnExit];
     422      Process.CurrentDirectory := ExtractFilePath(CompiledFile);
     423      Process.Executable := LongFileName(CompilerPath);
     424      Process.Parameters.Add(LongFileName(CompiledFile));
     425      for I := 0 to GetEnvironmentVariableCount - 1 do
     426        Process.Environment.Add(GetEnvironmentString(I));
     427      Process.Options := [poWaitOnExit, poUsePipes];
    417428      Process.Execute;
     429      if Assigned(FOnLog) then begin
     430        Lines := TStringList.Create;
     431        Lines.LoadFromStream(Process.Output);
     432        Lines.Insert(0, Process.Executable + ' ' + Process.Parameters.Text);
     433        FOnLog(Lines);
     434        Lines.Free;
     435      end;
    418436    finally
    419437      Process.Free;
     
    426444  Process: TProcess;
    427445  CompiledFile: string;
     446  RunFile: string;
    428447begin
    429448  CompiledFile := ExtractFilePath(ProjectFileName) +
    430449    'compiled' + DirectorySeparator + Name + DirectorySeparator +
    431450    ExtractFileNameOnly(ProjectFileName) + CompiledExtension;
     451  RunFile := ExtractFilePath(ProjectFileName) +
     452    'compiled' + DirectorySeparator + Name + DirectorySeparator +
     453    ExtractFileNameOnly(ProjectFileName) + RunExtension;
    432454  if FileExistsUTF8(CompiledFile) then
    433455  try
    434456    Process := TProcess.Create(nil);
    435     if ExecutorPath <> '' then Process.CommandLine := LongFileName(ExecutorPath) + ' ';
    436     Process.CommandLine := Process.CommandLine + LongFileName(CompiledFile);
    437     Process.Options := [poWaitOnExit];
     457    if ExecutorPath <> '' then begin
     458      Process.Executable := LongFileName(ExecutorPath);
     459      Process.Parameters.Add(LongFileName(RunFile));
     460    end else Process.Executable := LongFileName(RunFile);
     461    Process.ShowWindow := swoShow;
     462    Process.Options := [poWaitOnExit, poNewConsole];
    438463    Process.Execute;
    439464  finally
Note: See TracChangeset for help on using the changeset viewer.