Ignore:
Timestamp:
Aug 20, 2024, 12:20:49 AM (3 months ago)
Author:
chronos
Message:
  • Fixed: All targets compilation and run.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.