Changeset 60 for trunk/Target


Ignore:
Timestamp:
Dec 3, 2014, 10:45:24 PM (10 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.
Location:
trunk/Target
Files:
1 added
5 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
  • trunk/Target/UTargetC.pas

    r52 r60  
    3131  Name := 'C';
    3232  SourceExtension := '.c';
    33   CompiledExtension := '.exe';
    3433  ImageIndex := 23;
    3534  Capabilities := [tcCompile, tcRun];
    3635  {$IFDEF Windows}
    3736  CompilerPath := 'c:\Program Files\MinGW\bin\gcc.exe';
     37  CompiledExtension := '.exe';
     38  RunExtension := '';
    3839  {$ENDIF}
    3940  {$IFDEF Linux}
    4041  CompilerPath := '/usr/bin/gcc';
     42  CompiledExtension := '';
     43  RunExtension := '';
    4144  {$ENDIF}
    4245end;
  • trunk/Target/UTargetDelphi.pas

    r52 r60  
    3030  SourceExtension := '.pas';
    3131  ImageIndex := 22;
    32   CompiledExtension := '.exe';
    3332  Capabilities := [tcCompile, tcRun];
    3433  {$IFDEF Windows}
    3534  CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE';
     35  CompiledExtension := '.exe';
     36  RunExtension := '';
    3637  {$ENDIF}
    3738end;
  • trunk/Target/UTargetJava.pas

    r52 r60  
    3131  SourceExtension := '.java';
    3232  CompiledExtension := '.class';
     33  RunExtension := '';
    3334  ImageIndex := 24;
    3435  Capabilities := [tcCompile, tcRun];
  • trunk/Target/UTargetPHP.pas

    r59 r60  
    3030  Name := 'PHP';
    3131  SourceExtension := '.php';
     32  RunExtension := '.php';
     33  CompiledExtension := '.php';
    3234  ImageIndex := 21;
    3335  Capabilities := [tcCompile, tcRun];
Note: See TracChangeset for help on using the changeset viewer.