mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 13:59:24 +01:00
IDE: compile project/package: warn when passing an option twice with different values
git-svn-id: trunk@53184 -
This commit is contained in:
parent
94d76f9a59
commit
a9051948ae
@ -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
|
||||||
|
|||||||
@ -239,7 +239,6 @@ type
|
|||||||
property ErrorMsg: string read GetErrorMsg;
|
property ErrorMsg: string read GetErrorMsg;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TCompiler }
|
{ TCompiler }
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user