mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 02:49:19 +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 GetDefaultCompilerFilename(const TargetCPU: string = ''; Cross: boolean = false): string;
|
||||||
function GetFPCTargetOS(TargetOS: string): string;
|
function GetFPCTargetOS(TargetOS: string): string;
|
||||||
function GetFPCTargetCPU(TargetCPU: 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
|
// functions to quickly setup some defines
|
||||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||||
@ -2781,21 +2781,35 @@ begin
|
|||||||
Result:=LowerCase(TargetCPU);
|
Result:=LowerCase(TargetCPU);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IsFPCExecutable(AFilename: string): boolean;
|
function IsFPCExecutable(AFilename: string; out ErrorMsg: string): boolean;
|
||||||
var
|
var
|
||||||
ShortFilename: String;
|
ShortFilename: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
AFilename:=ResolveDots(aFilename);
|
AFilename:=ResolveDots(aFilename);
|
||||||
|
//debugln(['IsFPCExecutable ',AFilename]);
|
||||||
//debugln(['IsFPCompiler START ',aFilename]);
|
//debugln(['IsFPCompiler START ',aFilename]);
|
||||||
if aFilename='' then
|
if aFilename='' then begin
|
||||||
|
ErrorMsg:='missing file name';
|
||||||
exit;
|
exit;
|
||||||
if not FileExistsCached(AFilename) then
|
end;
|
||||||
|
if not FilenameIsAbsolute(AFilename) then begin
|
||||||
|
ErrorMsg:='file missing path';
|
||||||
exit;
|
exit;
|
||||||
if DirPathExistsCached(AFilename) then
|
end;
|
||||||
|
if not FileExistsCached(AFilename) then begin
|
||||||
|
ErrorMsg:='file not found';
|
||||||
exit;
|
exit;
|
||||||
if not FileIsExecutableCached(AFilename) then
|
end;
|
||||||
|
if DirPathExistsCached(AFilename) then begin
|
||||||
|
ErrorMsg:='file is a directory';
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
|
if not FileIsExecutableCached(AFilename) then begin
|
||||||
|
ErrorMsg:='file is not executable';
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
ErrorMsg:='';
|
||||||
|
|
||||||
// allow scripts like fpc.sh and fpc.bat
|
// allow scripts like fpc.sh and fpc.bat
|
||||||
ShortFilename:=ExtractFileNameOnly(AFilename);
|
ShortFilename:=ExtractFileNameOnly(AFilename);
|
||||||
@ -2808,6 +2822,8 @@ begin
|
|||||||
and ((ExeExt='') or (LazFileUtils.CompareFileExt(ShortFilename,ExeExt)=0))
|
and ((ExeExt='') or (LazFileUtils.CompareFileExt(ShortFilename,ExeExt)=0))
|
||||||
then
|
then
|
||||||
exit(true);
|
exit(true);
|
||||||
|
|
||||||
|
ErrorMsg:='unknown file name';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||||
@ -8510,12 +8526,13 @@ function TFPCDefinesCache.GetFPCVersion(const CompilerFilename, TargetOS,
|
|||||||
TargetCPU: string; UseCompiledVersionAsDefault: boolean): string;
|
TargetCPU: string; UseCompiledVersionAsDefault: boolean): string;
|
||||||
var
|
var
|
||||||
CfgCache: TFPCTargetConfigCache;
|
CfgCache: TFPCTargetConfigCache;
|
||||||
|
ErrorMsg: string;
|
||||||
begin
|
begin
|
||||||
if UseCompiledVersionAsDefault then
|
if UseCompiledVersionAsDefault then
|
||||||
Result:={$I %FPCVersion%}
|
Result:={$I %FPCVersion%}
|
||||||
else
|
else
|
||||||
Result:='';
|
Result:='';
|
||||||
if not IsFPCExecutable(CompilerFilename) then exit;
|
if not IsFPCExecutable(CompilerFilename,ErrorMsg) then exit;
|
||||||
CfgCache:=ConfigCaches.Find(CompilerFilename,ExtraOptions,TargetOS,TargetCPU,true);
|
CfgCache:=ConfigCaches.Find(CompilerFilename,ExtraOptions,TargetOS,TargetCPU,true);
|
||||||
if not CfgCache.Update(TestFilename,ExtraOptions) then exit;
|
if not CfgCache.Update(TestFilename,ExtraOptions) then exit;
|
||||||
if CfgCache.FullVersion='' then exit;
|
if CfgCache.FullVersion='' then exit;
|
||||||
|
@ -596,6 +596,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TBuildManager.GetFPCompilerFilename: string;
|
function TBuildManager.GetFPCompilerFilename: string;
|
||||||
|
var
|
||||||
|
s: string;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if (Project1<>nil)
|
if (Project1<>nil)
|
||||||
@ -605,7 +607,7 @@ begin
|
|||||||
Result:=Project1.GetCompilerFilename;
|
Result:=Project1.GetCompilerFilename;
|
||||||
//debugln(['TBuildManager.GetFPCompilerFilename project compiler="',Result,'"']);
|
//debugln(['TBuildManager.GetFPCompilerFilename project compiler="',Result,'"']);
|
||||||
end;
|
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,'"']);
|
//if Result<>'' then debugln(['TBuildManager.GetFPCompilerFilename project compiler NOT fpc: "',Result,'"']);
|
||||||
Result:=EnvironmentOptions.GetParsedCompilerFilename;
|
Result:=EnvironmentOptions.GetParsedCompilerFilename;
|
||||||
end;
|
end;
|
||||||
@ -792,6 +794,8 @@ var
|
|||||||
AsyncScanFPCSrcDir: String;
|
AsyncScanFPCSrcDir: String;
|
||||||
UnitSetChanged: Boolean;
|
UnitSetChanged: Boolean;
|
||||||
HasTemplate: Boolean;
|
HasTemplate: Boolean;
|
||||||
|
FPCExecMsg: string;
|
||||||
|
Msg: String;
|
||||||
begin
|
begin
|
||||||
if ClearCaches then begin
|
if ClearCaches then begin
|
||||||
{$IFDEF VerboseFPCSrcScan}
|
{$IFDEF VerboseFPCSrcScan}
|
||||||
@ -848,10 +852,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// then check the project's compiler
|
// then check the project's compiler
|
||||||
if not IsFPCExecutable(CompilerFilename) then begin
|
if not IsFPCExecutable(CompilerFilename,FPCExecMsg) then begin
|
||||||
debugln(['WARNING: TBuildManager.RescanCompilerDefines: it is not fpc: ',CompilerFilename]);
|
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
|
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;
|
end;
|
||||||
UnitSetCache:=nil;
|
UnitSetCache:=nil;
|
||||||
exit;
|
exit;
|
||||||
@ -2016,6 +2038,7 @@ function TBuildManager.MacroFuncFPCVer(const Param: string; const Data: PtrInt;
|
|||||||
TargetCPU: String;
|
TargetCPU: String;
|
||||||
CompilerFilename: String;
|
CompilerFilename: String;
|
||||||
ConfigCache: TFPCTargetConfigCache;
|
ConfigCache: TFPCTargetConfigCache;
|
||||||
|
s: string;
|
||||||
begin
|
begin
|
||||||
if OverrideFPCVer<>'' then
|
if OverrideFPCVer<>'' then
|
||||||
exit(OverrideFPCVer);
|
exit(OverrideFPCVer);
|
||||||
@ -2024,7 +2047,7 @@ function TBuildManager.MacroFuncFPCVer(const Param: string; const Data: PtrInt;
|
|||||||
// fetch the FPC version from the current compiler
|
// fetch the FPC version from the current compiler
|
||||||
// Not from the fpc.exe, but from the real compiler
|
// Not from the fpc.exe, but from the real compiler
|
||||||
CompilerFilename:=GetFPCompilerFilename;
|
CompilerFilename:=GetFPCompilerFilename;
|
||||||
if not IsFPCExecutable(CompilerFilename) then exit;
|
if not IsFPCExecutable(CompilerFilename,s) then exit;
|
||||||
TargetOS:=GetTargetOS;
|
TargetOS:=GetTargetOS;
|
||||||
TargetCPU:=GetTargetCPU;
|
TargetCPU:=GetTargetCPU;
|
||||||
ConfigCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
|
ConfigCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
|
||||||
|
@ -2482,6 +2482,7 @@ var
|
|||||||
DefaultTargetOS: string;
|
DefaultTargetOS: string;
|
||||||
DefaultTargetCPU: string;
|
DefaultTargetCPU: string;
|
||||||
FPCompilerFilename: String;
|
FPCompilerFilename: String;
|
||||||
|
s: string;
|
||||||
begin
|
begin
|
||||||
CurMainSrcFile:=MainSourceFileName;
|
CurMainSrcFile:=MainSourceFileName;
|
||||||
if CurMainSrcFile='' then
|
if CurMainSrcFile='' then
|
||||||
@ -2833,7 +2834,7 @@ begin
|
|||||||
Switches := Switches + ' -OoREGVAR';
|
Switches := Switches + ' -OoREGVAR';
|
||||||
|
|
||||||
CompilerFilename:=ParsedOpts.GetParsedValue(pcosCompilerPath);
|
CompilerFilename:=ParsedOpts.GetParsedValue(pcosCompilerPath);
|
||||||
if IsFPCExecutable(CompilerFilename) then
|
if IsFPCExecutable(CompilerFilename,s) then
|
||||||
FPCompilerFilename:=CompilerFilename
|
FPCompilerFilename:=CompilerFilename
|
||||||
else
|
else
|
||||||
FPCompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
|
FPCompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
|
||||||
|
@ -69,6 +69,7 @@ var
|
|||||||
AFilename: string;
|
AFilename: string;
|
||||||
Quality: TSDFilenameQuality;
|
Quality: TSDFilenameQuality;
|
||||||
Note: string;
|
Note: string;
|
||||||
|
s: string;
|
||||||
begin
|
begin
|
||||||
OpenDialog:=TOpenDialog.Create(nil);
|
OpenDialog:=TOpenDialog.Create(nil);
|
||||||
try
|
try
|
||||||
@ -85,7 +86,7 @@ begin
|
|||||||
|
|
||||||
if Sender=BrowseCompilerButton then begin
|
if Sender=BrowseCompilerButton then begin
|
||||||
// check compiler filename
|
// check compiler filename
|
||||||
if IsFPCExecutable(AFilename) then begin
|
if IsFPCExecutable(AFilename,s) then begin
|
||||||
// check compiler
|
// check compiler
|
||||||
Quality:=CheckCompilerQuality(AFilename,Note,
|
Quality:=CheckCompilerQuality(AFilename,Note,
|
||||||
CodeToolBoss.FPCDefinesCache.TestFilename);
|
CodeToolBoss.FPCDefinesCache.TestFilename);
|
||||||
|
Loading…
Reference in New Issue
Block a user