IDE: parse custom options on one line correctly for the all options GUI.

git-svn-id: trunk@42208 -
This commit is contained in:
juha 2013-07-26 09:13:55 +00:00
parent 283c25bf98
commit a30a85470b
4 changed files with 53 additions and 25 deletions

View File

@ -40,6 +40,7 @@ type
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
function ToCustomOptions(aStrings: TStrings): TModalResult;
public public
property CustomOptions: TStrings read FCustomOptions write FCustomOptions; property CustomOptions: TStrings read FCustomOptions write FCustomOptions;
property OptionsReader: TCompilerOptReader read FOptionsReader; property OptionsReader: TCompilerOptReader read FOptionsReader;
@ -69,6 +70,11 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TfrmAllCompilerOptions.ToCustomOptions(aStrings: TStrings): TModalResult;
begin
Result := OptionsReader.ToCustomOptions(aStrings, cbUseComments.Checked);
end;
procedure TfrmAllCompilerOptions.FormShow(Sender: TObject); procedure TfrmAllCompilerOptions.FormShow(Sender: TObject);
begin begin
Caption:=lisAllOptions; Caption:=lisAllOptions;
@ -96,8 +102,8 @@ end;
procedure TfrmAllCompilerOptions.SetIdleConnected(AValue: Boolean); procedure TfrmAllCompilerOptions.SetIdleConnected(AValue: Boolean);
begin begin
if FIdleConnected=AValue then exit; if FIdleConnected = AValue then exit;
FIdleConnected:=AValue; FIdleConnected := AValue;
if FIdleConnected then if FIdleConnected then
Application.AddOnIdleHandler(@OnIdle) Application.AddOnIdleHandler(@OnIdle)
else else
@ -107,7 +113,7 @@ end;
procedure TfrmAllCompilerOptions.OnIdle(Sender: TObject; var Done: Boolean); procedure TfrmAllCompilerOptions.OnIdle(Sender: TObject; var Done: Boolean);
begin begin
IdleConnected := False; IdleConnected := False;
Screen.Cursor:=crHourGlass; Screen.Cursor := crHourGlass;
try try
edOptionsFilter.Enabled := False; edOptionsFilter.Enabled := False;
FOptionsReader.CompilerExecutable := EnvironmentOptions.CompilerFilename; FOptionsReader.CompilerExecutable := EnvironmentOptions.CompilerFilename;
@ -117,7 +123,7 @@ begin
RenderAndFilterOptions; RenderAndFilterOptions;
edOptionsFilter.Enabled := True; edOptionsFilter.Enabled := True;
finally finally
Screen.Cursor:=crDefault; Screen.Cursor := crDefault;
end; end;
end; end;

View File

@ -114,7 +114,7 @@ type
TCompilerOpt = class TCompilerOpt = class
private private
fId: integer; // Identification. fId: integer; // Identification.
fOption: string; // Option without the leading '-'. fOption: string; // Option with the leading '-'.
fSuffix: string; // <x> or similar suffix of option. fSuffix: string; // <x> or similar suffix of option.
fValue: string; // Data entered by user, 'True' for Boolean. fValue: string; // Data entered by user, 'True' for Boolean.
fEditKind: TCompilerOptEditKind; fEditKind: TCompilerOptEditKind;
@ -199,7 +199,7 @@ type
function FilterOptions(aFilter: string): Boolean; function FilterOptions(aFilter: string): Boolean;
function FindOptionById(aId: integer): TCompilerOpt; function FindOptionById(aId: integer): TCompilerOpt;
function FromCustomOptions(aStrings: TStrings): TModalResult; function FromCustomOptions(aStrings: TStrings): TModalResult;
function ToCustomOptions(aStrings: TStrings): TModalResult; function ToCustomOptions(aStrings: TStrings; aUseComments: Boolean): TModalResult;
public public
property SupportedCategories: TStringList read fSupportedCategories; property SupportedCategories: TStringList read fSupportedCategories;
property RootOptGroup: TCompilerOptGroup read fRootOptGroup; property RootOptGroup: TCompilerOptGroup read fRootOptGroup;
@ -405,7 +405,10 @@ end;
function IgnoredOption(aOpt: string): Boolean; function IgnoredOption(aOpt: string): Boolean;
begin begin
Result := aOpt = '-F'; // Ignore all file names and paths if Length(aOpt) < 2 then Exit;
// Ignore : all file names and paths
// executable path
Result := aOpt[2] in ['F', 'e'];
end; end;
{ TCompilerOpt } { TCompilerOpt }
@ -550,8 +553,9 @@ begin
else begin else begin
// Option was not found, try separating the parameter. // Option was not found, try separating the parameter.
// ToDo: figure out the length in a more clever way. // ToDo: figure out the length in a more clever way.
if AnsiStartsStr('-d', aOptAndValue) Assert((Length(aOptAndValue)>2) and (aOptAndValue[1]='-'),
or AnsiStartsStr('-u', aOptAndValue) then 'TCompilerOptGroup.SelectOption: Invalid option & value');
if aOptAndValue[2] in ['e', 'd', 'u', 'I', 'k', 'o'] then
OptLen := 2 OptLen := 2
else else
OptLen := 3; OptLen := 3;
@ -940,24 +944,43 @@ end;
function TCompilerOptReader.FromCustomOptions(aStrings: TStrings): TModalResult; function TCompilerOptReader.FromCustomOptions(aStrings: TStrings): TModalResult;
var var
i, CommentPos: Integer; i, j, CommentPos: Integer;
s: String; s: String;
sl: TStringList;
begin begin
Result := mrOK; Result := mrOK;
for i := 0 to aStrings.Count-1 do sl := TStringList.Create;
begin try
s := Trim(aStrings[i]); for i := 0 to aStrings.Count-1 do
if s = '' then Continue; begin
CommentPos := Pos('//', s); s := Trim(aStrings[i]);
if CommentPos > 0 then // Remove the possible comment. if s = '' then Continue;
s := TrimRight(Copy(s, 1, CommentPos)); CommentPos := Pos('//', s);
fRootOptGroup.SelectOption(s); if CommentPos > 0 then // Remove possible comment.
s := TrimRight(Copy(s, 1, CommentPos));
sl.StrictDelimiter := True;
sl.Delimiter := ' ';
sl.DelimitedText := s; // Split the line with space as a separator.
for j := 0 to sl.Count-1 do
fRootOptGroup.SelectOption(sl[j]);
end;
finally
sl.Free;
end; end;
end; end;
function TCompilerOptReader.ToCustomOptions(aStrings: TStrings): TModalResult; function TCompilerOptReader.ToCustomOptions(aStrings: TStrings;
aUseComments: Boolean): TModalResult;
// Copy options to a list if they have a non-default value (True for boolean). // Copy options to a list if they have a non-default value (True for boolean).
function PossibleComment(aRoot: TCompilerOpt): string;
begin
if aUseComments then
Result := ' // ' + aRoot.Description
else
Result := '';
end;
function CopyOptions(aRoot: TCompilerOpt): integer; function CopyOptions(aRoot: TCompilerOpt): integer;
var var
Children: TCompilerOptList; Children: TCompilerOptList;
@ -971,7 +994,7 @@ function TCompilerOptReader.ToCustomOptions(aStrings: TStrings): TModalResult;
begin // TCompilerOptSet begin // TCompilerOptSet
s := TCompilerOptSet(aRoot).CollectSelectedOptions; s := TCompilerOptSet(aRoot).CollectSelectedOptions;
if s <> '' then if s <> '' then
aStrings.Add(s); aStrings.Add(s + PossibleComment(aRoot));
end end
else begin // TCompilerOptGroup else begin // TCompilerOptGroup
for i := 0 to Children.Count-1 do // Recursive call for children. for i := 0 to Children.Count-1 do // Recursive call for children.
@ -982,9 +1005,9 @@ function TCompilerOptReader.ToCustomOptions(aStrings: TStrings): TModalResult;
if aRoot.Value <> '' then if aRoot.Value <> '' then
begin begin
if aRoot.Value = 'True' then if aRoot.Value = 'True' then
aStrings.Add(aRoot.Option) aStrings.Add(aRoot.Option + PossibleComment(aRoot))
else else
aStrings.Add(aRoot.Option + aRoot.Value); aStrings.Add(aRoot.Option + aRoot.Value + PossibleComment(aRoot));
end; end;
end; end;
Result := Res; Result := Res;

View File

@ -117,7 +117,7 @@ begin
AllOpts.CustomOptions := memoCustomOptions.Lines; AllOpts.CustomOptions := memoCustomOptions.Lines;
if AllOpts.ShowModal = mrOK then if AllOpts.ShowModal = mrOK then
begin begin
AllOpts.OptionsReader.ToCustomOptions(memoCustomOptions.Lines); AllOpts.ToCustomOptions(memoCustomOptions.Lines);
memoCustomOptions.Invalidate; memoCustomOptions.Invalidate;
end; end;
finally finally

View File

@ -6089,8 +6089,7 @@ procedure TProjectCompilerOptions.SaveToXMLConfig(AXMLConfig: TXMLConfig;
begin begin
inherited SaveToXMLConfig(AXMLConfig,Path); inherited SaveToXMLConfig(AXMLConfig,Path);
SaveXMLCompileReasons(AXMLConfig, Path+'CompileReasons/', FCompileReasons, SaveXMLCompileReasons(AXMLConfig, Path+'CompileReasons/', FCompileReasons, crAll);
crAll);
//debugln(['TProjectCompilerOptions.SaveToXMLConfig ',Path+'CompileReasons/ ',crCompile in FCompileReasons]); //debugln(['TProjectCompilerOptions.SaveToXMLConfig ',Path+'CompileReasons/ ',crCompile in FCompileReasons]);
end; end;