Changeset 161 for trunk/Target/TargetC.pas
- Timestamp:
- Aug 20, 2024, 12:20:49 AM (3 months ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.