IDE: use compiler of project for FPCVer and codetools macro values

git-svn-id: trunk@44141 -
This commit is contained in:
mattias 2014-02-18 18:26:04 +00:00
parent fcf6ed2f5d
commit 88780a9aaa
10 changed files with 95 additions and 24 deletions

View File

@ -950,6 +950,7 @@ function ParseFPCInfo(FPCInfo: string; InfoTypes: TFPCInfoTypes;
out Infos: TFPCInfoStrings): boolean;
function RunFPCInfo(const CompilerFilename: string;
InfoTypes: TFPCInfoTypes; const Options: string =''): string;
function IsFPCompiler(AFilename: string): boolean;
function ExtractFPCFrontEndParameters(const CmdLine: string): string;
function SplitFPCVersion(const FPCVersionString: string;
out FPCVersion, FPCRelease, FPCPatch: integer): boolean;
@ -1359,6 +1360,35 @@ begin
end;
end;
function IsFPCompiler(aFilename: string): boolean;
var
ShortFilename: String;
begin
Result:=false;
AFilename:=ResolveDots(aFilename);
//debugln(['IsFPCompiler START ',aFilename]);
if aFilename='' then
exit;
if not FileExistsCached(AFilename) then
exit;
if DirPathExistsCached(AFilename) then
exit;
if not FileIsExecutableCached(AFilename) then
exit;
// allow scripts like fpc.sh and fpc.bat
ShortFilename:=ExtractFileNameOnly(AFilename);
//debugln(['IsFPCompiler Short=',ShortFilename]);
if CompareFilenames(ShortFilename,'fpc')=0 then
exit(true);
// allow ppcxxx.exe
if (CompareFilenames(copy(ShortFilename,1,3),'ppc')=0)
and ((ExeExt='') or (LazFileUtils.CompareFileExt(ShortFilename,ExeExt)=0))
then
exit(true);
end;
function ExtractFPCFrontEndParameters(const CmdLine: string): string;
// extract the parameters for the FPC frontend tool fpc.exe
// The result is normalized:

View File

@ -263,6 +263,7 @@ type
NewOwner: TObject; Flags: TSearchIDEFileFlags;
TryWithoutNumber: boolean): string; virtual; abstract;
function GetTestBuildDirectory: string; virtual; abstract;
function GetFPCompilerFilename: string; virtual; abstract;
// codetools
function BeginCodeTools: boolean; virtual; abstract;

View File

@ -54,6 +54,7 @@ type
function GetLCLWidgetType: string; virtual; abstract;
function GetRunCommandLine: string; virtual; abstract;
function GetFPCompilerFilename: string; virtual; abstract;
function GetProjectPublishDir: string; virtual; abstract;
function GetProjectTargetFilename(aProject: TProject): string; virtual; abstract;
function GetProjectUsesAppBundle: Boolean; virtual; abstract;

View File

@ -179,6 +179,7 @@ type
function GetLCLWidgetType: string; override;
function GetRunCommandLine: string; override;
function GetFPCompilerFilename: string; override;
function GetProjectPublishDir: string; override;
function GetProjectTargetFilename(aProject: TProject): string; override;
function GetProjectUsesAppBundle: Boolean; override;
@ -589,6 +590,22 @@ begin
end;
end;
function TBuildManager.GetFPCompilerFilename: string;
begin
Result:='';
if (Project1<>nil)
and ([crCompile,crBuild]*Project1.CompilerOptions.CompileReasons<>[])
and (Project1.CompilerOptions.CompilerPath<>'')
then begin
Result:=Project1.GetCompilerFilename;
//debugln(['TBuildManager.GetFPCompilerFilename project compiler="',Result,'"']);
end;
if not IsFPCompiler(Result) then begin
//if Result<>'' then debugln(['TBuildManager.GetFPCompilerFilename project compiler NOT fpc: "',Result,'"']);
Result:=EnvironmentOptions.GetParsedCompilerFilename;
end;
end;
function TBuildManager.GetProjectPublishDir: string;
begin
Result:='';
@ -786,10 +803,10 @@ begin
// use current TargetOS, TargetCPU, compilerfilename and FPC source dir
TargetOS:=GetTargetOS;
TargetCPU:=GetTargetCPU;
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
FPCSrcDir:=EnvironmentOptions.GetParsedFPCSourceDirectory; // needs FPCVer macro
CompilerFilename:=GetFPCompilerFilename;
{$IFDEF VerboseFPCSrcScan}
{ $IFDEF VerboseFPCSrcScan}
debugln(['TMainIDE.RescanCompilerDefines A ',
' CompilerFilename=',CompilerFilename,
' TargetOS=',TargetOS,
@ -798,22 +815,24 @@ begin
' FPCSrcDir=',FPCSrcDir,
' WaitTillDone=',WaitTillDone,
' Quiet=',Quiet,
' ClearCaches=',ClearCaches,
'']);
{$ENDIF}
if CompilerFilename='' then begin
UnitSetCache:=nil;
exit;
end;
{ $ENDIF}
// first check the default targetos, targetcpu of the default compiler
if FileExistsCached(EnvironmentOptions.GetParsedCompilerFilename) then
begin
// first check the default targetos, targetcpu of the default compiler
UnitSetCache:=CodeToolBoss.FPCDefinesCache.FindUnitSet(
EnvironmentOptions.GetParsedCompilerFilename,'','','',FPCSrcDir,true);
UnitSetCache.GetConfigCache(true);
end;
// then check the project's compiler
if not IsFPCompiler(CompilerFilename) then begin
UnitSetCache:=nil;
exit;
end;
// create a cache for the current project settings
UnitSetCache:=CodeToolBoss.FPCDefinesCache.FindUnitSet(
CompilerFilename,TargetOS,TargetCPU,'',FPCSrcDir,true);
@ -1951,8 +1970,8 @@ function TBuildManager.MacroFuncFPCVer(const Param: string; const Data: PtrInt;
if CodeToolBoss<>nil then begin
// fetch the FPC version from the current compiler
// Not from the fpc.exe, but from the real compiler
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
if CompilerFilename='' then exit;
CompilerFilename:=GetFPCompilerFilename;
if not IsFPCompiler(CompilerFilename) then exit;
TargetOS:=GetTargetOS;
TargetCPU:=GetTargetCPU;
ConfigCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(

View File

@ -45,7 +45,7 @@ uses
{$ELSE}
OutputFilter,
{$ENDIF}
UTF8Process, InfoBuild, IDEMsgIntf, CompOptsIntf,
UTF8Process, InfoBuild, IDEMsgIntf, CompOptsIntf, LazIDEIntf,
DefineTemplates, TransferMacros, EnvironmentOpts, LazFileUtils;
type
@ -1368,7 +1368,7 @@ var
begin
StartTime := Now;
try
fReader.CompilerExecutable := EnvironmentOptions.GetParsedCompilerFilename;
fReader.CompilerExecutable := LazarusIDE.GetFPCompilerFilename;
fReader.ReadAndParseOptions;
except
on E: Exception do

View File

@ -49,7 +49,8 @@ uses
ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, CompOptsIntf,
IDEOptionsIntf,
// IDE
LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros,
LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazIDEIntf, LazConf,
TransferMacros,
{$IFDEF EnableNewExtTools}
etFPCMsgParser,
{$ENDIF}
@ -2830,7 +2831,7 @@ begin
if (VariablesInRegisters) then
Switches := Switches + ' -OoREGVAR';
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
CompilerFilename:=LazarusIDE.GetFPCompilerFilename;
CodeToolBoss.FPCDefinesCache.ConfigCaches.GetDefaultCompilerTarget(
CompilerFilename,'',DefaultTargetOS,DefaultTargetCPU);

View File

@ -2040,6 +2040,7 @@ end;
function TEnvironmentOptions.MacroFuncCompPath(const s: string;
const Data: PtrInt; var Abort: boolean): string;
// CompPath returns the default compiler file name of the environment options
begin
Result:=GetParsedCompilerFilename;
end;

View File

@ -33,7 +33,7 @@ uses
Classes, SysUtils, AVL_Tree, FileUtil, lazutf8classes, Forms, Controls,
Graphics, Dialogs, StdCtrls, ComCtrls, FileProcs, DefineTemplates,
CodeToolManager, BaseBuildManager, Project, EnvironmentOpts,
LazarusIDEStrConsts, AboutFrm, IDEWindowIntf;
LazarusIDEStrConsts, AboutFrm, IDEWindowIntf, LazIDEIntf;
type
@ -114,7 +114,7 @@ begin
TargetOS:=BuildBoss.GetTargetOS;
TargetCPU:=BuildBoss.GetTargetCPU;
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
CompilerFilename:=LazarusIDE.GetFPCompilerFilename;
FPCSrcDir:=EnvironmentOptions.GetParsedFPCSourceDirectory; // needs FPCVer macro
UnitSetCache:=CodeToolBoss.FPCDefinesCache.FindUnitSet(
CompilerFilename,TargetOS,TargetCPU,'',FPCSrcDir,true);
@ -145,7 +145,7 @@ begin
List:=nil;
try
sl.Add('The IDE asks the compiler with the following command for the real OS/CPU:');
CompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
CompilerFilename:=LazarusIDE.GetFPCompilerFilename;
CompilerOptions:='';
Cfg:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
CompilerFilename,CompilerOptions,'','',true);
@ -241,8 +241,11 @@ begin
sl.add('Global IDE options:');
sl.Add('LazarusDirectory='+EnvironmentOptions.LazarusDirectory);
sl.Add('Resolved LazarusDirectory='+EnvironmentOptions.GetParsedLazarusDirectory);
sl.Add('CompilerFilename='+EnvironmentOptions.CompilerFilename);
sl.Add('Resolved CompilerFilename='+EnvironmentOptions.GetParsedCompilerFilename);
if Project1<>nil then
sl.Add('Project''s CompilerFilename='+Project1.CompilerOptions.CompilerPath);
sl.Add('Resolved Project''s CompilerFilename='+Project1.GetCompilerFilename);
sl.Add('Default CompilerFilename='+EnvironmentOptions.CompilerFilename);
sl.Add('Resolved default compilerFilename='+EnvironmentOptions.GetParsedCompilerFilename);
sl.Add('CompilerMessagesFilename='+EnvironmentOptions.CompilerMessagesFilename);
sl.Add('Resolved CompilerMessagesFilename='+EnvironmentOptions.GetParsedCompilerMessagesFilename);
sl.Add('');

View File

@ -32,7 +32,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, LCLProc, LazHelpHTML, LazHelpIntf, DefineTemplates, CodeToolManager,
EnvironmentOpts, AboutFrm, LazConf, IDEHelpIntf, IDEWindowIntf,
EnvironmentOpts, AboutFrm, LazConf, IDEHelpIntf, IDEWindowIntf, LazIDEIntf,
LazarusIDEStrConsts, Project, SourceEditor, InitialSetupDlgs, PackageSystem,
PackageDefs;
@ -241,20 +241,29 @@ begin
then
sl.Add('WARNING: '+Note);
sl.Add('CompilerFilename='+EnvironmentOptions.CompilerFilename);
sl.Add('Real CompilerFilename='+EnvironmentOptions.GetParsedCompilerFilename);
sl.Add('Default CompilerFilename='+EnvironmentOptions.CompilerFilename);
sl.Add('Real Default CompilerFilename='+EnvironmentOptions.GetParsedCompilerFilename);
if CheckCompilerQuality(EnvironmentOptions.GetParsedCompilerFilename,Note,
CodeToolBoss.FPCDefinesCache.TestFilename)<>sddqCompatible
then
sl.Add('WARNING: '+Note);
if Project1<>nil then begin
sl.Add('Project CompilerFilename='+Project1.CompilerOptions.CompilerPath);
sl.Add('Real Project CompilerFilename='+LazarusIDE.GetFPCompilerFilename);
if CheckCompilerQuality(LazarusIDE.GetFPCompilerFilename,Note,
CodeToolBoss.FPCDefinesCache.TestFilename)<>sddqCompatible
then
sl.Add('WARNING: '+Note);
end;
sl.Add('CompilerMessagesFilename='+EnvironmentOptions.CompilerMessagesFilename);
sl.Add('Real CompilerMessagesFilename='+EnvironmentOptions.GetParsedCompilerMessagesFilename);
sl.Add('FPC source directory='+EnvironmentOptions.FPCSourceDirectory);
sl.Add('Real FPC source directory='+EnvironmentOptions.GetParsedFPCSourceDirectory);
CfgCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
EnvironmentOptions.GetParsedCompilerFilename,'','','',true);
LazarusIDE.GetFPCompilerFilename,'','','',true);
if CheckFPCSrcDirQuality(EnvironmentOptions.GetParsedFPCSourceDirectory,Note,
CfgCache.GetFPCVer)<>sddqCompatible
then

View File

@ -978,6 +978,7 @@ type
// methods for debugging, compiling and external tools
function GetTestBuildDirectory: string; override;
function GetFPCompilerFilename: string; override;
procedure GetIDEFileState(Sender: TObject; const AFilename: string;
NeededFlags: TIDEFileStateFlags; out ResultFlags: TIDEFileStateFlags); override;
@ -9211,6 +9212,11 @@ begin
Result:=MainBuildBoss.GetTestBuildDirectory;
end;
function TMainIDE.GetFPCompilerFilename: string;
begin
Result:=MainBuildBoss.GetFPCompilerFilename;
end;
function TMainIDE.FindUnitFile(const AFilename: string; TheOwner: TObject;
Flags: TFindUnitFileFlags): string;