Changeset 161 for trunk/Target
- Timestamp:
- Aug 20, 2024, 12:20:49 AM (4 months ago)
- Location:
- trunk/Target
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/TargetC.pas
r146 r161 15 15 function GetMemoryCell: string; 16 16 public 17 function GetCompileParams: TStringArray; override; 17 18 constructor Create; override; 18 19 procedure Compile; override; 19 procedure CompileToFile; override;20 20 procedure Run; override; 21 21 end; … … 23 23 24 24 implementation 25 26 uses 27 Common; 25 28 26 29 { TTargetC } … … 36 39 CompilerPath := 'c:\Program Files\MinGW\bin\gcc.exe'; 37 40 FCompiledExtension := '.exe'; 38 FRunExtension := '';39 41 {$ENDIF} 40 42 {$IFDEF UNIX} 41 43 CompilerPath := '/usr/bin/gcc'; 42 44 FCompiledExtension := ''; 43 FRunExtension := '';44 45 {$ENDIF} 45 46 end; … … 53 54 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 54 55 Result := Result + ']'; 56 end; 57 58 function TTargetC.GetCompileParams: TStringArray; 59 begin 60 Result := [GetSourceFileName, '-o', GetCompileFileName]; 55 61 end; 56 62 … … 101 107 end; 102 108 103 procedure TTargetC.CompileToFile;104 var105 Process: TProcess;106 CompiledFile: string;107 begin108 CompiledFile := ExtractFilePath(ProjectFileName) +109 CompiledDir + DirectorySeparator + Name + DirectorySeparator +110 ExtractFileNameOnly(ProjectFileName) + SourceExtension;111 ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));112 with TStringList.Create do113 try114 Text := FTargetCode;115 SaveToFile(CompiledFile);116 finally117 Free;118 end;119 if FileExistsUTF8(CompilerPath) then120 try121 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 finally130 Process.Free;131 end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));132 end;133 134 109 procedure TTargetC.Run; 135 110 begin -
trunk/Target/TargetCSharp.pas
r153 r161 30 30 FSourceExtension := '.cs'; 31 31 FCompiledExtension := '.exe'; 32 FRunExtension := '.exe';33 32 FImageIndex := 27; 34 33 FCapabilities := [tcCompile, tcRun]; -
trunk/Target/TargetDelphi.pas
r146 r161 29 29 FSourceExtension := '.pas'; 30 30 FImageIndex := 22; 31 FCapabilities := [tcCompile]; 32 {$IFDEF Windows} 31 33 FCapabilities := [tcCompile, tcRun]; 32 {$IFDEF Windows}33 34 CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE'; 34 35 FCompiledExtension := '.exe'; 35 FRunExtension := '';36 36 {$ENDIF} 37 37 end; -
trunk/Target/TargetFPC.pas
r146 r161 33 33 FCompiledExtension := '.exe'; 34 34 CompilerPath := 'fpc.exe'; 35 FRunExtension := '';36 35 {$ENDIF} 37 36 {$IFDEF UNIX} 38 37 FCompiledExtension := ''; 39 38 CompilerPath := '/usr/bin/fpc'; 40 FRunExtension := '';41 39 {$ENDIF} 42 40 end; -
trunk/Target/TargetJava.pas
r153 r161 4 4 5 5 uses 6 Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs ;6 Classes, SysUtils, FileUtil, Target, BFTarget, Dialogs, LazFileUtils; 7 7 8 8 type … … 14 14 function GetMemoryCell: string; 15 15 public 16 function GetRunParams: TStringArray; override; 16 17 constructor Create; override; 17 18 procedure Compile; override; … … 30 31 FSourceExtension := '.java'; 31 32 FCompiledExtension := '.class'; 32 FRunExtension := '.class';33 33 FImageIndex := 24; 34 34 FCapabilities := [tcCompile, tcRun]; … … 51 51 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 52 52 Result := Result + ']'; 53 end; 54 55 function TTargetJava.GetRunParams: TStringArray; 56 begin 57 Result := ['-classpath', ExtractFileDir(GetCompileFileName), ExtractFileNameOnly(GetCompileFileName)]; 53 58 end; 54 59 -
trunk/Target/TargetJavascript.pas
r145 r161 36 36 CompilerPath := ''; 37 37 FCompiledExtension := ''; 38 FRunExtension := '';39 38 end; 40 39 -
trunk/Target/TargetPHP.pas
r145 r161 29 29 FName := 'PHP'; 30 30 FSourceExtension := '.php'; 31 FRunExtension := '.php';32 31 FCompiledExtension := '.php'; 33 32 FImageIndex := 21; -
trunk/Target/TargetPython.pas
r148 r161 29 29 FName := 'Python'; 30 30 FSourceExtension := '.py'; 31 FRunExtension := '.py';32 31 FCompiledExtension := '.py'; 33 32 FImageIndex := 26; -
trunk/Target/TargetRust.pas
r150 r161 15 15 function GetMemoryCell: string; 16 16 public 17 function GetCompileParams: TStringArray; override; 17 18 constructor Create; override; 18 19 procedure Compile; override; 19 procedure CompileToFile; override;20 20 procedure Run; override; 21 21 end; … … 23 23 24 24 implementation 25 26 uses 27 Common; 25 28 26 29 { TTargetRust } … … 36 39 CompilerPath := 'c:\Program Files\Rust\rustc.exe'; 37 40 FCompiledExtension := '.exe'; 38 FRunExtension := '';39 41 {$ENDIF} 40 42 {$IFDEF UNIX} 41 43 CompilerPath := '/usr/bin/rustc'; 42 44 FCompiledExtension := ''; 43 FRunExtension := '';44 45 {$ENDIF} 45 46 end; … … 53 54 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 54 55 Result := Result + ']'; 56 end; 57 58 function TTargetRust.GetCompileParams: TStringArray; 59 begin 60 Result := [GetSourceFileName, '-o', GetCompileFileName]; 55 61 end; 56 62 … … 110 116 end; 111 117 112 procedure TTargetRust.CompileToFile;113 var114 Process: TProcess;115 CompiledFile: string;116 begin117 CompiledFile := ExtractFilePath(ProjectFileName) +118 CompiledDir + DirectorySeparator + Name + DirectorySeparator +119 ExtractFileNameOnly(ProjectFileName) + SourceExtension;120 ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));121 with TStringList.Create do122 try123 Text := FTargetCode;124 SaveToFile(CompiledFile);125 finally126 Free;127 end;128 if FileExistsUTF8(CompilerPath) then129 try130 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 finally139 Process.Free;140 end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));141 end;142 143 118 procedure TTargetRust.Run; 144 119 begin
Note:
See TracChangeset
for help on using the changeset viewer.