mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 16:19:28 +02:00
* Remove knowledge of directorycache from compiler
git-svn-id: trunk@40423 -
This commit is contained in:
parent
b60cbf3329
commit
77446cfe07
packages/pastojs/src
@ -394,7 +394,6 @@ type
|
||||
FCurrentCfgFilename: string;
|
||||
FCurrentCfgLineNumber: integer;
|
||||
FDefines: TStrings; // Objects can be TMacroDef
|
||||
FDirectoryCache: TPas2jsCachedDirectories;
|
||||
FFileCache: TPas2jsFilesCache;
|
||||
FFileCacheAutoFree: boolean;
|
||||
FFiles: TPasAnalyzerKeySet; // set of TPas2jsCompilerFile, key is PasFilename
|
||||
@ -543,7 +542,6 @@ type
|
||||
function FindUnitWithName(const TheUnitName: string): TPas2jsCompilerFile;
|
||||
procedure AddUsedUnit(aFile: TPas2jsCompilerFile);
|
||||
|
||||
function DirectoryExists(const Filename: string): boolean;
|
||||
function ExpandFileName(const Filename: string): string;
|
||||
public
|
||||
property CompilerExe: string read FCompilerExe write SetCompilerExe;
|
||||
@ -552,7 +550,6 @@ type
|
||||
property CurrentCfgLineNumber: integer read FCurrentCfgLineNumber;
|
||||
property DefaultNamespace: String read GetDefaultNamespace;
|
||||
property Defines: TStrings read FDefines;
|
||||
property DirectoryCache: TPas2jsCachedDirectories read FDirectoryCache;
|
||||
property FileCache: TPas2jsFilesCache read FFileCache write SetFileCache;
|
||||
property FileCacheAutoFree: boolean read FFileCacheAutoFree write FFileCacheAutoFree;
|
||||
property FileCount: integer read GetFileCount;
|
||||
@ -1389,7 +1386,7 @@ begin
|
||||
|
||||
// check output directory
|
||||
DestDir:=ChompPathDelim(ExtractFilePath(PCUFilename));
|
||||
if (DestDir<>'') and not Compiler.DirectoryExists(DestDir) then
|
||||
if (DestDir<>'') and not Compiler.FileCache.DirectoryExists(DestDir) then
|
||||
begin
|
||||
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
|
||||
writeln('TPas2jsCompilerFile.WritePCU output dir not found "',DestDir,'"');
|
||||
@ -1397,7 +1394,7 @@ begin
|
||||
Log.LogMsg(nOutputDirectoryNotFound,[QuoteStr(Compiler.FileCache.FormatPath(DestDir))]);
|
||||
Compiler.Terminate(ExitCodeFileNotFound);
|
||||
end;
|
||||
if Compiler.DirectoryExists(PCUFilename) then
|
||||
if Compiler.FileCache.DirectoryExists(PCUFilename) then
|
||||
begin
|
||||
{$IF defined(VerboseUnitQueue) or defined(VerbosePCUFiler)}
|
||||
writeln('TPas2jsCompilerFile.WritePCU file is folder "',DestDir,'"');
|
||||
@ -2327,10 +2324,10 @@ begin
|
||||
Mark(nUnitNeedsCompileDueToOption,[aFile.GetModuleName,'-B'])
|
||||
else if FileCache.AllJSIntoMainJS then
|
||||
Mark(nUnitNeedsCompileDueToOption,[aFile.GetModuleName,'-Jc'])
|
||||
else if (aFile.JSFilename<>'') and (not DirectoryCache.FileExists(aFile.JSFilename)) then
|
||||
else if (aFile.JSFilename<>'') and (not FileCache.FileExists(aFile.JSFilename)) then
|
||||
Mark(nUnitNeedsCompileJSMissing,[aFile.GetModuleName,FileCache.FormatPath(aFile.JSFilename)])
|
||||
else if (aFile.JSFilename<>'')
|
||||
and (DirectoryCache.FileAge(aFile.PasFilename)>DirectoryCache.FileAge(aFile.JSFilename))
|
||||
and (FileCache.FileAge(aFile.PasFilename)>FileCache.FileAge(aFile.JSFilename))
|
||||
then begin
|
||||
Mark(nUnitNeedsCompilePasHasChanged,[aFile.GetModuleName,QuoteStr(FileCache.FormatPath(aFile.JSFilename))])
|
||||
end;
|
||||
@ -2421,7 +2418,7 @@ begin
|
||||
for i:=0 to SrcMap.SourceCount-1 do begin
|
||||
LocalFilename:=SrcMap.SourceFiles[i];
|
||||
if LocalFilename='' then continue;
|
||||
if SrcMapInclude and DirectoryCache.FileExists(LocalFilename) then
|
||||
if SrcMapInclude and FileCache.FileExists(LocalFilename) then
|
||||
begin
|
||||
// include source in SrcMap
|
||||
aFile:=FileCache.LoadFile(LocalFilename);
|
||||
@ -3250,7 +3247,7 @@ procedure TPas2jsCompiler.LoadDefaultConfig;
|
||||
aFilename:=ExpandFileName(aFilename);
|
||||
if ShowDebug or ShowTriedUsedFiles then
|
||||
Log.LogMsgIgnoreFilter(nConfigFileSearch,[aFilename]);
|
||||
if not DirectoryCache.FileExists(aFilename) then exit;
|
||||
if not FileCache.FileExists(aFilename) then exit;
|
||||
Result:=true;
|
||||
LoadConfig(aFilename);
|
||||
end;
|
||||
@ -3800,7 +3797,7 @@ begin
|
||||
if aFilename='' then
|
||||
ParamFatal('invalid config file at param position '+IntToStr(i));
|
||||
aFilename:=ExpandFileName(aFilename);
|
||||
if not DirectoryCache.FileExists(aFilename) then
|
||||
if not FileCache.FileExists(aFilename) then
|
||||
ParamFatal('config file not found: "'+copy(Param,2,length(Param))+'"');
|
||||
LoadConfig(aFilename);
|
||||
end;
|
||||
@ -4094,7 +4091,7 @@ begin
|
||||
Exe:=Cmd[0];
|
||||
if ShowDebug or ShowUsedTools then
|
||||
Log.LogMsgIgnoreFilter(nPostProcessorRunX,[QuoteStr(JSFilename)+' | '+CmdListAsStr(Cmd)]);
|
||||
if DirectoryCache.DirectoryExists(Exe) then
|
||||
if FileCache.DirectoryExists(Exe) then
|
||||
raise EFOpenError.Create('post processor "'+Exe+'" is a directory');
|
||||
if not FileIsExecutable(Exe) then
|
||||
raise EFOpenError.Create('post processor "'+Exe+'" is a not executable');
|
||||
@ -4467,7 +4464,7 @@ begin
|
||||
|
||||
if FileCache.MainSrcFile='' then
|
||||
ParamFatal('No source file name in command line');
|
||||
if not DirectoryCache.FileExists(FileCache.MainSrcFile) then
|
||||
if not FileCache.FileExists(FileCache.MainSrcFile) then
|
||||
ParamFatal('Pascal file not found: "'+FileCache.MainSrcFile+'"');
|
||||
|
||||
// compile
|
||||
@ -4893,7 +4890,7 @@ begin
|
||||
aFile:=FindUnitWithFile(UnitFilename);
|
||||
if aFile<>nil then exit;
|
||||
|
||||
if (UnitFilename='') or not DirectoryCache.FileExists(UnitFilename) then
|
||||
if (UnitFilename='') or not FileCache.FileExists(UnitFilename) then
|
||||
begin
|
||||
{$IFDEF HasPas2jsFiler}
|
||||
if aFormat=nil then
|
||||
@ -4905,7 +4902,7 @@ begin
|
||||
end;
|
||||
|
||||
UnitFilename:=ExpandFileName(UnitFilename);
|
||||
if DirectoryCache.DirectoryExists(UnitFilename) then
|
||||
if FileCache.DirectoryExists(UnitFilename) then
|
||||
begin
|
||||
Log.LogMsg(nFileIsFolder,[QuoteStr(UnitFilename)]);
|
||||
Terminate(ExitCodeFileNotFound);
|
||||
@ -4977,10 +4974,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPas2jsCompiler.DirectoryExists(const Filename: string): boolean;
|
||||
begin
|
||||
Result:=FileCache.DirectoryCache.DirectoryExists(Filename);
|
||||
end;
|
||||
|
||||
function TPas2jsCompiler.ExpandFileName(const Filename: string): string;
|
||||
begin
|
||||
|
@ -330,6 +330,10 @@ type
|
||||
function CreateResolver: TPas2jsFileResolver;
|
||||
function FormatPath(const aPath: string): string;
|
||||
function GetResolvedMainJSFile: string;
|
||||
Function DirectoryExists(Filename: string): boolean; virtual;
|
||||
function FileExists(Filename: string): boolean; virtual;
|
||||
function FileExistsI(var Filename: string): integer; // returns number of found files
|
||||
function FileAge(const Filename: string): TPas2jsFileAgeTime; virtual;
|
||||
function FindFile(Filename: string): TPas2jsCachedFile;
|
||||
function LoadFile(Filename: string; Binary: boolean = false): TPas2jsCachedFile;
|
||||
function NormalizeFilename(const Filename: string; RaiseOnError: boolean): string;
|
||||
@ -683,7 +687,7 @@ begin
|
||||
end;
|
||||
|
||||
function TPas2jsCachedDirectory.Add(const Name: string;
|
||||
Time: TPas2jsFileAgeTime; Attr: TPas2jsFileAttr; Size: TPas2jsFileSize
|
||||
Time: TPas2jsFileAgeTime; Attr: TPas2jsFileAttr; Size: TPas2jsFileSize
|
||||
): TPas2jsCachedDirectoryEntry;
|
||||
begin
|
||||
Result:=TPas2jsCachedDirectoryEntry.Create;
|
||||
@ -1244,12 +1248,12 @@ begin
|
||||
{$ENDIF}
|
||||
// needs (re)load
|
||||
Result:=false;
|
||||
if not Cache.DirectoryCache.FileExists(Filename) then
|
||||
if not Cache.FileExists(Filename) then
|
||||
begin
|
||||
Err('File not found "'+Filename+'"');
|
||||
exit;
|
||||
end;
|
||||
if Cache.DirectoryCache.DirectoryExists(Filename) then
|
||||
if Cache.DirectoryExists(Filename) then
|
||||
begin
|
||||
Err('File is a directory "'+Filename+'"');
|
||||
exit;
|
||||
@ -1384,10 +1388,10 @@ begin
|
||||
Result:=nil;
|
||||
CurFilename:=aFilename;
|
||||
if StrictFileCase or Cache.SearchLikeFPC then
|
||||
Found:=Cache.DirectoryCache.FileExists(CurFilename)
|
||||
Found:=Cache.FileExists(CurFilename)
|
||||
else
|
||||
begin
|
||||
i:=Cache.DirectoryCache.FileExistsI(CurFilename);
|
||||
i:=Cache.FileExistsI(CurFilename);
|
||||
Found:=i=1;
|
||||
if i>1 then
|
||||
Cache.RaiseDuplicateFile(CurFilename);
|
||||
@ -1526,7 +1530,7 @@ end;
|
||||
|
||||
function TPas2jsFileResolver.FileExistsLogged(const Filename: string): boolean;
|
||||
begin
|
||||
Result:=Cache.DirectoryCache.FileExists(Filename);
|
||||
Result:=Cache.FileExists(Filename);
|
||||
if Cache.ShowTriedUsedFiles then
|
||||
if Result then
|
||||
Cache.Log.LogMsgIgnoreFilter(nSearchingFileFound,[Cache.FormatPath(Filename)])
|
||||
@ -1883,7 +1887,7 @@ procedure TPas2jsFilesCache.FindMatchingFiles(Mask: string; MaxCount: integer;
|
||||
inc(p);
|
||||
end;
|
||||
// mask has no placeholder -> search directly
|
||||
if DirectoryCache.FileExists(aMask) then
|
||||
if FileExists(aMask) then
|
||||
begin
|
||||
if Files.Count>=MaxCount then
|
||||
TooMany(20180126091913);
|
||||
@ -2056,6 +2060,26 @@ begin
|
||||
Result:=FMainJSFileResolved;
|
||||
end;
|
||||
|
||||
function TPas2jsFilesCache.DirectoryExists(Filename: string): boolean;
|
||||
begin
|
||||
Result:=DirectoryCache.DirectoryExists(FileName);
|
||||
end;
|
||||
|
||||
function TPas2jsFilesCache.FileExists(Filename: string): boolean;
|
||||
begin
|
||||
Result:=DirectoryCache.FileExists(FileName);
|
||||
end;
|
||||
|
||||
function TPas2jsFilesCache.FileExistsI(var Filename: string): integer;
|
||||
begin
|
||||
Result:=DirectoryCache.FileExistsI(FileName);
|
||||
end;
|
||||
|
||||
function TPas2jsFilesCache.FileAge(const Filename: string): TPas2jsFileAgeTime;
|
||||
begin
|
||||
Result:=DirectoryCache.FileAge(FileName);
|
||||
end;
|
||||
|
||||
function TPas2jsFilesCache.FindFile(Filename: string): TPas2jsCachedFile;
|
||||
begin
|
||||
Filename:=NormalizeFilename(Filename,true);
|
||||
@ -2065,8 +2089,7 @@ end;
|
||||
function TPas2jsFilesCache.LoadFile(Filename: string; Binary: boolean
|
||||
): TPas2jsCachedFile;
|
||||
begin
|
||||
Filename:=NormalizeFilename(Filename,true);
|
||||
Result:=TPas2jsCachedFile(FFiles.FindKey(Pointer(Filename)));
|
||||
Result:=FindFile(FileName);
|
||||
if Result=nil then
|
||||
begin
|
||||
// new file
|
||||
@ -2217,9 +2240,9 @@ begin
|
||||
i:=GetLastOSError;
|
||||
if i<>0 then
|
||||
Log.LogPlain('Note: '+SysErrorMessage(i));
|
||||
if not DirectoryCache.DirectoryExists(ChompPathDelim(ExtractFilePath(Filename))) then
|
||||
if not DirectoryExists(ChompPathDelim(ExtractFilePath(Filename))) then
|
||||
Log.LogPlain('Note: file cache inconsistency: folder does not exist "'+ChompPathDelim(ExtractFilePath(Filename))+'"');
|
||||
if DirectoryCache.FileExists(Filename) and not FileIsWritable(Filename) then
|
||||
if FileExists(Filename) and not FileIsWritable(Filename) then
|
||||
Log.LogPlain('Note: file is not writable "'+Filename+'"');
|
||||
raise;
|
||||
end;
|
||||
@ -2247,7 +2270,7 @@ function TPas2jsFilesCache.ExpandExecutable(const Filename, BaseDir: string
|
||||
begin
|
||||
Result:=false;
|
||||
CurFilename:=ResolveDots(CurFilename);
|
||||
if not DirectoryCache.FileExists(CurFilename) then exit;
|
||||
if not FileExists(CurFilename) then exit;
|
||||
ExpandExecutable:=CurFilename;
|
||||
Result:=true;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user