From 1323dd35bc9b372978eb3ab005aaf0c0987243b6 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 11 Jan 2011 16:41:54 +0000 Subject: [PATCH] IDE: added check for missing real compiler git-svn-id: trunk@28962 - --- components/codetools/definetemplates.pas | 15 +++--- ide/buildmanager.pas | 43 ++++++++++++++--- ide/fpcsrcscan.pas | 61 ++++++++++++++++-------- ide/lazarusidestrconsts.pas | 2 + ide/progresswnd.pas | 1 + 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 87a7f0b75a..67a4643b65 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -6966,6 +6966,7 @@ begin SrcRule:=Rules[i]; Rule:=Add(SrcRule.Filename); Rule.Assign(SrcRule); + //debugln(['TFPCSourceRules.Assign ',i,' ',Rule.Targets,' ',Rule.Filename]); end; IncreaseChangeStamp; end; @@ -7573,11 +7574,11 @@ begin // fpc searches via PATH for the real compiler, resolves any symlink // and that is the RealCompiler // check if PATH - AFilename:=FindRealCompilerInPath(TargetCPU,true); - if RealCompilerInPath<>AFilename then begin - debugln(['TFPCTargetConfigCache.NeedsUpdate real compiler in PATH changed from "',RealCompilerInPath,'" to "',AFilename,'"']); - exit; - end; + end; + AFilename:=FindRealCompilerInPath(TargetCPU,true); + if RealCompilerInPath<>AFilename then begin + debugln(['TFPCTargetConfigCache.NeedsUpdate real compiler in PATH changed from "',RealCompilerInPath,'" to "',AFilename,'"']); + exit; end; for i:=0 to ConfigFiles.Count-1 do begin Cfg:=ConfigFiles[i]; @@ -7661,8 +7662,10 @@ begin for i:=0 to UnitPaths.Count-1 do UnitPaths[i]:=ChompPathDelim(TrimFilename(UnitPaths[i])); // store the real compiler file and date - if (RealCompiler<>'') and FileExistsCached(RealCompiler) then + if (RealCompiler<>'') and FileExistsCached(RealCompiler) then begin RealCompilerDate:=FileAgeCached(RealCompiler); + end else + debugln(['TFPCTargetConfigCache.Update WARNING: compiler is broken: '+Compiler+' '+ExtraOptions]); // store the list of tried and read cfg files if CfgFiles<>nil then begin for i:=0 to CfgFiles.Count-1 do begin diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index fc76d23c84..c1d6469d44 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -584,6 +584,33 @@ var Result:=true; end; + function PPUFilesAndCompilerMatch: boolean; + // check if compiler is in another directory than the ppu files + // for example: a 'make install' installs to /usr/local/lib/fpc + // while the rpm/deb packages install to /usr/lib + var + Cfg: TFPCTargetConfigCache; + Filename: String; + begin + Cfg:=UnitSetCache.GetConfigCache(false); + if Cfg=nil then exit(true); + if Cfg.RealCompiler='' then begin + debugln(['PPUFilesAndCompilerMatch Compiler=',Cfg.Compiler,' RealComp=',Cfg.RealCompiler,' InPath=',Cfg.RealCompilerInPath]); + IDEMessageDialog(lisCCOErrorCaption, Format( + lisCompilerDoesNotSupportTarget, [Cfg.Compiler, Cfg.TargetOS, Cfg. + TargetCPU]), + mtError,[mbOk]); + exit(false); + end; + Filename:=ReadAllLinks(Cfg.RealCompiler,false); + if (Filename='') then begin + IDEMessageDialog('Error','Compiler executable is missing: '+Cfg.RealCompiler, + mtError,[mbOk]); + exit(false); + end; + Result:=true; + end; + begin if ClearCaches then begin { $IFDEF VerboseFPCSrcScan} @@ -690,12 +717,10 @@ begin CodeToolBoss.DefineTree.ClearCache; if not Quiet then begin - if not FoundSystemPPU then begin - IDEMessageDialog(lisCCOErrorCaption, - Format(lisTheProjectUsesTargetOSAndCPUTheSystemPpuForThisTar, [ - TargetOS, TargetCPU, #13, #13]), - mtError,[mbOk]); - end else if (UnitSetCache<>nil) then begin + // check for common installation mistakes + if not PPUFilesAndCompilerMatch then exit; + if (UnitSetCache<>nil) then begin + // check if at least one fpc config is there if UnitSetCache.GetFirstFPCCfg='' then begin IgnorePath:='MissingFPCCfg_'+TargetOS+'-'+TargetCPU; if (InputHistories<>nil) and (InputHistories.Ignores.Find(IgnorePath)=nil) @@ -707,6 +732,12 @@ begin InputHistories.Ignores.Add(IgnorePath,iiidIDERestart); end; end; + end else if not FoundSystemPPU then begin + // system.ppu is missing + IDEMessageDialog(lisCCOErrorCaption, + Format(lisTheProjectUsesTargetOSAndCPUTheSystemPpuForThisTar, [ + TargetOS, TargetCPU, #13, #13]), + mtError,[mbOk]); end; end; end; diff --git a/ide/fpcsrcscan.pas b/ide/fpcsrcscan.pas index f8f3b48e3c..4dec2294d2 100644 --- a/ide/fpcsrcscan.pas +++ b/ide/fpcsrcscan.pas @@ -41,9 +41,12 @@ type TFPCSrcScan = class(TThread) protected + fLogMsg: string; Files: TStringList; procedure Execute; override; procedure OnFilesGathered; // main thread, called after thread has collected Files + procedure MainThreadLog; + procedure Log(Msg: string); public Directory: string; Scans: TFPCSrcScans; @@ -76,39 +79,59 @@ implementation procedure TFPCSrcScan.Execute; begin try + Log('TFPCSrcScan.Execute AAA1'); // scan fpc source directory, check for terminated Files:=GatherFilesInFPCSources(Directory,nil); - //debugln(['TFPCSrcScan.Execute ',Files<>nil]); - // let main thread update the codetools fpc source cache - Synchronize(@OnFilesGathered); + Log('TFPCSrcScan.Execute '+dbgs(Files<>nil)); except on E: Exception do begin - debugln(['TFPCSrcScan.Execute error: ',E.Message]); + Log('TFPCSrcScan.Execute error: '+E.Message); end; end; + if Files=nil then + Files:=TStringList.Create; + // let main thread update the codetools fpc source cache + Synchronize(@OnFilesGathered); end; procedure TFPCSrcScan.OnFilesGathered; var SrcCache: TFPCSourceCache; begin - //debugln(['TFPCSrcScan.OnFilesGathered ',Directory,' FileCount=',Files.Count]); - // copy Files to codetools cache - if CodeToolBoss<>nil then - begin - SrcCache:=CodeToolBoss.FPCDefinesCache.SourceCaches.Find(Directory,true); - SrcCache.Update(Files); + try + debugln(['TFPCSrcScan.OnFilesGathered ',Directory,' FileCount=',Files.Count]); + // copy Files to codetools cache + if CodeToolBoss<>nil then + begin + SrcCache:=CodeToolBoss.FPCDefinesCache.SourceCaches.Find(Directory,true); + debugln(['TFPCSrcScan.OnFilesGathered SrcCache.Update ...']); + SrcCache.Update(Files); - //debugln(['TFPCSrcScan.OnFilesGathered BuildBoss.RescanCompilerDefines ...']); - if BuildBoss<>nil then - BuildBoss.RescanCompilerDefines(false,false,false,true); + debugln(['TFPCSrcScan.OnFilesGathered BuildBoss.RescanCompilerDefines ...']); + if BuildBoss<>nil then + BuildBoss.RescanCompilerDefines(false,false,false,true); + end; + FreeAndNil(Files); + // delete item in progress window + debugln(['TFPCSrcScan.OnFilesGathered closing progress item ...']); + FreeAndNil(ProgressItem); + Scans.Remove(Self); + debugln(['TFPCSrcScan.OnFilesGathered END']); + except + on E: Exception do + debugln(['TFPCSrcScan.OnFilesGathered ERROR: ',E.Message]); end; - FreeAndNil(Files); - // delete item in progress window - //debugln(['TFPCSrcScan.OnFilesGathered closing progress item ...']); - FreeAndNil(ProgressItem); - Scans.Remove(Self); - //debugln(['TFPCSrcScan.OnFilesGathered END']); +end; + +procedure TFPCSrcScan.MainThreadLog; +begin + debugln(fLogMsg); +end; + +procedure TFPCSrcScan.Log(Msg: string); +begin + fLogMsg:=Msg; + Synchronize(@MainThreadLog); end; { TFPCSrcScans } diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 3a8304bf7f..61e74b34f6 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1926,6 +1926,8 @@ resourcestring dlgCCOTestMissingPPU = 'Test: Checking missing fpc ppu ...'; dlgCCOTestCompilerDate = 'Test: Checking compiler date ...'; lisCCOErrorCaption = 'Error'; + lisCompilerDoesNotSupportTarget = 'Compiler "%s" does not support target %' + +'s-%s'; lisInvalidMode = 'Invalid mode %s'; lisTheProjectCompilerOptionsAndTheDirectivesInTheMain = 'The project ' +'compiler options and the directives in the main source differ. For the ' diff --git a/ide/progresswnd.pas b/ide/progresswnd.pas index ef6070d002..1924172354 100644 --- a/ide/progresswnd.pas +++ b/ide/progresswnd.pas @@ -259,6 +259,7 @@ begin FreeAndNil(Items[i].fPanel); FItems.Delete(i); end; + debugln(['TIDEProgressWindow.Notification ',Count]); if Count=0 then Hide; finally