added diff for compiler options

git-svn-id: trunk@9362 -
This commit is contained in:
mattias 2006-05-27 13:36:02 +00:00
parent 1edcb3c436
commit 1552df85ab
6 changed files with 338 additions and 127 deletions

View File

@ -214,6 +214,32 @@ const
type type
{ TCompilerDiffTool
A tool to create the difference between two option sets }
TCompilerDiffTool = class
private
FDiff: TStrings;
FDiffer: boolean;
FPath: string;
procedure SetDiff(const AValue: TStrings);
procedure SetDiffer(const AValue: boolean);
procedure SetPath(const AValue: string);
public
constructor Create(DiffList: TStrings);
procedure AddDiffItem(const PropertyName, Value: string);
procedure AddDiff(const PropertyName: string; const Old, New: string);
procedure AddDiff(const PropertyName: string; const Old, New: integer);
procedure AddDiff(const PropertyName: string; const Old, New: boolean);
procedure AddPathsDiff(const PropertyName: string; const Old, New: string);
procedure AddSetDiff(const PropertyName: string; const Old, New: integer;
const EnumNames: PString);
property Diff: TStrings read FDiff write SetDiff;
property Path: string read FPath write SetPath;
property Differ: boolean read FDiffer write SetDiffer;
end;
{ TCompilationToolOptions } { TCompilationToolOptions }
TCompilationToolOptions = class TCompilationToolOptions = class
@ -223,11 +249,13 @@ type
ScanForMakeMessages: boolean; ScanForMakeMessages: boolean;
ShowAllMessages: boolean; ShowAllMessages: boolean;
procedure Clear; virtual; procedure Clear; virtual;
function IsEqual(Params: TCompilationToolOptions): boolean; virtual; function IsEqual(CompOpts: TCompilationToolOptions): boolean;
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;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); virtual; procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); virtual;
procedure CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool); virtual;
end; end;
TCompilationToolClass = class of TCompilationToolOptions; TCompilationToolClass = class of TCompilationToolOptions;
@ -248,6 +276,7 @@ type
fTargetFilename: string; fTargetFilename: string;
fXMLFile: String; fXMLFile: String;
FXMLConfig: TXMLConfig; FXMLConfig: TXMLConfig;
FTargets: TFPList;// list of TCompileTarget
// Compilation // Compilation
fCompilerPath: String; fCompilerPath: String;
@ -287,8 +316,11 @@ type
procedure LoadCompilerOptions(UseExistingFile: Boolean); procedure LoadCompilerOptions(UseExistingFile: Boolean);
procedure SaveCompilerOptions(UseExistingFile: Boolean); procedure SaveCompilerOptions(UseExistingFile: Boolean);
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; virtual; function IsEqual(CompOpts: TBaseCompilerOptions): boolean;
procedure CreateDiff(CompOpts: TBaseCompilerOptions; Diff: TStrings);
procedure CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool); virtual;
function MakeOptionsString(Globals: TGlobalCompilerOptions; function MakeOptionsString(Globals: TGlobalCompilerOptions;
Flags: TCompilerCmdLineOptions): String; Flags: TCompilerCmdLineOptions): String;
function MakeOptionsString(const MainSourceFileName: string; function MakeOptionsString(const MainSourceFileName: string;
@ -335,7 +367,7 @@ type
function GetCustomOptions(Parsed: TCompilerOptionsParseType = coptParsed): string; function GetCustomOptions(Parsed: TCompilerOptionsParseType = coptParsed): string;
function GetEffectiveLCLWidgetType: string; function GetEffectiveLCLWidgetType: string;
public public
{ Properties } // Properties
property ParsedOpts: TParsedCompilerOptions read FParsedOpts; property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory; property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property TargetFilename: String read fTargetFilename write fTargetFilename; property TargetFilename: String read fTargetFilename write fTargetFilename;
@ -413,8 +445,11 @@ type
const const
CompilationGenerateCodeNames: array [TCompilationGenerateCode] of string = ( CompileReasonNames: array[TCompileReason] of string = (
'Normal', 'Faster', 'Smaller'); 'Compile',
'Build',
'Run'
);
type type
TCompilerGraphStampIncreasedEvent = procedure of object; TCompilerGraphStampIncreasedEvent = procedure of object;
@ -715,7 +750,7 @@ function CompilationGenerateCodeNameToType(
const Name: string): TCompilationGenerateCode; const Name: string): TCompilationGenerateCode;
begin begin
for Result:=Low(TCompilationGenerateCode) to High(TCompilationGenerateCode) do for Result:=Low(TCompilationGenerateCode) to High(TCompilationGenerateCode) do
if AnsiCompareText(Name,CompilationGenerateCodeNames[Result])=0 then exit; if CompareText(Name,CompilationGenerateCodeNames[Result])=0 then exit;
Result:=cgcNormalCode; Result:=cgcNormalCode;
end; end;
@ -752,6 +787,7 @@ begin
FParsedOpts := TParsedCompilerOptions.Create; FParsedOpts := TParsedCompilerOptions.Create;
FExecuteBefore := AToolClass.Create; FExecuteBefore := AToolClass.Create;
FExecuteAfter := AToolClass.Create; FExecuteAfter := AToolClass.Create;
FTargets := TFPList.Create;
Clear; Clear;
end; end;
@ -1030,7 +1066,7 @@ begin
p:=Path+'Parsing/SyntaxOptions/' p:=Path+'Parsing/SyntaxOptions/'
else else
p:=Path+'SymantecChecking/'; p:=Path+'SymantecChecking/';
D2Extensions := XMLConfigFile.GetValue(p+'D2Extensions/Value', true); Delphi2Extensions := XMLConfigFile.GetValue(p+'D2Extensions/Value', true);
CStyleOperators := XMLConfigFile.GetValue(p+'CStyleOperator/Value', true); CStyleOperators := XMLConfigFile.GetValue(p+'CStyleOperator/Value', true);
IncludeAssertionCode := XMLConfigFile.GetValue(p+'IncludeAssertionCode/Value', false); IncludeAssertionCode := XMLConfigFile.GetValue(p+'IncludeAssertionCode/Value', false);
AllowLabel := XMLConfigFile.GetValue(p+'AllowLabel/Value', true); AllowLabel := XMLConfigFile.GetValue(p+'AllowLabel/Value', true);
@ -1180,7 +1216,7 @@ begin
{ Syntax Options } { Syntax Options }
p:=Path+'Parsing/SyntaxOptions/'; p:=Path+'Parsing/SyntaxOptions/';
XMLConfigFile.SetDeleteValue(p+'D2Extensions/Value', D2Extensions,true); XMLConfigFile.SetDeleteValue(p+'D2Extensions/Value', Delphi2Extensions,true);
XMLConfigFile.SetDeleteValue(p+'CStyleOperator/Value', CStyleOperators,true); XMLConfigFile.SetDeleteValue(p+'CStyleOperator/Value', CStyleOperators,true);
XMLConfigFile.SetDeleteValue(p+'IncludeAssertionCode/Value', IncludeAssertionCode,false); XMLConfigFile.SetDeleteValue(p+'IncludeAssertionCode/Value', IncludeAssertionCode,false);
XMLConfigFile.SetDeleteValue(p+'AllowLabel/Value', AllowLabel,true); XMLConfigFile.SetDeleteValue(p+'AllowLabel/Value', AllowLabel,true);
@ -1836,7 +1872,7 @@ Processor specific options:
} }
tempsw := ''; tempsw := '';
if (D2Extensions) then if (Delphi2Extensions) then
tempsw := tempsw + '2'; tempsw := tempsw + '2';
if (CStyleOperators) then if (CStyleOperators) then
tempsw := tempsw + 'c'; tempsw := tempsw + 'c';
@ -2228,7 +2264,7 @@ begin
// parsing // parsing
fAssemblerStyle := 0; fAssemblerStyle := 0;
fD2Ext := true; fDelphi2Ext := true;
fCStyleOp := true; fCStyleOp := true;
fIncludeAssertionCode := false; fIncludeAssertionCode := false;
fAllowLabel := true; fAllowLabel := true;
@ -2332,7 +2368,7 @@ begin
// Parsing // Parsing
fAssemblerStyle := CompOpts.fAssemblerStyle; fAssemblerStyle := CompOpts.fAssemblerStyle;
fD2Ext := CompOpts.fD2Ext; fDelphi2Ext := CompOpts.fDelphi2Ext;
fCStyleOp := CompOpts.fCStyleOp; fCStyleOp := CompOpts.fCStyleOp;
fIncludeAssertionCode := CompOpts.fIncludeAssertionCode; fIncludeAssertionCode := CompOpts.fIncludeAssertionCode;
fAllowLabel := CompOpts.fAllowLabel; fAllowLabel := CompOpts.fAllowLabel;
@ -2413,100 +2449,141 @@ begin
end; end;
function TBaseCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions): boolean; function TBaseCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions): boolean;
var
Tool: TCompilerDiffTool;
begin begin
Result:= Tool:=TCompilerDiffTool.Create(nil);
// search paths CreateDiff(CompOpts,Tool);
(fIncludePaths = CompOpts.fIncludePaths) Result:=Tool.Differ;
and (fLibraryPaths = CompOpts.fLibraryPaths) Tool.Free;
and (fUnitPaths = CompOpts.fUnitPaths) end;
and (fUnitOutputDir = CompOpts.fUnitOutputDir)
and (FObjectPath = CompOpts.FObjectPath)
and (FSrcPath = CompOpts.FSrcPath)
and (fDebugPath = CompOpts.fDebugPath)
and (fLCLWidgetType = CompOpts.fLCLWidgetType) procedure TBaseCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
Diff: TStrings);
var
Tool: TCompilerDiffTool;
begin
Tool:=TCompilerDiffTool.Create(Diff);
CreateDiff(CompOpts,Tool);
Tool.Free;
end;
// parsing procedure TBaseCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
and (fAssemblerStyle = CompOpts.fAssemblerStyle) Tool: TCompilerDiffTool);
and (fD2Ext = CompOpts.fD2Ext)
and (fCStyleOp = CompOpts.fCStyleOp)
and (fIncludeAssertionCode = CompOpts.fIncludeAssertionCode)
and (fAllowLabel = CompOpts.fAllowLabel)
and (fCPPInline = CompOpts.fCPPInline)
and (fCMacros = CompOpts.fCMacros)
and (fTPCompat = CompOpts.fTPCompat)
and (fInitConst = CompOpts.fInitConst)
and (fStaticKeyword = CompOpts.fStaticKeyword)
and (fDelphiCompat = CompOpts.fDelphiCompat)
and (fUseAnsiStr = CompOpts.fUseAnsiStr)
and (fGPCCompat = CompOpts.fGPCCompat)
// code generation procedure AddDiff(const PropertyName: string;
and (fSmartLinkUnit = CompOpts.SmartLinkUnit) const Old, New: TCompilationGenerateCode);
and (fIOChecks = CompOpts.fIOChecks) begin
and (fRangeChecks = CompOpts.fRangeChecks) if Old=New then exit;
and (fOverflowChecks = CompOpts.fOverflowChecks) Tool.AddDiffItem(PropertyName,CompilationGenerateCodeNames[New]);
and (fStackChecks = CompOpts.fStackChecks) end;
and (FEmulatedFloatOpcodes = CompOpts.FEmulatedFloatOpcodes)
and (fHeapSize = CompOpts.fHeapSize)
and (fEmulatedFloatOpcodes = CompOpts.fEmulatedFloatOpcodes)
and (fGenerate = CompOpts.fGenerate)
and (fTargetProc = CompOpts.fTargetProc)
and (fTargetCPU = CompOpts.fTargetCPU)
and (fVarsInReg = CompOpts.fVarsInReg)
and (fUncertainOpt = CompOpts.fUncertainOpt)
and (fOptLevel = CompOpts.fOptLevel)
and (fTargetOS = CompOpts.fTargetOS)
// linking procedure AddDiff(const PropertyName: string;
and (fGenDebugInfo = CompOpts.fGenDebugInfo) const Old, New: TCompilationExecutableType);
and (fGenDebugDBX = CompOpts.fGenDebugDBX) begin
and (fUseLineInfoUnit = CompOpts.fUseLineInfoUnit) if Old=New then exit;
and (fUseHeaptrc = CompOpts.fUseHeaptrc) Tool.AddDiffItem(PropertyName,CompilationExecutableTypeNames[New]);
and (fUseValgrind = CompOpts.fUseValgrind) end;
and (fGenGProfCode = CompOpts.fGenGProfCode)
and (fStripSymbols = CompOpts.fStripSymbols)
and (fLinkSmart = CompOpts.fLinkSmart)
and (fPassLinkerOpt = CompOpts.fPassLinkerOpt)
and (fLinkerOptions = CompOpts.fLinkerOptions)
and (FWin32GraphicApp = CompOpts.FWin32GraphicApp)
and (FExecutableType = CompOpts.FExecutableType)
// messages begin
and (fShowErrors = CompOpts.fShowErrors) // search paths
and (fShowWarn = CompOpts.fShowWarn) Tool.Path:='Paths';
and (fShowNotes = CompOpts.fShowNotes) Tool.AddPathsDiff('IncludePaths',fIncludePaths,CompOpts.fIncludePaths);
and (fShowHints = CompOpts.fShowHints) Tool.AddPathsDiff('LibraryPaths',fLibraryPaths,CompOpts.fLibraryPaths);
and (fShowGenInfo = CompOpts.fShowGenInfo) Tool.AddPathsDiff('UnitPaths',fUnitPaths,CompOpts.fUnitPaths);
and (fShowLineNum = CompOpts.fShowLineNum) Tool.AddPathsDiff('UnitOutputDir',fUnitOutputDir,CompOpts.fUnitOutputDir);
and (fShowAll = CompOpts.fShowAll) Tool.AddPathsDiff('ObjectPath',FObjectPath,CompOpts.FObjectPath);
and (fShowAllProcsOnError = CompOpts.fShowAllProcsOnError) Tool.AddPathsDiff('SrcPath',FSrcPath,CompOpts.FSrcPath);
and (fShowDebugInfo = CompOpts.fShowDebugInfo) Tool.AddPathsDiff('DebugPath',fDebugPath,CompOpts.fDebugPath);
and (fShowUsedFiles = CompOpts.fShowUsedFiles)
and (fShowTriedFiles = CompOpts.fShowTriedFiles)
and (fShowDefMacros = CompOpts.fShowDefMacros)
and (fShowCompProc = CompOpts.fShowCompProc)
and (fShowCond = CompOpts.fShowCond)
and (fShowExecInfo = CompOpts.fShowExecInfo)
and (fShowNothing = CompOpts.fShowNothing)
and (fShowSummary = CompOpts.fShowSummary)
and (fShowHintsForUnusedUnitsInMainSrc = CompOpts.fShowHintsForUnusedUnitsInMainSrc)
and (fShowHintsForSenderNotUsed = CompOpts.fShowHintsForSenderNotUsed)
and (fWriteFPCLogo = CompOpts.fWriteFPCLogo)
// other
and (fDontUseConfigFile = CompOpts.fDontUseConfigFile)
and (fCustomConfigFile = CompOpts.fCustomConfigFile)
and (fConfigFilePath = CompOpts.fConfigFilePath)
and (fStopAfterErrCount = CompOpts.fStopAfterErrCount)
and (fCustomOptions = CompOpts.fCustomOptions)
// compilation Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType);
and (fCompilerPath = CompOpts.fCompilerPath)
and ExecuteBefore.IsEqual(CompOpts.ExecuteBefore) // parsing
and ExecuteAfter.IsEqual(CompOpts.ExecuteAfter) Tool.Path:='Parsing';
and (CreateMakefileOnBuild=CompOpts.CreateMakefileOnBuild) Tool.AddDiff('AssemblerStyle',fAssemblerStyle,CompOpts.fAssemblerStyle);
; Tool.AddDiff('Delphi2Ext',fDelphi2Ext,CompOpts.fDelphi2Ext);
Tool.AddDiff('CStyleOp',fCStyleOp,CompOpts.fCStyleOp);
Tool.AddDiff('IncludeAssertionCode',fIncludeAssertionCode,CompOpts.fIncludeAssertionCode);
Tool.AddDiff('AllowLabel',fAllowLabel,CompOpts.fAllowLabel);
Tool.AddDiff('CPPInline',fCPPInline,CompOpts.fCPPInline);
Tool.AddDiff('CMacros',fCMacros,CompOpts.fCMacros);
Tool.AddDiff('TPCompat',fTPCompat,CompOpts.fTPCompat);
Tool.AddDiff('InitConst',fInitConst,CompOpts.fInitConst);
Tool.AddDiff('StaticKeyword',fStaticKeyword,CompOpts.fStaticKeyword);
Tool.AddDiff('DelphiCompat',fDelphiCompat,CompOpts.fDelphiCompat);
Tool.AddDiff('UseAnsiStr',fUseAnsiStr,CompOpts.fUseAnsiStr);
Tool.AddDiff('GPCCompat',fGPCCompat,CompOpts.fGPCCompat);
// code generation
Tool.Path:='Code';
Tool.AddDiff('SmartLinkUnit',fSmartLinkUnit,CompOpts.SmartLinkUnit);
Tool.AddDiff('IOChecks',fIOChecks,CompOpts.fIOChecks);
Tool.AddDiff('RangeChecks',fRangeChecks,CompOpts.fRangeChecks);
Tool.AddDiff('OverflowChecks',fOverflowChecks,CompOpts.fOverflowChecks);
Tool.AddDiff('StackChecks',fStackChecks,CompOpts.fStackChecks);
Tool.AddDiff('EmulatedFloatOpcodes',FEmulatedFloatOpcodes,CompOpts.FEmulatedFloatOpcodes);
Tool.AddDiff('HeapSize',fHeapSize,CompOpts.fHeapSize);
Tool.AddDiff('EmulatedFloatOpcodes',fEmulatedFloatOpcodes,CompOpts.fEmulatedFloatOpcodes);
AddDiff('Generate',fGenerate,CompOpts.fGenerate);
Tool.AddDiff('TargetProc',fTargetProc,CompOpts.fTargetProc);
Tool.AddDiff('TargetCPU',fTargetCPU,CompOpts.fTargetCPU);
Tool.AddDiff('VarsInReg',fVarsInReg,CompOpts.fVarsInReg);
Tool.AddDiff('UncertainOpt',fUncertainOpt,CompOpts.fUncertainOpt);
Tool.AddDiff('OptLevel',fOptLevel,CompOpts.fOptLevel);
Tool.AddDiff('TargetOS',fTargetOS,CompOpts.fTargetOS);
// linking
Tool.Path:='Linking';
Tool.AddDiff('GenDebugInfo',fGenDebugInfo,CompOpts.fGenDebugInfo);
Tool.AddDiff('GenDebugDBX',fGenDebugDBX,CompOpts.fGenDebugDBX);
Tool.AddDiff('UseLineInfoUnit',fUseLineInfoUnit,CompOpts.fUseLineInfoUnit);
Tool.AddDiff('UseHeaptrc',fUseHeaptrc,CompOpts.fUseHeaptrc);
Tool.AddDiff('UseValgrind',fUseValgrind,CompOpts.fUseValgrind);
Tool.AddDiff('GenGProfCode',fGenGProfCode,CompOpts.fGenGProfCode);
Tool.AddDiff('StripSymbols',fStripSymbols,CompOpts.fStripSymbols);
Tool.AddDiff('LinkSmart',fLinkSmart,CompOpts.fLinkSmart);
Tool.AddDiff('PassLinkerOpt',fPassLinkerOpt,CompOpts.fPassLinkerOpt);
Tool.AddDiff('LinkerOptions',fLinkerOptions,CompOpts.fLinkerOptions);
Tool.AddDiff('Win32GraphicApp',FWin32GraphicApp,CompOpts.FWin32GraphicApp);
AddDiff('ExecutableType',FExecutableType,CompOpts.FExecutableType);
// messages
Tool.Path:='Messages';
Tool.AddDiff('ShowErrors',fShowErrors,CompOpts.fShowErrors);
Tool.AddDiff('ShowWarn',fShowWarn,CompOpts.fShowWarn);
Tool.AddDiff('ShowNotes',fShowNotes,CompOpts.fShowNotes);
Tool.AddDiff('ShowHints',fShowHints,CompOpts.fShowHints);
Tool.AddDiff('ShowGenInfo',fShowGenInfo,CompOpts.fShowGenInfo);
Tool.AddDiff('ShowLineNum',fShowLineNum,CompOpts.fShowLineNum);
Tool.AddDiff('ShowAll',fShowAll,CompOpts.fShowAll);
Tool.AddDiff('ShowAllProcsOnError',fShowAllProcsOnError,CompOpts.fShowAllProcsOnError);
Tool.AddDiff('ShowDebugInfo',fShowDebugInfo,CompOpts.fShowDebugInfo);
Tool.AddDiff('ShowUsedFiles',fShowUsedFiles,CompOpts.fShowUsedFiles);
Tool.AddDiff('ShowTriedFiles',fShowTriedFiles,CompOpts.fShowTriedFiles);
Tool.AddDiff('ShowDefMacros',fShowDefMacros,CompOpts.fShowDefMacros);
Tool.AddDiff('ShowCompProc',fShowCompProc,CompOpts.fShowCompProc);
Tool.AddDiff('ShowCond',fShowCond,CompOpts.fShowCond);
Tool.AddDiff('ShowExecInfo',fShowExecInfo,CompOpts.fShowExecInfo);
Tool.AddDiff('ShowNothing',fShowNothing,CompOpts.fShowNothing);
Tool.AddDiff('ShowSummary',fShowSummary,CompOpts.fShowSummary);
Tool.AddDiff('ShowHintsForUnusedUnitsInMainSrc',fShowHintsForUnusedUnitsInMainSrc,CompOpts.fShowHintsForUnusedUnitsInMainSrc);
Tool.AddDiff('ShowHintsForSenderNotUsed',fShowHintsForSenderNotUsed,CompOpts.fShowHintsForSenderNotUsed);
Tool.AddDiff('WriteFPCLogo',fWriteFPCLogo,CompOpts.fWriteFPCLogo);
// other
Tool.Path:='Other';
Tool.AddDiff('DontUseConfigFile',fDontUseConfigFile,CompOpts.fDontUseConfigFile);
Tool.AddDiff('CustomConfigFile',fCustomConfigFile,CompOpts.fCustomConfigFile);
Tool.AddDiff('ConfigFilePath',fConfigFilePath,CompOpts.fConfigFilePath);
Tool.AddDiff('StopAfterErrCount',fStopAfterErrCount,CompOpts.fStopAfterErrCount);
Tool.AddDiff('CustomOptions',fCustomOptions,CompOpts.fCustomOptions);
// compilation
Tool.Path:='Compilation';
Tool.AddDiff('CompilerPath',fCompilerPath,CompOpts.fCompilerPath);
ExecuteBefore.CreateDiff(CompOpts.ExecuteBefore,Tool);
ExecuteAfter.CreateDiff(CompOpts.ExecuteAfter,Tool);
Tool.AddDiff('CreateMakefileOnBuild',fCreateMakefileOnBuild,CompOpts.fCreateMakefileOnBuild);
end; end;
@ -2817,14 +2894,15 @@ begin
ShowAllMessages:=false; ShowAllMessages:=false;
end; end;
function TCompilationToolOptions.IsEqual(Params: TCompilationToolOptions function TCompilationToolOptions.IsEqual(CompOpts: TCompilationToolOptions
): boolean; ): boolean;
var
Tool: TCompilerDiffTool;
begin begin
Result:= (Command=Params.Command) Tool:=TCompilerDiffTool.Create(nil);
and (ScanForFPCMessages=Params.ScanForFPCMessages) CreateDiff(CompOpts,Tool);
and (ScanForMakeMessages=Params.ScanForMakeMessages) Result:=Tool.Differ;
and (ShowAllMessages=Params.ShowAllMessages) Tool.Free;
;
end; end;
procedure TCompilationToolOptions.Assign(Src: TCompilationToolOptions); procedure TCompilationToolOptions.Assign(Src: TCompilationToolOptions);
@ -2857,6 +2935,15 @@ begin
ShowAllMessages,false); ShowAllMessages,false);
end; end;
procedure TCompilationToolOptions.CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool);
begin
Tool.AddDiff('Command',Command,CompOpts.Command);
Tool.AddDiff('ScanForFPCMessages',ScanForFPCMessages,CompOpts.ScanForFPCMessages);
Tool.AddDiff('ScanForMakeMessages',ScanForMakeMessages,CompOpts.ScanForMakeMessages);
Tool.AddDiff('ShowAllMessages',ShowAllMessages,CompOpts.ShowAllMessages);
end;
{ TGlobalCompilerOptions } { TGlobalCompilerOptions }
procedure TGlobalCompilerOptions.SetTargetCPU(const AValue: string); procedure TGlobalCompilerOptions.SetTargetCPU(const AValue: string);
@ -2871,6 +2958,94 @@ begin
FTargetOS:=AValue; FTargetOS:=AValue;
end; end;
{ TCompilerDiffTool }
procedure TCompilerDiffTool.SetDiff(const AValue: TStrings);
begin
if FDiff=AValue then exit;
FDiff:=AValue;
end;
procedure TCompilerDiffTool.SetDiffer(const AValue: boolean);
begin
if FDiffer=AValue then exit;
FDiffer:=AValue;
end;
procedure TCompilerDiffTool.SetPath(const AValue: string);
begin
if FPath=AValue then exit;
FPath:=AValue;
// ! config path, not file path. Always /, not PathDelim
if (FPath<>'') and (Path[length(Path)]<>'/') then FPath:=FPath+'/';
end;
constructor TCompilerDiffTool.Create(DiffList: TStrings);
begin
FDiff:=DiffList;
if Diff<>nil then
Diff.Clear;
end;
procedure TCompilerDiffTool.AddDiffItem(const PropertyName, Value: string);
begin
Differ:=true;
if Diff<>nil then
Diff.Add(Path+PropertyName+'='+Value);
end;
procedure TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: string);
begin
if Old=New then exit;
AddDiffItem(PropertyName,New);
end;
procedure TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: integer);
begin
if Old=New then exit;
AddDiffItem(PropertyName,IntToStr(New));
end;
procedure TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: boolean);
begin
if Old=New then exit;
AddDiffItem(PropertyName,dbgs(New));
end;
procedure TCompilerDiffTool.AddPathsDiff(const PropertyName: string; const Old,
New: string);
begin
if Old=New then exit;
AddDiff(PropertyName,Old,New);
end;
procedure TCompilerDiffTool.AddSetDiff(const PropertyName: string; const Old,
New: integer; const EnumNames: PString);
var
i: Integer;
Mask: LongInt;
s: String;
begin
if Old=New then exit;
Mask := 1;
s:='';
for i := 0 to 31 do begin
if (New and Mask) <> (Old and Mask) then begin
if s<>'' then s:=s+',';
if (New and Mask) <> 0 then
s:=s+'+'
else
s:=s+'-';
s:=s+EnumNames[i];
end;
Mask := Mask shl 1;
end;
AddDiffItem(PropertyName,s);
end;
initialization initialization
CompilerParseStamp:=1; CompilerParseStamp:=1;
CompilerGraphStamp:=1; CompilerGraphStamp:=1;

View File

@ -636,7 +636,7 @@ begin
else else
grpStyle.ItemIndex:=0; grpStyle.ItemIndex:=0;
chkSymD2Ext.Checked := Options.D2Extensions; chkSymD2Ext.Checked := Options.Delphi2Extensions;
chkSymCOper.Checked := Options.CStyleOperators; chkSymCOper.Checked := Options.CStyleOperators;
chkSymIncludeAssertions.Checked := Options.IncludeAssertionCode; chkSymIncludeAssertions.Checked := Options.IncludeAssertionCode;
chkSymAllowLab.Checked := Options.AllowLabel; chkSymAllowLab.Checked := Options.AllowLabel;
@ -908,7 +908,7 @@ begin
// parsing; // parsing;
Options.AssemblerStyle := grpStyle.ItemIndex; Options.AssemblerStyle := grpStyle.ItemIndex;
Options.D2Extensions := chkSymD2Ext.Checked; Options.Delphi2Extensions := chkSymD2Ext.Checked;
Options.CStyleOperators := chkSymCOper.Checked; Options.CStyleOperators := chkSymCOper.Checked;
Options.IncludeAssertionCode := chkSymIncludeAssertions.Checked; Options.IncludeAssertionCode := chkSymIncludeAssertions.Checked;
Options.AllowLabel := chkSymAllowLab.Checked; Options.AllowLabel := chkSymAllowLab.Checked;

View File

@ -256,7 +256,8 @@ type
CompileReasons: TCompileReasons; CompileReasons: TCompileReasons;
DefaultCompileReasons: TCompileReasons; DefaultCompileReasons: TCompileReasons;
procedure Clear; override; procedure Clear; override;
function IsEqual(Params: TCompilationToolOptions): boolean; override; procedure CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool); override;
procedure Assign(Src: TCompilationToolOptions); override; procedure Assign(Src: TCompilationToolOptions); override;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
DoSwitchPathDelims: boolean); override; DoSwitchPathDelims: boolean); override;
@ -292,12 +293,14 @@ type
function GetDefaultMainSourceFileName: string; override; function GetDefaultMainSourceFileName: string; override;
procedure GetInheritedCompilerOptions(var OptionsList: TList); override; procedure GetInheritedCompilerOptions(var OptionsList: TList); override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; override; procedure CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool); override;
procedure InvalidateOptions; procedure InvalidateOptions;
public public
property OwnerProject: TProject read FOwnerProject; property OwnerProject: TProject read FOwnerProject;
property Project: TProject read FOwnerProject; property Project: TProject read FOwnerProject;
property Globals: TGlobalCompilerOptions read FGlobals; property Globals: TGlobalCompilerOptions read FGlobals;
published
property CompileReasons: TCompileReasons read FCompileReasons write FCompileReasons; property CompileReasons: TCompileReasons read FCompileReasons write FCompileReasons;
end; end;
@ -713,12 +716,23 @@ const
ResourceFileExt = '.lrs'; ResourceFileExt = '.lrs';
procedure AddCompileReasonsDiff(Tool: TCompilerDiffTool;
const PropertyName: string; const Old, New: TCompileReasons);
implementation implementation
const const
ProjectInfoFileVersion = 5; ProjectInfoFileVersion = 5;
procedure AddCompileReasonsDiff(Tool: TCompilerDiffTool;
const PropertyName: string; const Old, New: TCompileReasons);
begin
if Old=New then exit;
Tool.AddSetDiff(PropertyName,integer(Old),integer(New),
PString(@CompileReasonNames[Low(TCompileReasons)]));
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TUnitInfo Constructor TUnitInfo Constructor
@ -3604,11 +3618,16 @@ begin
CompileReasons := crAll; CompileReasons := crAll;
end; end;
function TProjectCompilationToolOptions.IsEqual(Params: TCompilationToolOptions): boolean; procedure TProjectCompilationToolOptions.CreateDiff(
CompOpts: TCompilationToolOptions; Tool: TCompilerDiffTool);
begin begin
Result := (Params is TProjectCompilationToolOptions) if (CompOpts is TProjectCompilationToolOptions) then begin
and (CompileReasons = TProjectCompilationToolOptions(Params).CompileReasons) AddCompileReasonsDiff(Tool,'CompileReasons',CompileReasons,
and inherited IsEqual(Params); TProjectCompilationToolOptions(CompOpts).CompileReasons);
end else begin
Tool.Differ:=true;
end;
inherited CreateDiff(CompOpts, Tool);
end; end;
procedure TProjectCompilationToolOptions.Assign(Src: TCompilationToolOptions); procedure TProjectCompilationToolOptions.Assign(Src: TCompilationToolOptions);
@ -3743,11 +3762,16 @@ begin
UpdateGlobals; UpdateGlobals;
end; end;
function TProjectCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions): boolean; procedure TProjectCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool);
begin begin
Result := (CompOpts is TProjectCompilerOptions) if (CompOpts is TProjectCompilerOptions) then begin
and (FCompileReasons = TProjectCompilerOptions(CompOpts).FCompileReasons) AddCompileReasonsDiff(Tool,'CompileReasons',FCompileReasons,
and inherited IsEqual(CompOpts); TProjectCompilerOptions(CompOpts).FCompileReasons);
end else begin
Tool.Differ:=true;
end;
inherited CreateDiff(CompOpts, Tool);
end; end;
procedure TProjectCompilerOptions.InvalidateOptions; procedure TProjectCompilerOptions.InvalidateOptions;

View File

@ -52,7 +52,7 @@ type
cetProgram, cetProgram,
cetLibrary cetLibrary
); );
{ TLazCompilerOptions } { TLazCompilerOptions }
TLazCompilerOptions = class(TPersistent) TLazCompilerOptions = class(TPersistent)
@ -77,7 +77,7 @@ type
fAssemblerStyle: Integer; fAssemblerStyle: Integer;
// syntax options // syntax options
fD2Ext: Boolean; fDelphi2Ext: Boolean;
fCStyleOp: Boolean; fCStyleOp: Boolean;
fIncludeAssertionCode: Boolean; fIncludeAssertionCode: Boolean;
fDelphiCompat: Boolean; fDelphiCompat: Boolean;
@ -184,7 +184,7 @@ type
// parsing: // parsing:
property AssemblerStyle: Integer read fAssemblerStyle write fAssemblerStyle; property AssemblerStyle: Integer read fAssemblerStyle write fAssemblerStyle;
property D2Extensions: Boolean read fD2Ext write fD2Ext; property Delphi2Extensions: Boolean read fDelphi2Ext write fDelphi2Ext;
property CStyleOperators: Boolean read fCStyleOp write fCStyleOp; property CStyleOperators: Boolean read fCStyleOp write fCStyleOp;
property IncludeAssertionCode: Boolean property IncludeAssertionCode: Boolean
read fIncludeAssertionCode write fIncludeAssertionCode; read fIncludeAssertionCode write fIncludeAssertionCode;
@ -616,6 +616,12 @@ const
'None' 'None'
); );
CompilationGenerateCodeNames: array[TCompilationGenerateCode] of string = (
'Normal',
'Faster',
'Smaller'
);
CompilationExecutableTypeNames: array[TCompilationExecutableType] of string =( CompilationExecutableTypeNames: array[TCompilationExecutableType] of string =(
'Program', 'Program',
'Library' 'Library'

View File

@ -371,7 +371,8 @@ type
function CreateTargetFilename(const MainSourceFileName: string): string; override; function CreateTargetFilename(const MainSourceFileName: string): string; override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; override; procedure CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool); override;
public public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage; property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
property SkipCompiler: Boolean read FSkipCompiler write FSkipCompiler; property SkipCompiler: Boolean read FSkipCompiler write FSkipCompiler;
@ -3414,11 +3415,16 @@ begin
end; end;
end; end;
function TPkgCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions): boolean; procedure TPkgCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool);
begin begin
Result := (CompOpts is TPkgCompilerOptions) if (CompOpts is TPkgCompilerOptions) then begin
and (FSkipCompiler = TPkgCompilerOptions(CompOpts).FSkipCompiler) Tool.AddDiff('SkipCompiler',FSkipCompiler,
and inherited IsEqual(CompOpts); TPkgCompilerOptions(CompOpts).FSkipCompiler);
end else begin
Tool.Differ:=true;
end;
inherited CreateDiff(CompOpts, Tool);
end; end;
{ TPkgAdditionalCompilerOptions } { TPkgAdditionalCompilerOptions }

View File

@ -1293,7 +1293,7 @@ begin
coptParsedPlatformIndependent); coptParsedPlatformIndependent);
CustomOptions:=APackage.CompilerOptions.GetCustomOptions( CustomOptions:=APackage.CompilerOptions.GetCustomOptions(
coptParsedPlatformIndependent); coptParsedPlatformIndependent);
if APackage.CompilerOptions.D2Extensions then if APackage.CompilerOptions.Delphi2Extensions then
CustomOptions:=CustomOptions+' -S2'; CustomOptions:=CustomOptions+' -S2';
if APackage.CompilerOptions.UseLineInfoUnit then if APackage.CompilerOptions.UseLineInfoUnit then
CustomOptions:=CustomOptions+' -gl'; CustomOptions:=CustomOptions+' -gl';
@ -1301,7 +1301,7 @@ begin
//DebugLn('TPkgManager.DoWriteMakefile ',APackage.Name,' makefile UnitPath="',UnitPath,'"'); //DebugLn('TPkgManager.DoWriteMakefile ',APackage.Name,' makefile UnitPath="',UnitPath,'"');
UnitPath:=ConvertLazarusToMakefileSearchPath(UnitPath); UnitPath:=ConvertLazarusToMakefileSearchPath(UnitPath);
// remove path delimeter at the end, or else it will fail on windows // remove path delimiter at the end, or else it will fail on windows
UnitOutputPath:=ConvertLazarusToMakefileDirectory( UnitOutputPath:=ConvertLazarusToMakefileDirectory(
ChompPathDelim(UnitOutputPath)); ChompPathDelim(UnitOutputPath));
MainSrcFile:=CreateRelativePath(SrcFilename,APackage.Directory); MainSrcFile:=CreateRelativePath(SrcFilename,APackage.Directory);