mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 18:20:00 +02:00
IDE: more details why the IDE does not like the compiler file
git-svn-id: trunk@44295 -
This commit is contained in:
parent
4c8bf0291a
commit
1489dc5cb6
@ -928,7 +928,7 @@ function GetCompiledTargetCPU: string;
|
||||
function GetDefaultCompilerFilename(const TargetCPU: string = ''; Cross: boolean = false): string;
|
||||
function GetFPCTargetOS(TargetOS: string): string;
|
||||
function GetFPCTargetCPU(TargetCPU: string): string;
|
||||
function IsFPCExecutable(AFilename: string): boolean;
|
||||
function IsFPCExecutable(AFilename: string; out ErrorMsg: string): boolean;
|
||||
|
||||
// functions to quickly setup some defines
|
||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||
@ -2781,21 +2781,35 @@ begin
|
||||
Result:=LowerCase(TargetCPU);
|
||||
end;
|
||||
|
||||
function IsFPCExecutable(AFilename: string): boolean;
|
||||
function IsFPCExecutable(AFilename: string; out ErrorMsg: string): boolean;
|
||||
var
|
||||
ShortFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
AFilename:=ResolveDots(aFilename);
|
||||
//debugln(['IsFPCExecutable ',AFilename]);
|
||||
//debugln(['IsFPCompiler START ',aFilename]);
|
||||
if aFilename='' then
|
||||
if aFilename='' then begin
|
||||
ErrorMsg:='missing file name';
|
||||
exit;
|
||||
if not FileExistsCached(AFilename) then
|
||||
end;
|
||||
if not FilenameIsAbsolute(AFilename) then begin
|
||||
ErrorMsg:='file missing path';
|
||||
exit;
|
||||
if DirPathExistsCached(AFilename) then
|
||||
end;
|
||||
if not FileExistsCached(AFilename) then begin
|
||||
ErrorMsg:='file not found';
|
||||
exit;
|
||||
if not FileIsExecutableCached(AFilename) then
|
||||
end;
|
||||
if DirPathExistsCached(AFilename) then begin
|
||||
ErrorMsg:='file is a directory';
|
||||
exit;
|
||||
end;
|
||||
if not FileIsExecutableCached(AFilename) then begin
|
||||
ErrorMsg:='file is not executable';
|
||||
exit;
|
||||
end;
|
||||
ErrorMsg:='';
|
||||
|
||||
// allow scripts like fpc.sh and fpc.bat
|
||||
ShortFilename:=ExtractFileNameOnly(AFilename);
|
||||
@ -2808,6 +2822,8 @@ begin
|
||||
and ((ExeExt='') or (LazFileUtils.CompareFileExt(ShortFilename,ExeExt)=0))
|
||||
then
|
||||
exit(true);
|
||||
|
||||
ErrorMsg:='unknown file name';
|
||||
end;
|
||||
|
||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||
@ -8510,12 +8526,13 @@ function TFPCDefinesCache.GetFPCVersion(const CompilerFilename, TargetOS,
|
||||
TargetCPU: string; UseCompiledVersionAsDefault: boolean): string;
|
||||
var
|
||||
CfgCache: TFPCTargetConfigCache;
|
||||
ErrorMsg: string;
|
||||
begin
|
||||
if UseCompiledVersionAsDefault then
|
||||
Result:={$I %FPCVersion%}
|
||||
else
|
||||
Result:='';
|
||||
if not IsFPCExecutable(CompilerFilename) then exit;
|
||||
if not IsFPCExecutable(CompilerFilename,ErrorMsg) then exit;
|
||||
CfgCache:=ConfigCaches.Find(CompilerFilename,ExtraOptions,TargetOS,TargetCPU,true);
|
||||
if not CfgCache.Update(TestFilename,ExtraOptions) then exit;
|
||||
if CfgCache.FullVersion='' then exit;
|
||||
|
@ -596,6 +596,8 @@ begin
|
||||
end;
|
||||
|
||||
function TBuildManager.GetFPCompilerFilename: string;
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
Result:='';
|
||||
if (Project1<>nil)
|
||||
@ -605,7 +607,7 @@ begin
|
||||
Result:=Project1.GetCompilerFilename;
|
||||
//debugln(['TBuildManager.GetFPCompilerFilename project compiler="',Result,'"']);
|
||||
end;
|
||||
if not IsFPCExecutable(Result) then begin
|
||||
if not IsFPCExecutable(Result,s) then begin
|
||||
//if Result<>'' then debugln(['TBuildManager.GetFPCompilerFilename project compiler NOT fpc: "',Result,'"']);
|
||||
Result:=EnvironmentOptions.GetParsedCompilerFilename;
|
||||
end;
|
||||
@ -792,6 +794,8 @@ var
|
||||
AsyncScanFPCSrcDir: String;
|
||||
UnitSetChanged: Boolean;
|
||||
HasTemplate: Boolean;
|
||||
FPCExecMsg: string;
|
||||
Msg: String;
|
||||
begin
|
||||
if ClearCaches then begin
|
||||
{$IFDEF VerboseFPCSrcScan}
|
||||
@ -848,10 +852,28 @@ begin
|
||||
end;
|
||||
|
||||
// then check the project's compiler
|
||||
if not IsFPCExecutable(CompilerFilename) then begin
|
||||
debugln(['WARNING: TBuildManager.RescanCompilerDefines: it is not fpc: ',CompilerFilename]);
|
||||
if not IsFPCExecutable(CompilerFilename,FPCExecMsg) then begin
|
||||
Msg:='';
|
||||
if (Project1<>nil)
|
||||
and ([crCompile,crBuild]*Project1.CompilerOptions.CompileReasons<>[])
|
||||
and (Project1.CompilerOptions.CompilerPath<>'')
|
||||
then begin
|
||||
CompilerFilename:=Project1.GetCompilerFilename;
|
||||
if not IsFPCExecutable(CompilerFilename,FPCExecMsg) then begin
|
||||
Msg+='Project''s compiler: "'+CompilerFilename+'": '+FPCExecMsg+#13;
|
||||
end;
|
||||
end;
|
||||
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
|
||||
if not IsFPCExecutable(CompilerFilename,FPCExecMsg) then begin
|
||||
Msg+='Environment compiler: "'+CompilerFilename+'": '+FPCExecMsg+#13;
|
||||
end;
|
||||
debugln('WARNING: TBuildManager.RescanCompilerDefines: invalid compiler:');
|
||||
debugln(Msg);
|
||||
if not Quiet then begin
|
||||
IDEMessageDialog('Error','There is no Free Pascal Compiler (e.g. fpc'+ExeExt+' or ppc<cpu>'+ExeExt+') configured in the environment options. Codetools will not work properly.',mtError,[mbCancel]);
|
||||
IDEMessageDialog('Error','There is no Free Pascal Compiler'
|
||||
+' (e.g. fpc'+ExeExt+' or ppc<cpu>'+ExeExt+') configured in the'
|
||||
+' environment options. Codetools will not work properly.'#13
|
||||
+Msg,mtError,[mbCancel]);
|
||||
end;
|
||||
UnitSetCache:=nil;
|
||||
exit;
|
||||
@ -2016,6 +2038,7 @@ function TBuildManager.MacroFuncFPCVer(const Param: string; const Data: PtrInt;
|
||||
TargetCPU: String;
|
||||
CompilerFilename: String;
|
||||
ConfigCache: TFPCTargetConfigCache;
|
||||
s: string;
|
||||
begin
|
||||
if OverrideFPCVer<>'' then
|
||||
exit(OverrideFPCVer);
|
||||
@ -2024,7 +2047,7 @@ function TBuildManager.MacroFuncFPCVer(const Param: string; const Data: PtrInt;
|
||||
// fetch the FPC version from the current compiler
|
||||
// Not from the fpc.exe, but from the real compiler
|
||||
CompilerFilename:=GetFPCompilerFilename;
|
||||
if not IsFPCExecutable(CompilerFilename) then exit;
|
||||
if not IsFPCExecutable(CompilerFilename,s) then exit;
|
||||
TargetOS:=GetTargetOS;
|
||||
TargetCPU:=GetTargetCPU;
|
||||
ConfigCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
|
||||
|
@ -2482,6 +2482,7 @@ var
|
||||
DefaultTargetOS: string;
|
||||
DefaultTargetCPU: string;
|
||||
FPCompilerFilename: String;
|
||||
s: string;
|
||||
begin
|
||||
CurMainSrcFile:=MainSourceFileName;
|
||||
if CurMainSrcFile='' then
|
||||
@ -2833,7 +2834,7 @@ begin
|
||||
Switches := Switches + ' -OoREGVAR';
|
||||
|
||||
CompilerFilename:=ParsedOpts.GetParsedValue(pcosCompilerPath);
|
||||
if IsFPCExecutable(CompilerFilename) then
|
||||
if IsFPCExecutable(CompilerFilename,s) then
|
||||
FPCompilerFilename:=CompilerFilename
|
||||
else
|
||||
FPCompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
|
||||
|
@ -69,6 +69,7 @@ var
|
||||
AFilename: string;
|
||||
Quality: TSDFilenameQuality;
|
||||
Note: string;
|
||||
s: string;
|
||||
begin
|
||||
OpenDialog:=TOpenDialog.Create(nil);
|
||||
try
|
||||
@ -85,7 +86,7 @@ begin
|
||||
|
||||
if Sender=BrowseCompilerButton then begin
|
||||
// check compiler filename
|
||||
if IsFPCExecutable(AFilename) then begin
|
||||
if IsFPCExecutable(AFilename,s) then begin
|
||||
// check compiler
|
||||
Quality:=CheckCompilerQuality(AFilename,Note,
|
||||
CodeToolBoss.FPCDefinesCache.TestFilename);
|
||||
|
Loading…
Reference in New Issue
Block a user