IDE: compile project/package: warn when passing an option twice with different values

git-svn-id: trunk@53184 -
This commit is contained in:
mattias 2016-10-20 20:17:01 +00:00
parent 94d76f9a59
commit a9051948ae
4 changed files with 37 additions and 6 deletions

View File

@ -40,7 +40,7 @@ uses
Windows, Windows,
{$ENDIF} {$ENDIF}
// RTL + FCL // RTL + FCL
Classes, SysUtils, AVL_Tree, contnrs, Classes, SysUtils, AVL_Tree,
// CodeTools // CodeTools
CodeToolsStrConsts, CodeToolsStrConsts,
// LazUtils // LazUtils

View File

@ -239,7 +239,6 @@ type
property ErrorMsg: string read GetErrorMsg; property ErrorMsg: string read GetErrorMsg;
end; end;
implementation implementation
{ TCompiler } { TCompiler }

View File

@ -6788,6 +6788,8 @@ begin
exit; exit;
end; end;
WarnSuspiciousCompilerOptions('Project checks','',CompilerParams);
StartTime:=Now; StartTime:=Now;
Result:=TheCompiler.Compile(Project1, Result:=TheCompiler.Compile(Project1,
WorkingDir,CompilerFilename,CompilerParams, WorkingDir,CompilerFilename,CompilerParams,

View File

@ -54,13 +54,11 @@ uses
CodeToolManager, DirectoryCacher, CodeToolManager, DirectoryCacher,
// IDEIntf, // IDEIntf,
IDEExternToolIntf, IDEDialogs, IDEMsgIntf, PackageIntf, IDEExternToolIntf, IDEDialogs, IDEMsgIntf, PackageIntf,
CompOptsIntf, LazIDEIntf, MacroDefIntf, CompOptsIntf, LazIDEIntf, MacroDefIntf, ProjectIntf, LazarusPackageIntf,
// package registration
LazarusPackageIntf,
// IDE // IDE
LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf, LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf,
TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks, TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks,
PackageDefs, ComponentReg, ProjectIntf; PackageDefs, ComponentReg;
const const
MakefileCompileVersion = 2; MakefileCompileVersion = 2;
@ -502,6 +500,7 @@ function ExtractMakefileCompiledParams(const CompParams: string;
CreateReduced: boolean = false; CreateReduced: boolean = false;
BaseDir: string = ''; MakeRelative: boolean = false): TStringList; BaseDir: string = ''; MakeRelative: boolean = false): TStringList;
function RemoveFPCVerbosityParams(const CompParams: string): string; function RemoveFPCVerbosityParams(const CompParams: string): string;
procedure WarnSuspiciousCompilerOptions(ViewCaption, Target, CompilerParams: string);
implementation implementation
@ -669,6 +668,35 @@ begin
Result:=UTF8Trim(Result,[]); Result:=UTF8Trim(Result,[]);
end; end;
procedure WarnSuspiciousCompilerOptions(ViewCaption, Target,
CompilerParams: string);
var
ParsedParams: TObjectList;
i: Integer;
Param: TFPCParamValue;
Msg: String;
begin
ParsedParams:=TObjectList.Create(true);
try
ParseFPCParameters(CompilerParams,ParsedParams);
for i:=0 to ParsedParams.Count-1 do begin
Param:=TFPCParamValue(ParsedParams[i]);
if fpfValueChanged in Param.Flags then begin
Msg:='';
if Param.Kind in [fpkBoolean,fpkValue] then
Msg:='passing compiler option -'+Param.Name+' twice with different values'
else if Param.Kind=fpkDefine then
Msg:='passing compiler define "'+Param.Name+'" twice with different values';
if Msg='' then continue;
if Target<>'' then Msg:=Target+' '+Msg;
IDEMessagesWindow.AddCustomMessage(mluNote,Msg,'',0,0,ViewCaption);
end;
end;
finally
ParsedParams.Free;
end;
end;
{ TLazPackageGraphFileCache } { TLazPackageGraphFileCache }
constructor TLazPackageGraphFileCache.Create(AOwner: TLazPackageGraph); constructor TLazPackageGraphFileCache.Create(AOwner: TLazPackageGraph);
@ -4095,6 +4123,8 @@ begin
EffectiveCompilerParams:='-B'; EffectiveCompilerParams:='-B';
end; end;
WarnSuspiciousCompilerOptions('Compile checks','package '+APackage.IDAsString+':',CompilerParams);
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilePackage, [APackage.IDAsString])); PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilePackage, [APackage.IDAsString]));
ExtToolData:=TLazPkgGraphExtToolData.Create(IDEToolCompilePackage, ExtToolData:=TLazPkgGraphExtToolData.Create(IDEToolCompilePackage,
APackage.Name,APackage.Filename); APackage.Name,APackage.Filename);