Changeset 161 for trunk/Target


Ignore:
Timestamp:
Aug 20, 2024, 12:20:49 AM (3 months ago)
Author:
chronos
Message:
  • Fixed: All targets compilation and run.
Location:
trunk/Target
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target/TargetC.pas

    r146 r161  
    1515    function GetMemoryCell: string;
    1616  public
     17    function GetCompileParams: TStringArray; override;
    1718    constructor Create; override;
    1819    procedure Compile; override;
    19     procedure CompileToFile; override;
    2020    procedure Run; override;
    2121  end;
     
    2323
    2424implementation
     25
     26uses
     27  Common;
    2528
    2629{ TTargetC }
     
    3639  CompilerPath := 'c:\Program Files\MinGW\bin\gcc.exe';
    3740  FCompiledExtension := '.exe';
    38   FRunExtension := '';
    3941  {$ENDIF}
    4042  {$IFDEF UNIX}
    4143  CompilerPath := '/usr/bin/gcc';
    4244  FCompiledExtension := '';
    43   FRunExtension := '';
    4445  {$ENDIF}
    4546end;
     
    5354    Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex));
    5455  Result := Result + ']';
     56end;
     57
     58function TTargetC.GetCompileParams: TStringArray;
     59begin
     60  Result := [GetSourceFileName, '-o', GetCompileFileName];
    5561end;
    5662
     
    101107end;
    102108
    103 procedure TTargetC.CompileToFile;
    104 var
    105   Process: TProcess;
    106   CompiledFile: string;
    107 begin
    108   CompiledFile := ExtractFilePath(ProjectFileName) +
    109     CompiledDir + DirectorySeparator + Name + DirectorySeparator +
    110     ExtractFileNameOnly(ProjectFileName) + SourceExtension;
    111   ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));
    112   with TStringList.Create do
    113   try
    114     Text := FTargetCode;
    115     SaveToFile(CompiledFile);
    116   finally
    117     Free;
    118   end;
    119   if FileExistsUTF8(CompilerPath) then
    120   try
    121     Process := TProcess.Create(nil);
    122     Process.CurrentDirectory := ExtractFilePath(CompilerPath);
    123     Process.Executable := LongFileName(CompilerPath);
    124     Process.Parameters.Add(LongFileName(CompiledFile));
    125     Process.Parameters.Add('-o');
    126     Process.Parameters.Add(LongFileName(ExtractFilePath(CompiledFile) + ExtractFileNameOnly(CompiledFile) + CompiledExtension));
    127     Process.Options := [poWaitOnExit];
    128     Process.Execute;
    129   finally
    130     Process.Free;
    131   end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));
    132 end;
    133 
    134109procedure TTargetC.Run;
    135110begin
  • trunk/Target/TargetCSharp.pas

    r153 r161  
    3030  FSourceExtension := '.cs';
    3131  FCompiledExtension := '.exe';
    32   FRunExtension := '.exe';
    3332  FImageIndex := 27;
    3433  FCapabilities := [tcCompile, tcRun];
  • trunk/Target/TargetDelphi.pas

    r146 r161  
    2929  FSourceExtension := '.pas';
    3030  FImageIndex := 22;
     31  FCapabilities := [tcCompile];
     32  {$IFDEF Windows}
    3133  FCapabilities := [tcCompile, tcRun];
    32   {$IFDEF Windows}
    3334  CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE';
    3435  FCompiledExtension := '.exe';
    35   FRunExtension := '';
    3636  {$ENDIF}
    3737end;
  • trunk/Target/TargetFPC.pas

    r146 r161  
    3333  FCompiledExtension := '.exe';
    3434  CompilerPath := 'fpc.exe';
    35   FRunExtension := '';
    3635  {$ENDIF}
    3736  {$IFDEF UNIX}
    3837  FCompiledExtension := '';
    3938  CompilerPath := '/usr/bin/fpc';
    40   FRunExtension := '';
    4139  {$ENDIF}
    4240end;
  • trunk/Target/TargetJava.pas

    r153 r161  
    44
    55uses
    6   Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs;
     6  Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs, LazFileUtils;
    77
    88type
     
    1414    function GetMemoryCell: string;
    1515  public
     16    function GetRunParams: TStringArray; override;
    1617    constructor Create; override;
    1718    procedure Compile; override;
     
    3031  FSourceExtension := '.java';
    3132  FCompiledExtension := '.class';
    32   FRunExtension := '.class';
    3333  FImageIndex := 24;
    3434  FCapabilities := [tcCompile, tcRun];
     
    5151    Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex));
    5252  Result := Result + ']';
     53end;
     54
     55function TTargetJava.GetRunParams: TStringArray;
     56begin
     57  Result := ['-classpath', ExtractFileDir(GetCompileFileName), ExtractFileNameOnly(GetCompileFileName)];
    5358end;
    5459
  • trunk/Target/TargetJavascript.pas

    r145 r161  
    3636  CompilerPath := '';
    3737  FCompiledExtension := '';
    38   FRunExtension := '';
    3938end;
    4039
  • trunk/Target/TargetPHP.pas

    r145 r161  
    2929  FName := 'PHP';
    3030  FSourceExtension := '.php';
    31   FRunExtension := '.php';
    3231  FCompiledExtension := '.php';
    3332  FImageIndex := 21;
  • trunk/Target/TargetPython.pas

    r148 r161  
    2929  FName := 'Python';
    3030  FSourceExtension := '.py';
    31   FRunExtension := '.py';
    3231  FCompiledExtension := '.py';
    3332  FImageIndex := 26;
  • trunk/Target/TargetRust.pas

    r150 r161  
    1515    function GetMemoryCell: string;
    1616  public
     17    function GetCompileParams: TStringArray; override;
    1718    constructor Create; override;
    1819    procedure Compile; override;
    19     procedure CompileToFile; override;
    2020    procedure Run; override;
    2121  end;
     
    2323
    2424implementation
     25
     26uses
     27  Common;
    2528
    2629{ TTargetRust }
     
    3639  CompilerPath := 'c:\Program Files\Rust\rustc.exe';
    3740  FCompiledExtension := '.exe';
    38   FRunExtension := '';
    3941  {$ENDIF}
    4042  {$IFDEF UNIX}
    4143  CompilerPath := '/usr/bin/rustc';
    4244  FCompiledExtension := '';
    43   FRunExtension := '';
    4445  {$ENDIF}
    4546end;
     
    5354    Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex));
    5455  Result := Result + ']';
     56end;
     57
     58function TTargetRust.GetCompileParams: TStringArray;
     59begin
     60  Result := [GetSourceFileName, '-o', GetCompileFileName];
    5561end;
    5662
     
    110116end;
    111117
    112 procedure TTargetRust.CompileToFile;
    113 var
    114   Process: TProcess;
    115   CompiledFile: string;
    116 begin
    117   CompiledFile := ExtractFilePath(ProjectFileName) +
    118     CompiledDir + DirectorySeparator + Name + DirectorySeparator +
    119     ExtractFileNameOnly(ProjectFileName) + SourceExtension;
    120   ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));
    121   with TStringList.Create do
    122   try
    123     Text := FTargetCode;
    124     SaveToFile(CompiledFile);
    125   finally
    126     Free;
    127   end;
    128   if FileExistsUTF8(CompilerPath) then
    129   try
    130     Process := TProcess.Create(nil);
    131     Process.CurrentDirectory := ExtractFilePath(CompilerPath);
    132     Process.Executable := LongFileName(CompilerPath);
    133     Process.Parameters.Add(LongFileName(CompiledFile));
    134     Process.Parameters.Add('-o');
    135     Process.Parameters.Add(LongFileName(ExtractFilePath(CompiledFile) + ExtractFileNameOnly(CompiledFile) + CompiledExtension));
    136     Process.Options := [poWaitOnExit];
    137     Process.Execute;
    138   finally
    139     Process.Free;
    140   end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));
    141 end;
    142 
    143118procedure TTargetRust.Run;
    144119begin
Note: See TracChangeset for help on using the changeset viewer.