You've already forked lazarus-ccr
instantfpc: compiler output: replace cache file name with source file name
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2029 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -54,6 +54,12 @@
|
|||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
<DebugInfoType Value="dsAuto"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<CompilerMessages>
|
<CompilerMessages>
|
||||||
<UseMsgFile Value="True"/>
|
<UseMsgFile Value="True"/>
|
||||||
|
@ -25,7 +25,7 @@ uses
|
|||||||
Classes, SysUtils, InstantFPTools;
|
Classes, SysUtils, InstantFPTools;
|
||||||
|
|
||||||
const
|
const
|
||||||
Version = '1.1';
|
Version = '1.2';
|
||||||
|
|
||||||
|
|
||||||
Procedure Usage;
|
Procedure Usage;
|
||||||
@ -189,7 +189,7 @@ begin
|
|||||||
if not IsCacheValid(Src,CacheFilename,OutputFilename) then begin
|
if not IsCacheValid(Src,CacheFilename,OutputFilename) then begin
|
||||||
// save source in cache to find out next time if something changed
|
// save source in cache to find out next time if something changed
|
||||||
Src.SaveToFile(CacheFilename);
|
Src.SaveToFile(CacheFilename);
|
||||||
Compile(CacheFilename,OutputFilename);
|
Compile(Filename,CacheFilename,OutputFilename);
|
||||||
end;
|
end;
|
||||||
// run
|
// run
|
||||||
if RunIt then
|
if RunIt then
|
||||||
|
@ -17,6 +17,10 @@ unit InstantFPTools;
|
|||||||
{$DEFINE UseExeSearch}
|
{$DEFINE UseExeSearch}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$if defined(Windows) or defined(darwin)}
|
||||||
|
{$define CaseInsensitiveFilenames}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -31,7 +35,8 @@ function GetCacheDir: string;
|
|||||||
procedure SetCacheDir(AValue : string);
|
procedure SetCacheDir(AValue : string);
|
||||||
function IsCacheValid(Src: TStringList;
|
function IsCacheValid(Src: TStringList;
|
||||||
const CachedSrcFile, CachedExeFile: string): boolean;
|
const CachedSrcFile, CachedExeFile: string): boolean;
|
||||||
procedure Compile(const CacheFilename, OutputFilename: string);
|
procedure Compile(const SrcFilename, CacheFilename, OutputFilename: string);
|
||||||
|
procedure WriteCompilerOutput(SrcFilename, CacheFilename, CompilerOutput: string);
|
||||||
function GetCompiler: string;
|
function GetCompiler: string;
|
||||||
procedure SetCompiler(AValue : string);
|
procedure SetCompiler(AValue : string);
|
||||||
function GetCompilerParameters(const SrcFilename, OutputFilename: string): string;
|
function GetCompilerParameters(const SrcFilename, OutputFilename: string): string;
|
||||||
@ -141,6 +146,41 @@ begin
|
|||||||
CmdCompiler:=AValue;
|
CmdCompiler:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure WriteCompilerOutput(SrcFilename, CacheFilename, CompilerOutput: string);
|
||||||
|
var
|
||||||
|
Lines: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
Line: String;
|
||||||
|
p: SizeInt;
|
||||||
|
begin
|
||||||
|
// replace in compiler output CacheFilename with SrcFilename
|
||||||
|
Lines:=TStringList.Create;
|
||||||
|
Lines.Text:=CompilerOutput;
|
||||||
|
{$IFDEF CaseInsensitiveFilenames}
|
||||||
|
CacheFilename:=LowerCase(CacheFilename);
|
||||||
|
{$ENDIF}
|
||||||
|
for i:=0 to Lines.Count-1 do begin
|
||||||
|
repeat
|
||||||
|
Line:=Lines[i];
|
||||||
|
{$IFDEF CaseInsensitiveFilenames}
|
||||||
|
Line:=LowerCase(Line);
|
||||||
|
{$ENDIF}
|
||||||
|
p:=Pos(CacheFilename,Line);
|
||||||
|
if p<1 then break;
|
||||||
|
{$IFDEF CaseInsensitiveFilenames}
|
||||||
|
Line:=Lines[i];
|
||||||
|
{$ENDIF}
|
||||||
|
Lines[i]:=copy(Line,1,p-1)+SrcFilename+copy(Line,p+length(CacheFilename),length(Line));
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// write to stdout
|
||||||
|
writeln(Lines.Text);
|
||||||
|
{$IFDEF IFFreeMem}
|
||||||
|
Lines.Free;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
function GetCompiler: string;
|
function GetCompiler: string;
|
||||||
var
|
var
|
||||||
CompFile: String;
|
CompFile: String;
|
||||||
@ -194,7 +234,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Compile(const CacheFilename, OutputFilename: string);
|
procedure Compile(const SrcFilename, CacheFilename, OutputFilename: string);
|
||||||
var
|
var
|
||||||
Compiler: String;
|
Compiler: String;
|
||||||
CompParams: String;
|
CompParams: String;
|
||||||
@ -222,7 +262,7 @@ begin
|
|||||||
ss.write(buf,count);
|
ss.write(buf,count);
|
||||||
until Count=0;
|
until Count=0;
|
||||||
if (not Proc.WaitOnExit) or (Proc.ExitStatus<>0) then begin
|
if (not Proc.WaitOnExit) or (Proc.ExitStatus<>0) then begin
|
||||||
write(ss.DataString);
|
WriteCompilerOutput(SrcFilename,CacheFilename,ss.DataString);
|
||||||
Halt(1);
|
Halt(1);
|
||||||
end;
|
end;
|
||||||
ss.Free;
|
ss.Free;
|
||||||
|
Reference in New Issue
Block a user