IDE: compiler options diff

git-svn-id: trunk@27762 -
This commit is contained in:
mattias 2010-10-19 21:45:38 +00:00
parent c7d58c33c4
commit 1946265ab4
5 changed files with 248 additions and 135 deletions

View File

@ -31,7 +31,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls, ComCtrls, StdCtrls, ComCtrls,
LazarusIDEStrConsts, Project, CompilerOptions; LazarusIDEStrConsts, Project, CompilerOptions, CompOptsModes;
type type
@ -111,6 +111,9 @@ var
i: Integer; i: Integer;
CurMode: TProjectBuildMode; CurMode: TProjectBuildMode;
ModeNode: TTreeNode; ModeNode: TTreeNode;
Diff: TStringList;
DiffTool: TCompilerDiffTool;
j: Integer;
begin begin
DiffTreeView.BeginUpdate; DiffTreeView.BeginUpdate;
DiffTreeView.Items.Clear; DiffTreeView.Items.Clear;
@ -121,7 +124,13 @@ begin
CurMode:=fProject.BuildModes[i]; CurMode:=fProject.BuildModes[i];
if CurMode=BaseMode then continue; if CurMode=BaseMode then continue;
ModeNode:=DiffTreeView.Items.Add(nil,CurMode.GetCaption); ModeNode:=DiffTreeView.Items.Add(nil,CurMode.GetCaption);
DiffTreeView.Items.AddChild(ModeNode,'todo'); Diff:=TStringList.Create;
DiffTool:=TCompilerDiffTool.Create(Diff);
BaseMode.CreateDiff(CurMode,DiffTool);
for j:=0 to Diff.Count-1 do
DiffTreeView.Items.AddChild(ModeNode,Diff[j]);
DiffTool.Free;
Diff.Free;
ModeNode.Expand(true); ModeNode.Expand(true);
end; end;
end; end;

View File

@ -439,7 +439,7 @@ type
public public
procedure Clear; virtual; procedure Clear; virtual;
function CreateDiff(CompOpts: TCompilationToolOptions; function CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool = nil): boolean; virtual; Tool: TCompilerDiffTool = nil): boolean; virtual;
procedure Assign(Src: TCompilationToolOptions); virtual; procedure Assign(Src: TCompilationToolOptions); virtual;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
DoSwitchPathDelims: boolean); virtual; DoSwitchPathDelims: boolean); virtual;
@ -3178,6 +3178,12 @@ end;
function TBaseCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions; function TBaseCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool): boolean; Tool: TCompilerDiffTool): boolean;
function Done(Diff: boolean): boolean;
begin
if Diff then CreateDiff:=true;
Result:=(Tool=nil) and Diff;
end;
function AddDiff(const PropertyName: string; function AddDiff(const PropertyName: string;
const Old, New: TCompilationExecutableType): boolean; const Old, New: TCompilationExecutableType): boolean;
begin begin
@ -3188,110 +3194,104 @@ function TBaseCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
var var
i: Integer; i: Integer;
begin begin
Result:=Tool.AddPathsDiff('StorePathDelim',PathDelimSwitchToDelim[FStorePathDelim], Result:=false;
PathDelimSwitchToDelim[CompOpts.FStorePathDelim]); //if Tool<>nil then debugln(['TBaseCompilerOptions.CreateDiff ',DbgSName(Self)]);
if Done(Tool.AddPathsDiff('StorePathDelim',PathDelimSwitchToDelim[FStorePathDelim],
PathDelimSwitchToDelim[CompOpts.FStorePathDelim])) then exit;
// target // target
Result:=Result or Tool.AddDiff('TargetFilename',fTargetFilename,CompOpts.fTargetFilename); if Done(Tool.AddDiff('TargetFilename',fTargetFilename,CompOpts.fTargetFilename)) then exit;
// search paths // search paths
if Tool<>nil then Tool.Path:='Paths'; if Tool<>nil then Tool.Path:='Paths';
Result:=Result if Done(Tool.AddPathsDiff('IncludePaths',IncludePath,CompOpts.IncludePath)) then exit;
or Tool.AddPathsDiff('IncludePaths',IncludePath,CompOpts.IncludePath) if Done(Tool.AddPathsDiff('LibraryPaths',Libraries,CompOpts.Libraries)) then exit;
or Tool.AddPathsDiff('LibraryPaths',Libraries,CompOpts.Libraries) if Done(Tool.AddPathsDiff('UnitPaths',OtherUnitFiles,CompOpts.OtherUnitFiles)) then exit;
or Tool.AddPathsDiff('UnitPaths',OtherUnitFiles,CompOpts.OtherUnitFiles) if Done(Tool.AddPathsDiff('UnitOutputDir',UnitOutputDirectory,CompOpts.UnitOutputDirectory)) then exit;
or Tool.AddPathsDiff('UnitOutputDir',UnitOutputDirectory,CompOpts.UnitOutputDirectory) if Done(Tool.AddPathsDiff('ObjectPath',ObjectPath,CompOpts.ObjectPath)) then exit;
or Tool.AddPathsDiff('ObjectPath',ObjectPath,CompOpts.ObjectPath) if Done(Tool.AddPathsDiff('SrcPath',SrcPath,CompOpts.SrcPath)) then exit;
or Tool.AddPathsDiff('SrcPath',SrcPath,CompOpts.SrcPath) if Done(Tool.AddPathsDiff('DebugPath',DebugPath,CompOpts.DebugPath)) then exit;
or Tool.AddPathsDiff('DebugPath',DebugPath,CompOpts.DebugPath);
// conditionals // conditionals
Result:=Result if Done(Tool.AddPathsDiff('Conditionals',FConditionals,CompOpts.FConditionals)) then exit;
or Tool.AddPathsDiff('Conditionals',FConditionals,CompOpts.FConditionals);
if Tool<>nil then Tool.Path:='BuildModes'; if Tool<>nil then Tool.Path:='BuildModes';
Result:=Result if Done(TIDEBuildMacros(fBuildMacros).CreateDiff(CompOpts.BuildMacros,Tool)) then exit;
or TIDEBuildMacros(fBuildMacros).CreateDiff(CompOpts.BuildMacros,Tool) if Done(Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType)) then exit;
or Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType);
// parsing // parsing
if Tool<>nil then Tool.Path:='Parsing'; if Tool<>nil then Tool.Path:='Parsing';
Result:=Result if Done(Tool.AddDiff('SyntaxMode',FSyntaxMode,CompOpts.FSyntaxMode)) then exit;
or Tool.AddDiff('SyntaxMode',FSyntaxMode,CompOpts.FSyntaxMode) if Done(Tool.AddDiff('AssemblerStyle',fAssemblerStyle,CompOpts.fAssemblerStyle)) then exit;
or Tool.AddDiff('AssemblerStyle',fAssemblerStyle,CompOpts.fAssemblerStyle) if Done(Tool.AddDiff('CStyleOp',fCStyleOp,CompOpts.fCStyleOp)) then exit;
or Tool.AddDiff('CStyleOp',fCStyleOp,CompOpts.fCStyleOp) if Done(Tool.AddDiff('IncludeAssertionCode',fIncludeAssertionCode,CompOpts.fIncludeAssertionCode)) then exit;
or Tool.AddDiff('IncludeAssertionCode',fIncludeAssertionCode,CompOpts.fIncludeAssertionCode) if Done(Tool.AddDiff('AllowLabel',fAllowLabel,CompOpts.fAllowLabel)) then exit;
or Tool.AddDiff('AllowLabel',fAllowLabel,CompOpts.fAllowLabel) if Done(Tool.AddDiff('CPPInline',fCPPInline,CompOpts.fCPPInline)) then exit;
or Tool.AddDiff('CPPInline',fCPPInline,CompOpts.fCPPInline) if Done(Tool.AddDiff('CMacros',fCMacros,CompOpts.fCMacros)) then exit;
or Tool.AddDiff('CMacros',fCMacros,CompOpts.fCMacros) if Done(Tool.AddDiff('InitConst',fInitConst,CompOpts.fInitConst)) then exit;
or Tool.AddDiff('InitConst',fInitConst,CompOpts.fInitConst) if Done(Tool.AddDiff('StaticKeyword',fStaticKeyword,CompOpts.fStaticKeyword)) then exit;
or Tool.AddDiff('StaticKeyword',fStaticKeyword,CompOpts.fStaticKeyword) if Done(Tool.AddDiff('UseAnsiStr',fUseAnsiStr,CompOpts.fUseAnsiStr)) then exit;
or Tool.AddDiff('UseAnsiStr',fUseAnsiStr,CompOpts.fUseAnsiStr);
// code generation // code generation
if Tool<>nil then Tool.Path:='Code'; if Tool<>nil then Tool.Path:='Code';
Result:=Result if Done(Tool.AddDiff('SmartLinkUnit',fSmartLinkUnit,CompOpts.SmartLinkUnit)) then exit;
or Tool.AddDiff('SmartLinkUnit',fSmartLinkUnit,CompOpts.SmartLinkUnit) if Done(Tool.AddDiff('IOChecks',fIOChecks,CompOpts.fIOChecks)) then exit;
or Tool.AddDiff('IOChecks',fIOChecks,CompOpts.fIOChecks) if Done(Tool.AddDiff('RangeChecks',fRangeChecks,CompOpts.fRangeChecks)) then exit;
or Tool.AddDiff('RangeChecks',fRangeChecks,CompOpts.fRangeChecks) if Done(Tool.AddDiff('OverflowChecks',fOverflowChecks,CompOpts.fOverflowChecks)) then exit;
or Tool.AddDiff('OverflowChecks',fOverflowChecks,CompOpts.fOverflowChecks) if Done(Tool.AddDiff('StackChecks',fStackChecks,CompOpts.fStackChecks)) then exit;
or Tool.AddDiff('StackChecks',fStackChecks,CompOpts.fStackChecks) if Done(Tool.AddDiff('EmulatedFloatOpcodes',FEmulatedFloatOpcodes,CompOpts.FEmulatedFloatOpcodes)) then exit;
or Tool.AddDiff('EmulatedFloatOpcodes',FEmulatedFloatOpcodes,CompOpts.FEmulatedFloatOpcodes) if Done(Tool.AddDiff('HeapSize',fHeapSize,CompOpts.fHeapSize)) then exit;
or Tool.AddDiff('HeapSize',fHeapSize,CompOpts.fHeapSize) if Done(Tool.AddDiff('EmulatedFloatOpcodes',fEmulatedFloatOpcodes,CompOpts.fEmulatedFloatOpcodes)) then exit;
or Tool.AddDiff('EmulatedFloatOpcodes',fEmulatedFloatOpcodes,CompOpts.fEmulatedFloatOpcodes) if Done(Tool.AddDiff('SmallerCode',FSmallerCode,CompOpts.FSmallerCode)) then exit;
or Tool.AddDiff('SmallerCode',FSmallerCode,CompOpts.FSmallerCode) if Done(Tool.AddDiff('TargetProc',fTargetProc,CompOpts.fTargetProc)) then exit;
or Tool.AddDiff('TargetProc',fTargetProc,CompOpts.fTargetProc) if Done(Tool.AddDiff('TargetCPU',fTargetCPU,CompOpts.fTargetCPU)) then exit;
or Tool.AddDiff('TargetCPU',fTargetCPU,CompOpts.fTargetCPU) if Done(Tool.AddDiff('VarsInReg',fVarsInReg,CompOpts.fVarsInReg)) then exit;
or Tool.AddDiff('VarsInReg',fVarsInReg,CompOpts.fVarsInReg) if Done(Tool.AddDiff('UncertainOpt',fUncertainOpt,CompOpts.fUncertainOpt)) then exit;
or Tool.AddDiff('UncertainOpt',fUncertainOpt,CompOpts.fUncertainOpt) if Done(Tool.AddDiff('OptLevel',fOptLevel,CompOpts.fOptLevel)) then exit;
or Tool.AddDiff('OptLevel',fOptLevel,CompOpts.fOptLevel) if Done(Tool.AddDiff('TargetOS',fTargetOS,CompOpts.fTargetOS)) then exit;
or Tool.AddDiff('TargetOS',fTargetOS,CompOpts.fTargetOS);
// linking // linking
if Tool<>nil then Tool.Path:='Linking'; if Tool<>nil then Tool.Path:='Linking';
Result:=Result if Done(Tool.AddDiff('GenDebugInfo',fGenDebugInfo,CompOpts.fGenDebugInfo)) then exit;
or Tool.AddDiff('GenDebugInfo',fGenDebugInfo,CompOpts.fGenDebugInfo) if Done(Tool.AddDiff('UseLineInfoUnit',fUseLineInfoUnit,CompOpts.fUseLineInfoUnit)) then exit;
or Tool.AddDiff('UseLineInfoUnit',fUseLineInfoUnit,CompOpts.fUseLineInfoUnit) if Done(Tool.AddDiff('GenerateDwarf',FGenerateDwarf,CompOpts.FGenerateDwarf)) then exit;
or Tool.AddDiff('GenerateDwarf',FGenerateDwarf,CompOpts.FGenerateDwarf) if Done(Tool.AddDiff('UseHeaptrc',fUseHeaptrc,CompOpts.fUseHeaptrc)) then exit;
or Tool.AddDiff('UseHeaptrc',fUseHeaptrc,CompOpts.fUseHeaptrc) if Done(Tool.AddDiff('UseValgrind',fUseValgrind,CompOpts.fUseValgrind)) then exit;
or Tool.AddDiff('UseValgrind',fUseValgrind,CompOpts.fUseValgrind) if Done(Tool.AddDiff('GenGProfCode',fGenGProfCode,CompOpts.fGenGProfCode)) then exit;
or Tool.AddDiff('GenGProfCode',fGenGProfCode,CompOpts.fGenGProfCode) if Done(Tool.AddDiff('StripSymbols',fStripSymbols,CompOpts.fStripSymbols)) then exit;
or Tool.AddDiff('StripSymbols',fStripSymbols,CompOpts.fStripSymbols) if Done(Tool.AddDiff('LinkSmart',fLinkSmart,CompOpts.fLinkSmart)) then exit;
or Tool.AddDiff('LinkSmart',fLinkSmart,CompOpts.fLinkSmart) if Done(Tool.AddDiff('PassLinkerOpt',fPassLinkerOpt,CompOpts.fPassLinkerOpt)) then exit;
or Tool.AddDiff('PassLinkerOpt',fPassLinkerOpt,CompOpts.fPassLinkerOpt) if Done(Tool.AddDiff('LinkerOptions',fLinkerOptions,CompOpts.fLinkerOptions)) then exit;
or Tool.AddDiff('LinkerOptions',fLinkerOptions,CompOpts.fLinkerOptions) if Done(Tool.AddDiff('Win32GraphicApp',FWin32GraphicApp,CompOpts.FWin32GraphicApp)) then exit;
or Tool.AddDiff('Win32GraphicApp',FWin32GraphicApp,CompOpts.FWin32GraphicApp) if Done(AddDiff('ExecutableType',FExecutableType,CompOpts.FExecutableType)) then exit;
or AddDiff('ExecutableType',FExecutableType,CompOpts.FExecutableType);
// verbosity // verbosity
if Tool<>nil then Tool.Path:='Verbosity'; if Tool<>nil then Tool.Path:='Verbosity';
Result:=Result if Done(Tool.AddDiff('ShowErrors',fShowErrors,CompOpts.fShowErrors)) then exit;
or Tool.AddDiff('ShowErrors',fShowErrors,CompOpts.fShowErrors) if Done(Tool.AddDiff('ShowWarn',fShowWarn,CompOpts.fShowWarn)) then exit;
or Tool.AddDiff('ShowWarn',fShowWarn,CompOpts.fShowWarn) if Done(Tool.AddDiff('ShowNotes',fShowNotes,CompOpts.fShowNotes)) then exit;
or Tool.AddDiff('ShowNotes',fShowNotes,CompOpts.fShowNotes) if Done(Tool.AddDiff('ShowHints',fShowHints,CompOpts.fShowHints)) then exit;
or Tool.AddDiff('ShowHints',fShowHints,CompOpts.fShowHints) if Done(Tool.AddDiff('ShowGenInfo',fShowGenInfo,CompOpts.fShowGenInfo)) then exit;
or Tool.AddDiff('ShowGenInfo',fShowGenInfo,CompOpts.fShowGenInfo) if Done(Tool.AddDiff('ShowLineNum',fShowLineNum,CompOpts.fShowLineNum)) then exit;
or Tool.AddDiff('ShowLineNum',fShowLineNum,CompOpts.fShowLineNum) if Done(Tool.AddDiff('ShowAll',fShowAll,CompOpts.fShowAll)) then exit;
or Tool.AddDiff('ShowAll',fShowAll,CompOpts.fShowAll) if Done(Tool.AddDiff('ShowAllProcsOnError',fShowAllProcsOnError,CompOpts.fShowAllProcsOnError)) then exit;
or Tool.AddDiff('ShowAllProcsOnError',fShowAllProcsOnError,CompOpts.fShowAllProcsOnError) if Done(Tool.AddDiff('ShowDebugInfo',fShowDebugInfo,CompOpts.fShowDebugInfo)) then exit;
or Tool.AddDiff('ShowDebugInfo',fShowDebugInfo,CompOpts.fShowDebugInfo) if Done(Tool.AddDiff('ShowUsedFiles',fShowUsedFiles,CompOpts.fShowUsedFiles)) then exit;
or Tool.AddDiff('ShowUsedFiles',fShowUsedFiles,CompOpts.fShowUsedFiles) if Done(Tool.AddDiff('ShowTriedFiles',fShowTriedFiles,CompOpts.fShowTriedFiles)) then exit;
or Tool.AddDiff('ShowTriedFiles',fShowTriedFiles,CompOpts.fShowTriedFiles) if Done(Tool.AddDiff('ShowDefMacros',fShowDefMacros,CompOpts.fShowDefMacros)) then exit;
or Tool.AddDiff('ShowDefMacros',fShowDefMacros,CompOpts.fShowDefMacros) if Done(Tool.AddDiff('ShowCompProc',fShowCompProc,CompOpts.fShowCompProc)) then exit;
or Tool.AddDiff('ShowCompProc',fShowCompProc,CompOpts.fShowCompProc) if Done(Tool.AddDiff('ShowCond',fShowCond,CompOpts.fShowCond)) then exit;
or Tool.AddDiff('ShowCond',fShowCond,CompOpts.fShowCond) if Done(Tool.AddDiff('ShowExecInfo',fShowExecInfo,CompOpts.fShowExecInfo)) then exit;
or Tool.AddDiff('ShowExecInfo',fShowExecInfo,CompOpts.fShowExecInfo) if Done(Tool.AddDiff('ShowNothing',fShowNothing,CompOpts.fShowNothing)) then exit;
or Tool.AddDiff('ShowNothing',fShowNothing,CompOpts.fShowNothing) if Done(Tool.AddDiff('ShowSummary',fShowSummary,CompOpts.fShowSummary)) then exit;
or Tool.AddDiff('ShowSummary',fShowSummary,CompOpts.fShowSummary) if Done(Tool.AddDiff('ShowHintsForUnusedUnitsInMainSrc',fShowHintsForUnusedUnitsInMainSrc,CompOpts.fShowHintsForUnusedUnitsInMainSrc)) then exit;
or Tool.AddDiff('ShowHintsForUnusedUnitsInMainSrc',fShowHintsForUnusedUnitsInMainSrc,CompOpts.fShowHintsForUnusedUnitsInMainSrc) if Done(Tool.AddDiff('ShowHintsForSenderNotUsed',fShowHintsForSenderNotUsed,CompOpts.fShowHintsForSenderNotUsed)) then exit;
or Tool.AddDiff('ShowHintsForSenderNotUsed',fShowHintsForSenderNotUsed,CompOpts.fShowHintsForSenderNotUsed) if Done(Tool.AddDiff('WriteFPCLogo',fWriteFPCLogo,CompOpts.fWriteFPCLogo)) then exit;
or Tool.AddDiff('WriteFPCLogo',fWriteFPCLogo,CompOpts.fWriteFPCLogo);
//messages //messages
if Tool<>nil then Tool.Path:='Messages'; if Tool<>nil then Tool.Path:='Messages';
Result:=Result if Done(Tool.AddDiff('UseCustomMessages',fUseCustomMessages,CompOpts.fUseCustomMessages)) then exit;
or Tool.AddDiff('UseCustomMessages',fUseCustomMessages,CompOpts.fUseCustomMessages) if Done(Tool.AddDiff('UseMsgFile',fUseMsgFile,CompOpts.fUseMsgFile)) then exit;
or Tool.AddDiff('UseMsgFile',fUseMsgFile,CompOpts.fUseMsgFile) if Done(Tool.AddDiff('MsgFileName',fMsgFileName,CompOpts.fMsgFileName)) then exit;
or Tool.AddDiff('MsgFileName',fMsgFileName,CompOpts.fMsgFileName);
for i:=0 to fCompilerMessages.Count-1 do for i:=0 to fCompilerMessages.Count-1 do
if fCompilerMessages.Msg[i].Ignored<>CompOpts.fCompilerMessages.Msg[i].Ignored if fCompilerMessages.Msg[i].Ignored<>CompOpts.fCompilerMessages.Msg[i].Ignored
then begin then begin
@ -3302,20 +3302,18 @@ begin
// other // other
if Tool<>nil then Tool.Path:='Other'; if Tool<>nil then Tool.Path:='Other';
Result:=Result if Done(Tool.AddDiff('DontUseConfigFile',fDontUseConfigFile,CompOpts.fDontUseConfigFile)) then exit;
or Tool.AddDiff('DontUseConfigFile',fDontUseConfigFile,CompOpts.fDontUseConfigFile) if Done(Tool.AddDiff('CustomConfigFile',fCustomConfigFile,CompOpts.fCustomConfigFile)) then exit;
or Tool.AddDiff('CustomConfigFile',fCustomConfigFile,CompOpts.fCustomConfigFile) if Done(Tool.AddDiff('ConfigFilePath',fConfigFilePath,CompOpts.fConfigFilePath)) then exit;
or Tool.AddDiff('ConfigFilePath',fConfigFilePath,CompOpts.fConfigFilePath) if Done(Tool.AddDiff('StopAfterErrCount',fStopAfterErrCount,CompOpts.fStopAfterErrCount)) then exit;
or Tool.AddDiff('StopAfterErrCount',fStopAfterErrCount,CompOpts.fStopAfterErrCount) if Done(Tool.AddDiff('CustomOptions',CustomOptions,CompOpts.CustomOptions)) then exit;
or Tool.AddDiff('CustomOptions',CustomOptions,CompOpts.CustomOptions);
// compilation // compilation
if Tool<>nil then Tool.Path:='Compilation'; if Tool<>nil then Tool.Path:='Compilation';
Result:=Result if Done(Tool.AddDiff('CompilerPath',CompilerPath,CompOpts.CompilerPath)) then exit;
or Tool.AddDiff('CompilerPath',CompilerPath,CompOpts.CompilerPath) if Done(ExecuteBefore.CreateDiff(CompOpts.ExecuteBefore,Tool)) then exit;
or ExecuteBefore.CreateDiff(CompOpts.ExecuteBefore,Tool) if Done(ExecuteAfter.CreateDiff(CompOpts.ExecuteAfter,Tool)) then exit;
or ExecuteAfter.CreateDiff(CompOpts.ExecuteAfter,Tool) if Done(Tool.AddDiff('CreateMakefileOnBuild',fCreateMakefileOnBuild,CompOpts.fCreateMakefileOnBuild)) then exit;
or Tool.AddDiff('CreateMakefileOnBuild',fCreateMakefileOnBuild,CompOpts.fCreateMakefileOnBuild);
end; end;
@ -3834,11 +3832,19 @@ end;
function TCompilationToolOptions.CreateDiff(CompOpts: TCompilationToolOptions; function TCompilationToolOptions.CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool): boolean; Tool: TCompilerDiffTool): boolean;
function Done(Diff: boolean): boolean;
begin
if Diff then CreateDiff:=true;
Result:=(Tool=nil) and Diff;
end;
begin begin
Result:=Tool.AddDiff('Command',Command,CompOpts.Command) Result:=false;
or Tool.AddDiff('ScanForFPCMessages',ScanForFPCMessages,CompOpts.ScanForFPCMessages) if Done(Tool.AddDiff('Command',Command,CompOpts.Command)) then exit;
or Tool.AddDiff('ScanForMakeMessages',ScanForMakeMessages,CompOpts.ScanForMakeMessages) if Done(Tool.AddDiff('ScanForFPCMessages',ScanForFPCMessages,CompOpts.ScanForFPCMessages)) then exit;
or Tool.AddDiff('ShowAllMessages',ShowAllMessages,CompOpts.ShowAllMessages); if Done(Tool.AddDiff('ScanForMakeMessages',ScanForMakeMessages,CompOpts.ScanForMakeMessages)) then exit;
if Done(Tool.AddDiff('ShowAllMessages',ShowAllMessages,CompOpts.ShowAllMessages)) then exit;
end; end;
function TCompilationToolOptions.Execute(const WorkingDir, ToolTitle: string function TCompilationToolOptions.Execute(const WorkingDir, ToolTitle: string
@ -3997,11 +4003,19 @@ end;
function TIDEBuildMacro.CreateDiff(OtherMode: TLazBuildMacro; function TIDEBuildMacro.CreateDiff(OtherMode: TLazBuildMacro;
Tool: TCompilerDiffTool): boolean; Tool: TCompilerDiffTool): boolean;
function Done(Diff: boolean): boolean;
begin
if Diff then CreateDiff:=true;
Result:=(Tool=nil) and Diff;
end;
begin begin
Result:=Tool.AddDiff('Identifier',Identifier,OtherMode.Identifier) Result:=false;
or Tool.AddDiff('Description',Description,OtherMode.Description) if Done(Tool.AddDiff('Identifier',Identifier,OtherMode.Identifier)) then exit;
or Tool.AddStringsDiff('Values',Values,OtherMode.Values) if Done(Tool.AddDiff('Description',Description,OtherMode.Description)) then exit;
or Tool.AddStringsDiff('ValueDescriptions',ValueDescriptions,OtherMode.ValueDescriptions); if Done(Tool.AddStringsDiff('Values',Values,OtherMode.Values)) then exit;
if Done(Tool.AddStringsDiff('ValueDescriptions',ValueDescriptions,OtherMode.ValueDescriptions)) then exit;
end; end;
procedure TIDEBuildMacro.IncreaseChangeStamp; procedure TIDEBuildMacro.IncreaseChangeStamp;
@ -4115,13 +4129,30 @@ function TIDEBuildMacros.CreateDiff(OtherProperties: TLazBuildMacros;
Tool: TCompilerDiffTool): boolean; Tool: TCompilerDiffTool): boolean;
var var
i: Integer; i: Integer;
OtherMacro: TLazBuildMacro;
begin begin
Result:=Tool.AddDiff('Count',Count,OtherProperties.Count); if (Tool=nil) and (Count<>OtherProperties.Count) then exit(true);
for i:=0 to Count-1 do begin for i:=0 to OtherProperties.Count-1 do begin
if i>=OtherProperties.Count then break; OtherMacro:=OtherProperties.Items[i];
if TIDEBuildMacro(Items[i]).CreateDiff(OtherProperties.Items[i],Tool) then if i>=Count then
Result:=true; begin
if Tool=nil then exit(true);
Tool.AddDiffItem('BuildMacros/'+OtherMacro.Identifier,'new');
end else begin
if Tool=nil then
begin
if not TIDEBuildMacro(Items[i]).Equals(OtherMacro) then exit(true);
end else
begin
Tool.Path:='BuildMacros/'+OtherMacro.Identifier;
if TIDEBuildMacro(Items[i]).CreateDiff(OtherProperties.Items[i],Tool) then
Result:=true;
end;
end;
end; end;
if Tool<>nil then
for i:=OtherProperties.Count to Count-1 do
Tool.AddDiffItem('BuildMacros/'+Items[i].Identifier,'deleted');
end; end;
procedure TIDEBuildMacros.Assign(Source: TLazBuildMacros); procedure TIDEBuildMacros.Assign(Source: TLazBuildMacros);

View File

@ -27,8 +27,7 @@
Author: Mattias Gaertner Author: Mattias Gaertner
Abstract: Abstract:
This unit contains the implementation of the conditional compiler options This unit contains a class to create diffs between compiler options.
that depend on build macros/modes and environment.
} }
unit CompOptsModes; unit CompOptsModes;
@ -58,6 +57,7 @@ type
public public
constructor Create(DiffList: TStrings); constructor Create(DiffList: TStrings);
procedure AddDiffItem(const PropertyName, Value: string); procedure AddDiffItem(const PropertyName, Value: string);
procedure AddDiffItemUndefined(const PropertyName: string);
function AddDiff(const PropertyName: string; const Old, New: string): boolean; function AddDiff(const PropertyName: string; const Old, New: string): boolean;
function AddDiff(const PropertyName: string; const Old, New: integer): boolean; function AddDiff(const PropertyName: string; const Old, New: integer): boolean;
function AddDiff(const PropertyName: string; const Old, New: boolean): boolean; function AddDiff(const PropertyName: string; const Old, New: boolean): boolean;
@ -112,9 +112,18 @@ begin
Diff.Add(Path+PropertyName+'='+Value); Diff.Add(Path+PropertyName+'='+Value);
end; end;
procedure TCompilerDiffTool.AddDiffItemUndefined(const PropertyName: string);
begin
if Self=nil then exit;
Differ:=true;
if Diff<>nil then
Diff.Add(Path+PropertyName+' undefined');
end;
function TCompilerDiffTool.AddDiff(const PropertyName: string; const Old, function TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: string): boolean; New: string): boolean;
begin begin
//if Self<>nil then debugln(['TCompilerDiffTool.AddDiff ',PropertyName,'=',Old,',',New]);
if Old=New then exit(false); if Old=New then exit(false);
Result:=true; Result:=true;
if Self=nil then exit; if Self=nil then exit;

View File

@ -88,17 +88,27 @@ function TCompilerPathOptionsFrame.Check: boolean;
end; end;
var var
OldIncludePath: String; OldParsedIncludePath: String;
OldLibraryPath: String; OldParsedLibraryPath: String;
OldUnitPath: String; OldParsedUnitPath: String;
OldSrcPath: String; OldParsedSrcPath: String;
OldDebugPath: String; OldParsedDebugPath: String;
OldUnparsedIncludePath: String;
OldUnparsedLibraryPath: String;
OldUnparsedUnitPath: String;
OldUnparsedSrcPath: String;
OldUnparsedDebugPath: String;
begin begin
OldIncludePath := FCompilerOpts.GetIncludePath(False); OldParsedIncludePath := FCompilerOpts.GetIncludePath(False);
OldLibraryPath := FCompilerOpts.GetLibraryPath(False); OldUnparsedIncludePath := FCompilerOpts.IncludePath;
OldUnitPath := FCompilerOpts.GetUnitPath(False); OldParsedLibraryPath := FCompilerOpts.GetLibraryPath(False);
OldSrcPath := FCompilerOpts.GetSrcPath(False); OldUnparsedLibraryPath := FCompilerOpts.Libraries;
OldDebugPath := FCompilerOpts.GetDebugPath(False); OldParsedUnitPath := FCompilerOpts.GetUnitPath(False);
OldUnparsedUnitPath := FCompilerOpts.OtherUnitFiles;
OldParsedSrcPath := FCompilerOpts.GetSrcPath(False);
OldUnparsedSrcPath := FCompilerOpts.SrcPath;
OldParsedDebugPath := FCompilerOpts.GetDebugPath(False);
OldUnparsedDebugPath := FCompilerOpts.DebugPath;
try try
FCompilerOpts.IncludePath := IncludeFilesEdit.Text; FCompilerOpts.IncludePath := IncludeFilesEdit.Text;
@ -106,22 +116,22 @@ begin
FCompilerOpts.OtherUnitFiles := OtherUnitsEdit.Text; FCompilerOpts.OtherUnitFiles := OtherUnitsEdit.Text;
FCompilerOpts.SrcPath := OtherSourcesEdit.Text; FCompilerOpts.SrcPath := OtherSourcesEdit.Text;
FCompilerOpts.DebugPath := DebugPathEdit.Text; FCompilerOpts.DebugPath := DebugPathEdit.Text;
if not CheckPutSearchPath('include search path', OldIncludePath, FCompilerOpts.GetIncludePath(False)) then if not CheckPutSearchPath('include search path', OldParsedIncludePath, FCompilerOpts.GetIncludePath(False)) then
Exit(False); Exit(False);
if not CheckPutSearchPath('library search path', OldLibraryPath, FCompilerOpts.GetLibraryPath(False)) then if not CheckPutSearchPath('library search path', OldParsedLibraryPath, FCompilerOpts.GetLibraryPath(False)) then
Exit(False); Exit(False);
if not CheckPutSearchPath('unit search path', OldUnitPath, FCompilerOpts.GetUnitPath(False)) then if not CheckPutSearchPath('unit search path', OldParsedUnitPath, FCompilerOpts.GetUnitPath(False)) then
Exit(False); Exit(False);
if not CheckPutSearchPath('source search path', OldSrcPath, FCompilerOpts.GetSrcPath(False)) then if not CheckPutSearchPath('source search path', OldParsedSrcPath, FCompilerOpts.GetSrcPath(False)) then
Exit(False); Exit(False);
if not CheckPutSearchPath('debugger search path', OldDebugPath, FCompilerOpts.GetDebugPath(False)) then if not CheckPutSearchPath('debugger search path', OldParsedDebugPath, FCompilerOpts.GetDebugPath(False)) then
Exit(False); Exit(False);
finally finally
FCompilerOpts.IncludePath := OldIncludePath; FCompilerOpts.IncludePath := OldUnparsedIncludePath;
FCompilerOpts.Libraries := OldLibraryPath; FCompilerOpts.Libraries := OldUnparsedLibraryPath;
FCompilerOpts.OtherUnitFiles := OldUnitPath; FCompilerOpts.OtherUnitFiles := OldUnparsedUnitPath;
FCompilerOpts.SrcPath := OldSrcPath; FCompilerOpts.SrcPath := OldUnparsedSrcPath;
FCompilerOpts.DebugPath := OldDebugPath; FCompilerOpts.DebugPath := OldUnparsedDebugPath;
end; end;
Result := True; Result := True;
end; end;

View File

@ -528,7 +528,7 @@ type
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; override; function IsEqual(CompOpts: TBaseCompilerOptions): boolean; override;
function CreateDiff(CompOpts: TBaseCompilerOptions; function CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool = nil): boolean; override; // true if differ Tool: TCompilerDiffTool = nil): boolean; override; // true if differ
procedure InvalidateOptions; procedure InvalidateOptions;
function GetEffectiveLCLWidgetType: string; override; function GetEffectiveLCLWidgetType: string; override;
public public
@ -617,6 +617,8 @@ type
procedure Clear; procedure Clear;
function Equals(Other: TProjectBuildMacros): boolean; reintroduce; function Equals(Other: TProjectBuildMacros): boolean; reintroduce;
function Equals(aValues: TStringList): boolean; reintroduce; function Equals(aValues: TStringList): boolean; reintroduce;
function CreateDiff(Other: TProjectBuildMacros;
Tool: TCompilerDiffTool = nil): boolean;
procedure Assign(Src: TProjectBuildMacros); overload; procedure Assign(Src: TProjectBuildMacros); overload;
procedure Assign(aValues: TStringList); overload; procedure Assign(aValues: TStringList); overload;
function Count: integer; function Count: integer;
@ -657,6 +659,8 @@ type
function LazProject: TProject; function LazProject: TProject;
procedure Clear; procedure Clear;
function Equals(Src: TProjectBuildMode): boolean; reintroduce; function Equals(Src: TProjectBuildMode): boolean; reintroduce;
function CreateDiff(Other: TProjectBuildMode;
Tool: TCompilerDiffTool = nil): boolean;
procedure Assign(Src: TProjectBuildMode); reintroduce; procedure Assign(Src: TProjectBuildMode); reintroduce;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
@ -5665,7 +5669,8 @@ begin
Result:=true; Result:=true;
if Tool<>nil then Tool.Differ:=true; if Tool<>nil then Tool.Differ:=true;
end; end;
Result:=Result or inherited CreateDiff(CompOpts, Tool); if (Tool=nil) and Result then exit;
if (inherited CreateDiff(CompOpts, Tool)) then Result:=true;
end; end;
procedure TProjectCompilationToolOptions.Assign(Src: TCompilationToolOptions); procedure TProjectCompilationToolOptions.Assign(Src: TCompilationToolOptions);
@ -5832,6 +5837,7 @@ end;
function TProjectCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions; function TProjectCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool): boolean; Tool: TCompilerDiffTool): boolean;
begin begin
//if Tool<>nil then debugln(['TProjectCompilerOptions.CreateDiff ',DbgSName(Self)]);
if (CompOpts is TProjectCompilerOptions) then begin if (CompOpts is TProjectCompilerOptions) then begin
Result:=AddCompileReasonsDiff('CompileReasons',FCompileReasons, Result:=AddCompileReasonsDiff('CompileReasons',FCompileReasons,
TProjectCompilerOptions(CompOpts).FCompileReasons,Tool); TProjectCompilerOptions(CompOpts).FCompileReasons,Tool);
@ -5839,7 +5845,10 @@ begin
Result:=true; Result:=true;
if Tool<>nil then Tool.Differ:=true; if Tool<>nil then Tool.Differ:=true;
end; end;
Result:=Result or inherited CreateDiff(CompOpts, Tool); //if Tool<>nil then debugln(['TProjectCompilerOptions.CreateDiff AAA1 ',Result]);
if (Tool=nil) and Result then exit;
if (inherited CreateDiff(CompOpts, Tool)) then
Result:=true;
end; end;
procedure TProjectCompilerOptions.InvalidateOptions; procedure TProjectCompilerOptions.InvalidateOptions;
@ -6536,7 +6545,7 @@ end;
function TProjectBuildMacros.Equals(Other: TProjectBuildMacros): boolean; function TProjectBuildMacros.Equals(Other: TProjectBuildMacros): boolean;
begin begin
Result:=FItems.Equals(Other.FItems); Result:=not CreateDiff(Other);
end; end;
function TProjectBuildMacros.Equals(aValues: TStringList): boolean; function TProjectBuildMacros.Equals(aValues: TStringList): boolean;
@ -6545,7 +6554,6 @@ var
CurName: string; CurName: string;
CurValue: string; CurValue: string;
begin begin
Result:=false;
for i:=0 to aValues.Count-1 do begin for i:=0 to aValues.Count-1 do begin
CurName:=aValues.Names[i]; CurName:=aValues.Names[i];
CurValue:=aValues.ValueFromIndex[i]; CurValue:=aValues.ValueFromIndex[i];
@ -6557,6 +6565,42 @@ begin
Result:=aValues.Count=Count; Result:=aValues.Count=Count;
end; end;
function TProjectBuildMacros.CreateDiff(Other: TProjectBuildMacros;
Tool: TCompilerDiffTool): boolean;
{ add anything new or different in Other and if something is not in Other
add an undefined line
}
var
i: Integer;
CurName: string;
CurValue: string;
begin
Result:=false;
for i:=0 to Other.Count-1 do begin
CurName:=Other.Names[i];
CurValue:=Other.ValueFromIndex(i);
//debugln(['TProjectBuildMacros.Equals ',CurName,' NewValue=',CurValue,' IsDefined=',IsDefined(CurName),' OldValue=',Values[CurName]]);
if Tool=nil then
begin
if Values[CurName]<>CurValue then exit(true);
end else
Result:=Result or Tool.AddDiff('BuildMacros/'+CurName,Values[CurName],CurValue);
end;
if Tool<>nil then
begin
for i:=0 to Count-1 do
begin
CurName:=ValueFromIndex(i);
if not Other.IsDefined(CurName) then
begin
Result:=true;
Tool.AddDiffItemUndefined('BuildMacros/'+CurName);
end;
end;
end;
//debugln(['TProjectBuildMacros.Equals END ',aValues.Count,' ',Count]);
end;
procedure TProjectBuildMacros.Assign(Src: TProjectBuildMacros); procedure TProjectBuildMacros.Assign(Src: TProjectBuildMacros);
begin begin
if Equals(Src) then exit; if Equals(Src) then exit;
@ -6733,6 +6777,16 @@ begin
and MacroValues.Equals(Src.MacroValues); and MacroValues.Equals(Src.MacroValues);
end; end;
function TProjectBuildMode.CreateDiff(Other: TProjectBuildMode;
Tool: TCompilerDiffTool): boolean;
begin
// Note: if there is a Tool all steps must be evaluated, if not exit on first diff
//if Tool<>nil then debugln(['TProjectBuildMode.CreateDiff ']);
Result:=CompilerOptions.CreateDiff(Other.CompilerOptions,Tool);
if (Tool=nil) and Result then exit;
if MacroValues.CreateDiff(Other.MacroValues,Tool) then Result:=true;
end;
procedure TProjectBuildMode.Assign(Src: TProjectBuildMode); procedure TProjectBuildMode.Assign(Src: TProjectBuildMode);
begin begin
if Equals(Src) then exit; if Equals(Src) then exit;