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,
{$ENDIF}
// RTL + FCL
Classes, SysUtils, AVL_Tree, contnrs,
Classes, SysUtils, AVL_Tree,
// CodeTools
CodeToolsStrConsts,
// LazUtils

View File

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

View File

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

View File

@ -54,13 +54,11 @@ uses
CodeToolManager, DirectoryCacher,
// IDEIntf,
IDEExternToolIntf, IDEDialogs, IDEMsgIntf, PackageIntf,
CompOptsIntf, LazIDEIntf, MacroDefIntf,
// package registration
LazarusPackageIntf,
CompOptsIntf, LazIDEIntf, MacroDefIntf, ProjectIntf, LazarusPackageIntf,
// IDE
LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf,
TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks,
PackageDefs, ComponentReg, ProjectIntf;
PackageDefs, ComponentReg;
const
MakefileCompileVersion = 2;
@ -502,6 +500,7 @@ function ExtractMakefileCompiledParams(const CompParams: string;
CreateReduced: boolean = false;
BaseDir: string = ''; MakeRelative: boolean = false): TStringList;
function RemoveFPCVerbosityParams(const CompParams: string): string;
procedure WarnSuspiciousCompilerOptions(ViewCaption, Target, CompilerParams: string);
implementation
@ -669,6 +668,35 @@ begin
Result:=UTF8Trim(Result,[]);
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 }
constructor TLazPackageGraphFileCache.Create(AOwner: TLazPackageGraph);
@ -4095,6 +4123,8 @@ begin
EffectiveCompilerParams:='-B';
end;
WarnSuspiciousCompilerOptions('Compile checks','package '+APackage.IDAsString+':',CompilerParams);
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilePackage, [APackage.IDAsString]));
ExtToolData:=TLazPkgGraphExtToolData.Create(IDEToolCompilePackage,
APackage.Name,APackage.Filename);