mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 03:00:27 +02:00
IDE: Load and save all compiler options.
git-svn-id: trunk@42144 -
This commit is contained in:
parent
e5edeb10ad
commit
3b6537c967
@ -253,6 +253,7 @@ type
|
|||||||
fCustomConfigFile: Boolean;
|
fCustomConfigFile: Boolean;
|
||||||
fConfigFilePath: String;
|
fConfigFilePath: String;
|
||||||
protected
|
protected
|
||||||
|
function GetAllOptions: TStrings; virtual; abstract;
|
||||||
function GetCustomOptions: string; virtual; abstract;
|
function GetCustomOptions: string; virtual; abstract;
|
||||||
function GetDebugPath: string; virtual; abstract;
|
function GetDebugPath: string; virtual; abstract;
|
||||||
function GetIncludePaths: String; virtual; abstract;
|
function GetIncludePaths: String; virtual; abstract;
|
||||||
@ -265,6 +266,7 @@ type
|
|||||||
procedure SetCompilerPath(const AValue: String); virtual; abstract;
|
procedure SetCompilerPath(const AValue: String); virtual; abstract;
|
||||||
procedure SetConditionals(const AValue: string); virtual; abstract;
|
procedure SetConditionals(const AValue: string); virtual; abstract;
|
||||||
procedure SetCustomOptions(const AValue: string); virtual; abstract;
|
procedure SetCustomOptions(const AValue: string); virtual; abstract;
|
||||||
|
//procedure SetAllOptions(const AValue: TStrings); virtual; abstract;
|
||||||
procedure SetDebugPath(const AValue: string); virtual; abstract;
|
procedure SetDebugPath(const AValue: string); virtual; abstract;
|
||||||
procedure SetIncludePaths(const AValue: String); virtual; abstract;
|
procedure SetIncludePaths(const AValue: String); virtual; abstract;
|
||||||
procedure SetLibraryPaths(const AValue: String); virtual; abstract;
|
procedure SetLibraryPaths(const AValue: String); virtual; abstract;
|
||||||
@ -409,16 +411,14 @@ type
|
|||||||
property ShowHintsForSenderNotUsed: Boolean
|
property ShowHintsForSenderNotUsed: Boolean
|
||||||
read fShowHintsForSenderNotUsed write SetShowHintsForSenderNotUsed;
|
read fShowHintsForSenderNotUsed write SetShowHintsForSenderNotUsed;
|
||||||
property WriteFPCLogo: Boolean read fWriteFPCLogo write SetWriteFPCLogo;
|
property WriteFPCLogo: Boolean read fWriteFPCLogo write SetWriteFPCLogo;
|
||||||
property StopAfterErrCount: integer
|
property StopAfterErrCount: integer read fStopAfterErrCount write SetStopAfterErrCount;
|
||||||
read fStopAfterErrCount write SetStopAfterErrCount;
|
|
||||||
|
|
||||||
// other
|
// other
|
||||||
property DontUseConfigFile: Boolean read fDontUseConfigFile
|
property DontUseConfigFile: Boolean read fDontUseConfigFile write SetDontUseConfigFile;
|
||||||
write SetDontUseConfigFile;
|
property CustomConfigFile: Boolean read fCustomConfigFile write SetCustomConfigFile;
|
||||||
property CustomConfigFile: Boolean read fCustomConfigFile
|
|
||||||
write SetCustomConfigFile;
|
|
||||||
property ConfigFilePath: String read fConfigFilePath write SetConfigFilePath;
|
property ConfigFilePath: String read fConfigFilePath write SetConfigFilePath;
|
||||||
property CustomOptions: string read GetCustomOptions write SetCustomOptions;
|
property CustomOptions: string read GetCustomOptions write SetCustomOptions;
|
||||||
|
property AllOptions: TStrings read GetAllOptions; // write SetAllOptions;
|
||||||
|
|
||||||
// execute other
|
// execute other
|
||||||
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract; // disable normal compile and call this instead
|
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract; // disable normal compile and call this instead
|
||||||
|
@ -183,6 +183,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function ReadAndParseOptions: TModalResult;
|
function ReadAndParseOptions: TModalResult;
|
||||||
function FilterOptions(aFilter: string): Boolean;
|
function FilterOptions(aFilter: string): Boolean;
|
||||||
|
function CopyNonDefaultOptions(aStrings: TStrings): integer;
|
||||||
public
|
public
|
||||||
property SupportedCategories: TStringList read fSupportedCategories;
|
property SupportedCategories: TStringList read fSupportedCategories;
|
||||||
property RootOptGroup: TCompilerOptGroup read fRootOptGroup;
|
property RootOptGroup: TCompilerOptGroup read fRootOptGroup;
|
||||||
@ -761,5 +762,38 @@ begin
|
|||||||
Result := FilterOptionsSub(fRootOptGroup);
|
Result := FilterOptionsSub(fRootOptGroup);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCompilerOptReader.CopyNonDefaultOptions(aStrings: TStrings): integer;
|
||||||
|
// Copy options to a list if they have a non-default value (True for boolean).
|
||||||
|
|
||||||
|
function CopyOptionsSub(aRoot: TCompilerOpt): integer;
|
||||||
|
var
|
||||||
|
Children: TCompilerOptList;
|
||||||
|
i, Res: Integer;
|
||||||
|
s: string;
|
||||||
|
begin
|
||||||
|
if aRoot is TCompilerOptGroup then
|
||||||
|
begin
|
||||||
|
Children := TCompilerOptGroup(aRoot).CompilerOpts;
|
||||||
|
if aRoot is TCompilerOptSet then
|
||||||
|
begin // TCompilerOptSet
|
||||||
|
for i := 0 to Children.Count-1 do // Collect subitems of a set to one option.
|
||||||
|
s := s + TCompilerOpt(Children[i]).Option;
|
||||||
|
aStrings.Add(s);
|
||||||
|
end
|
||||||
|
else begin // TCompilerOptGroup
|
||||||
|
for i := 0 to Children.Count-1 do // Recursive call for children.
|
||||||
|
Res := CopyOptionsSub(TCompilerOpt(Children[i]));
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin // TCompilerOpt
|
||||||
|
aStrings.Add(aRoot.Option);
|
||||||
|
end;
|
||||||
|
Result := Res;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result := CopyOptionsSub(fRootOptGroup);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -434,6 +434,21 @@ const
|
|||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TBaseCompilerOptions = class;
|
||||||
|
|
||||||
|
{ TAllOptionsList }
|
||||||
|
|
||||||
|
TAllOptionsList = class(TStringList)
|
||||||
|
private
|
||||||
|
FOwner: TBaseCompilerOptions;
|
||||||
|
protected
|
||||||
|
procedure InsertItem(Index: Integer; const S: string); override;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TBaseCompilerOptions);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Delete(Index: Integer); override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TBaseCompilerOptions }
|
{ TBaseCompilerOptions }
|
||||||
|
|
||||||
TBaseCompilerOptions = class(TLazCompilerOptions)
|
TBaseCompilerOptions = class(TLazCompilerOptions)
|
||||||
@ -443,6 +458,7 @@ type
|
|||||||
fInheritedOptParseStamps: integer;
|
fInheritedOptParseStamps: integer;
|
||||||
FParsedOpts: TParsedCompilerOptions;
|
FParsedOpts: TParsedCompilerOptions;
|
||||||
FStorePathDelim: TPathDelimSwitch;
|
FStorePathDelim: TPathDelimSwitch;
|
||||||
|
FAllOptions: TAllOptionsList;
|
||||||
|
|
||||||
// Compilation
|
// Compilation
|
||||||
fExecuteBefore: TCompilationToolOptions;
|
fExecuteBefore: TCompilationToolOptions;
|
||||||
@ -458,6 +474,7 @@ type
|
|||||||
procedure OnItemChanged(Sender: TObject);
|
procedure OnItemChanged(Sender: TObject);
|
||||||
procedure SetCreateMakefileOnBuild(AValue: boolean);
|
procedure SetCreateMakefileOnBuild(AValue: boolean);
|
||||||
protected
|
protected
|
||||||
|
function GetAllOptions: TStrings; override;
|
||||||
function GetCompilerPath: String;
|
function GetCompilerPath: String;
|
||||||
function GetBaseDirectory: string;
|
function GetBaseDirectory: string;
|
||||||
function GetCustomOptions: string; override;
|
function GetCustomOptions: string; override;
|
||||||
@ -1053,6 +1070,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TAllOptionsList }
|
||||||
|
|
||||||
|
constructor TAllOptionsList.Create(AOwner: TBaseCompilerOptions);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FOwner:=AOwner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TAllOptionsList.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TAllOptionsList.InsertItem(Index: Integer; const S: string);
|
||||||
|
begin
|
||||||
|
inherited InsertItem(Index, S);
|
||||||
|
FOwner.IncreaseChangeStamp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TAllOptionsList.Delete(Index: Integer);
|
||||||
|
begin
|
||||||
|
inherited Delete(Index);
|
||||||
|
FOwner.IncreaseChangeStamp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TBaseCompilerOptions }
|
{ TBaseCompilerOptions }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1063,13 +1106,14 @@ constructor TBaseCompilerOptions.Create(const AOwner: TObject;
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FParsedOpts := TParsedCompilerOptions.Create(Self);
|
FParsedOpts := TParsedCompilerOptions.Create(Self);
|
||||||
|
FAllOptions := TAllOptionsList.Create(Self);
|
||||||
FExecuteBefore := AToolClass.Create(Self);
|
FExecuteBefore := AToolClass.Create(Self);
|
||||||
FExecuteBefore.OnChanged:=@OnItemChanged;
|
FExecuteBefore.OnChanged := @OnItemChanged;
|
||||||
FExecuteAfter := AToolClass.Create(Self);
|
FExecuteAfter := AToolClass.Create(Self);
|
||||||
fExecuteAfter.OnChanged:=@OnItemChanged;
|
fExecuteAfter.OnChanged := @OnItemChanged;
|
||||||
fBuildMacros := TIDEBuildMacros.Create(Self);
|
fBuildMacros := TIDEBuildMacros.Create(Self);
|
||||||
FCompilerMessages:=TCompilerMessagesList.Create;
|
FCompilerMessages:=TCompilerMessagesList.Create;
|
||||||
FCompilerMessages.OnChanged:=@OnItemChanged;
|
FCompilerMessages.OnChanged := @OnItemChanged;
|
||||||
Clear;
|
Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1087,6 +1131,7 @@ begin
|
|||||||
FreeAndNil(fBuildMacros);
|
FreeAndNil(fBuildMacros);
|
||||||
FreeThenNil(fExecuteBefore);
|
FreeThenNil(fExecuteBefore);
|
||||||
FreeThenNil(fExecuteAfter);
|
FreeThenNil(fExecuteAfter);
|
||||||
|
FreeThenNil(FAllOptions);
|
||||||
FreeThenNil(FParsedOpts);
|
FreeThenNil(FParsedOpts);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -1238,6 +1283,11 @@ begin
|
|||||||
IncreaseChangeStamp;
|
IncreaseChangeStamp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBaseCompilerOptions.GetAllOptions: TStrings;
|
||||||
|
begin
|
||||||
|
Result:=FAllOptions;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBaseCompilerOptions.GetCompilerPath: String;
|
function TBaseCompilerOptions.GetCompilerPath: String;
|
||||||
begin
|
begin
|
||||||
Result:=ParsedOpts.Values[pcosCompilerPath].UnparsedValue;
|
Result:=ParsedOpts.Values[pcosCompilerPath].UnparsedValue;
|
||||||
@ -1357,10 +1407,10 @@ end;
|
|||||||
procedure TBaseCompilerOptions.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
|
procedure TBaseCompilerOptions.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
|
||||||
const Path: string);
|
const Path: string);
|
||||||
var
|
var
|
||||||
p: String;
|
p, s: String;
|
||||||
b, PathDelimChange: boolean;
|
b, PathDelimChange: boolean;
|
||||||
FileVersion: Integer;
|
FileVersion: Integer;
|
||||||
i: LongInt;
|
i, Cnt: LongInt;
|
||||||
dit: TCompilerDbgSymbolType;
|
dit: TCompilerDbgSymbolType;
|
||||||
|
|
||||||
function f(const Filename: string): string;
|
function f(const Filename: string): string;
|
||||||
@ -1571,14 +1621,13 @@ begin
|
|||||||
with aXMLConfig do begin
|
with aXMLConfig do begin
|
||||||
// ErrorNames should be stored, because the Message file is not read (or parsed)
|
// ErrorNames should be stored, because the Message file is not read (or parsed)
|
||||||
// on project opening. So errors needs to be initialized properly from the CompilerOptions.xml
|
// on project opening. So errors needs to be initialized properly from the CompilerOptions.xml
|
||||||
fCompilerMessages.fErrorNames[etHint]:=GetValue(p+'fCompilerMessages/ErrorNames/Hint', FPCErrorTypeNames[etHint]);
|
fCompilerMessages.fErrorNames[etHint] :=GetValue(p+'CompilerMessages/ErrorNames/Hint', FPCErrorTypeNames[etHint]);
|
||||||
fCompilerMessages.fErrorNames[etNote]:=GetValue(p+'fCompilerMessages/ErrorNames/Note', FPCErrorTypeNames[etNote]);
|
fCompilerMessages.fErrorNames[etNote] :=GetValue(p+'CompilerMessages/ErrorNames/Note', FPCErrorTypeNames[etNote]);
|
||||||
fCompilerMessages.fErrorNames[etWarning]:=GetValue(p+'fCompilerMessages/ErrorNames/Warning', FPCErrorTypeNames[etWarning]);
|
fCompilerMessages.fErrorNames[etWarning]:=GetValue(p+'CompilerMessages/ErrorNames/Warning', FPCErrorTypeNames[etWarning]);
|
||||||
fCompilerMessages.fErrorNames[etError]:=GetValue(p+'fCompilerMessages/ErrorNames/Error', FPCErrorTypeNames[etError]);
|
fCompilerMessages.fErrorNames[etError] :=GetValue(p+'CompilerMessages/ErrorNames/Error', FPCErrorTypeNames[etError]);
|
||||||
fCompilerMessages.fErrorNames[etFatal]:=GetValue(p+'fCompilerMessages/ErrorNames/Fatal', FPCErrorTypeNames[etFatal]);
|
fCompilerMessages.fErrorNames[etFatal] :=GetValue(p+'CompilerMessages/ErrorNames/Fatal', FPCErrorTypeNames[etFatal]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Other }
|
{ Other }
|
||||||
p:=Path+'Other/';
|
p:=Path+'Other/';
|
||||||
DontUseConfigFile := aXMLConfig.GetValue(p+'ConfigFile/DontUseConfigFile/Value', false);
|
DontUseConfigFile := aXMLConfig.GetValue(p+'ConfigFile/DontUseConfigFile/Value', false);
|
||||||
@ -1588,6 +1637,14 @@ begin
|
|||||||
CustomConfigFile := aXMLConfig.GetValue(p+'ConfigFile/CustomConfigFile/Value', false);
|
CustomConfigFile := aXMLConfig.GetValue(p+'ConfigFile/CustomConfigFile/Value', false);
|
||||||
ConfigFilePath := f(aXMLConfig.GetValue(p+'ConfigFile/ConfigFilePath/Value', 'extrafpc.cfg'));
|
ConfigFilePath := f(aXMLConfig.GetValue(p+'ConfigFile/ConfigFilePath/Value', 'extrafpc.cfg'));
|
||||||
CustomOptions := LineBreaksToSystemLineBreaks(aXMLConfig.GetValue(p+'CustomOptions/Value', ''));
|
CustomOptions := LineBreaksToSystemLineBreaks(aXMLConfig.GetValue(p+'CustomOptions/Value', ''));
|
||||||
|
// All options
|
||||||
|
AllOptions.Clear;
|
||||||
|
Cnt:=aXMLConfig.GetValue(p+'AllOptions/Count', 0);
|
||||||
|
for i:=0 to Cnt-1 do begin
|
||||||
|
s:=aXMLConfig.GetValue(p+'AllOptions/Item'+IntToStr(i)+'/', '');
|
||||||
|
if s<>'' then
|
||||||
|
AllOptions.Add(s);
|
||||||
|
end;
|
||||||
|
|
||||||
{ Compilation }
|
{ Compilation }
|
||||||
CompilerPath := f(aXMLConfig.GetValue(p+'CompilerPath/Value','$(CompPath)'));
|
CompilerPath := f(aXMLConfig.GetValue(p+'CompilerPath/Value','$(CompPath)'));
|
||||||
@ -1772,6 +1829,10 @@ begin
|
|||||||
aXMLConfig.SetDeleteValue(p+'ConfigFile/ConfigFilePath/Value', f(ConfigFilePath),'extrafpc.cfg');
|
aXMLConfig.SetDeleteValue(p+'ConfigFile/ConfigFilePath/Value', f(ConfigFilePath),'extrafpc.cfg');
|
||||||
aXMLConfig.SetDeleteValue(p+'CustomOptions/Value',
|
aXMLConfig.SetDeleteValue(p+'CustomOptions/Value',
|
||||||
LineBreaksToSystemLineBreaks(CustomOptions),''); // do not touch / \ characters
|
LineBreaksToSystemLineBreaks(CustomOptions),''); // do not touch / \ characters
|
||||||
|
// All options
|
||||||
|
aXMLConfig.SetDeleteValue(p+'AllOptions/Count', AllOptions.Count, 0);
|
||||||
|
for i:=0 to AllOptions.Count-1 do
|
||||||
|
aXMLConfig.SetDeleteValue(p+'AllOptions/Item'+IntToStr(i)+'/', AllOptions[i], '');
|
||||||
|
|
||||||
{ Compilation }
|
{ Compilation }
|
||||||
aXMLConfig.SetDeleteValue(p+'CompilerPath/Value', f(CompilerPath),'');
|
aXMLConfig.SetDeleteValue(p+'CompilerPath/Value', f(CompilerPath),'');
|
||||||
@ -1779,7 +1840,6 @@ begin
|
|||||||
ExecuteAfter.SaveToXMLConfig(aXMLConfig,p+'ExecuteAfter/',UsePathDelim);
|
ExecuteAfter.SaveToXMLConfig(aXMLConfig,p+'ExecuteAfter/',UsePathDelim);
|
||||||
aXMLConfig.SetDeleteValue(p+'CreateMakefileOnBuild/Value',
|
aXMLConfig.SetDeleteValue(p+'CreateMakefileOnBuild/Value',
|
||||||
CreateMakefileOnBuild,false);
|
CreateMakefileOnBuild,false);
|
||||||
|
|
||||||
// write
|
// write
|
||||||
Modified := False;
|
Modified := False;
|
||||||
end;
|
end;
|
||||||
@ -3724,8 +3784,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAdditionalCompilerOptions.
|
function TAdditionalCompilerOptions.GetBaseCompilerOptions: TBaseCompilerOptions;
|
||||||
GetBaseCompilerOptions: TBaseCompilerOptions;
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
@ -835,14 +835,6 @@ begin
|
|||||||
FIsPackage := CompOptions is TPkgCompilerOptions;
|
FIsPackage := CompOptions is TPkgCompilerOptions;
|
||||||
//debugln(['TCompilerOtherOptionsFrame.ReadSettings ',dbgs(Pointer(FCompOptions)),' ',FCompOptions=Project1.CompilerOptions]);
|
//debugln(['TCompilerOtherOptionsFrame.ReadSettings ',dbgs(Pointer(FCompOptions)),' ',FCompOptions=Project1.CompilerOptions]);
|
||||||
|
|
||||||
edCustomOptions.Text := CompOptions.CustomOptions;
|
|
||||||
|
|
||||||
Vars := GetBuildMacroValues(CompOptions,false);
|
|
||||||
if Vars<>nil then
|
|
||||||
DefaultVariables.Assign(Vars)
|
|
||||||
else
|
|
||||||
DefaultVariables.Clear;
|
|
||||||
|
|
||||||
CondSynEdit.Lines.Text := CompOptions.Conditionals;
|
CondSynEdit.Lines.Text := CompOptions.Conditionals;
|
||||||
if FHighlighter=nil then
|
if FHighlighter=nil then
|
||||||
begin
|
begin
|
||||||
@ -851,6 +843,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
|
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
|
||||||
EditorOpts.GetSynEditSettings(CondSynEdit);
|
EditorOpts.GetSynEditSettings(CondSynEdit);
|
||||||
|
|
||||||
|
Vars := GetBuildMacroValues(CompOptions,false);
|
||||||
|
if Vars<>nil then
|
||||||
|
DefaultVariables.Assign(Vars)
|
||||||
|
else
|
||||||
|
DefaultVariables.Clear;
|
||||||
|
|
||||||
|
// Custom Options
|
||||||
|
edCustomOptions.Text := CompOptions.CustomOptions;
|
||||||
|
// All Options
|
||||||
|
FOptionsReader.CopyNonDefaultOptions(CompOptions.AllOptions);
|
||||||
|
|
||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -862,8 +866,8 @@ begin
|
|||||||
CurOptions := AOptions as TBaseCompilerOptions;
|
CurOptions := AOptions as TBaseCompilerOptions;
|
||||||
with CurOptions do
|
with CurOptions do
|
||||||
begin
|
begin
|
||||||
CustomOptions := edCustomOptions.Text;
|
|
||||||
Conditionals := CondSynEdit.Lines.Text;
|
Conditionals := CondSynEdit.Lines.Text;
|
||||||
|
CustomOptions := edCustomOptions.Text;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user