Changeset 161 for trunk/Target/TargetRust.pas
- Timestamp:
- Aug 20, 2024, 12:20:49 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.