IDE: generate comments in all compiler options GUI.

git-svn-id: trunk@42400 -
This commit is contained in:
juha 2013-08-14 22:38:12 +00:00
parent d5fea9e70b
commit 4be93112dd
5 changed files with 40 additions and 12 deletions

View File

@ -254,6 +254,7 @@ type
fDontUseConfigFile: Boolean;
fCustomConfigFile: Boolean;
fConfigFilePath: String;
fUseCommentsInCustomOptions: Boolean;
protected
function GetCustomOptions: string; virtual; abstract;
function GetDebugPath: string; virtual; abstract;
@ -419,6 +420,7 @@ type
property CustomConfigFile: Boolean read fCustomConfigFile write SetCustomConfigFile;
property ConfigFilePath: String read fConfigFilePath write SetConfigFilePath;
property CustomOptions: string read GetCustomOptions write SetCustomOptions;
property UseCommentsInCustomOptions: Boolean read fUseCommentsInCustomOptions write fUseCommentsInCustomOptions;
// execute other
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract; // disable normal compile and call this instead

View File

@ -96,7 +96,6 @@ object frmAllCompilerOptions: TfrmAllCompilerOptions
Width = 233
BorderSpacing.Left = 29
Caption = 'Use comments in custom options'
Enabled = False
TabOrder = 4
end
end

View File

@ -1055,6 +1055,9 @@ begin
Result := fRootOptGroup.FindOptionById(aId);
end;
const
CommentId = '-dLazIdeComment_';
function TCompilerOptReader.FromCustomOptions(aStrings: TStrings): TModalResult;
var
i, j: Integer;
@ -1070,11 +1073,15 @@ begin
begin
s := Trim(aStrings[i]);
if s = '' then Continue;
sl.Clear;
SplitCmdLineParams(s, sl);
for j := 0 to sl.Count-1 do
if AnsiStartsStr('-d', sl[j]) then
fDefines.Add(sl[j])
begin
if not AnsiStartsStr(CommentId, sl[j]) then
fDefines.Add(sl[j])
end
else
fRootOptGroup.SelectOption(sl[j]);
end;
@ -1088,9 +1095,23 @@ function TCompilerOptReader.ToCustomOptions(aStrings: TStrings;
// Copy options to a list if they have a non-default value (True for boolean).
function PossibleComment(aRoot: TCompilerOpt): string;
var
i: Integer;
ch: Char;
begin
if aUseComments then
Result := ' // ' + aRoot.Description
begin
// ToDo: Show "//" comment and change to a define when storing.
// Result := ' // ' + aRoot.Description
Result := ' ' + CommentId;
for i := 1 to Length(aRoot.Description) do
begin
ch := aRoot.Description[i];
if ch in [' '] then
ch := '_'; // Change illegal characters to '_'
Result := Result + ch;
end;
end
else
Result := '';
end;

View File

@ -1616,6 +1616,7 @@ begin
CustomConfigFile := aXMLConfig.GetValue(p+'ConfigFile/CustomConfigFile/Value', false);
ConfigFilePath := f(aXMLConfig.GetValue(p+'ConfigFile/ConfigFilePath/Value', 'extrafpc.cfg'));
CustomOptions := LineBreaksToSystemLineBreaks(aXMLConfig.GetValue(p+'CustomOptions/Value', ''));
UseCommentsInCustomOptions := aXMLConfig.GetValue(p+'ConfigFile/UseCommentsInCustomOptions/Value', false);
{ Compilation }
CompilerPath := f(aXMLConfig.GetValue(p+'CompilerPath/Value','$(CompPath)'));
@ -1814,6 +1815,7 @@ begin
aXMLConfig.SetDeleteValue(p+'ConfigFile/ConfigFilePath/Value', f(ConfigFilePath),'extrafpc.cfg');
aXMLConfig.SetDeleteValue(p+'CustomOptions/Value',
LineBreaksToSystemLineBreaks(CustomOptions),''); // do not touch / \ characters
aXMLConfig.SetDeleteValue(p+'ConfigFile/UseCommentsInCustomOptions/Value', UseCommentsInCustomOptions,false);
{ Compilation }
aXMLConfig.SetDeleteValue(p+'CompilerPath/Value', f(CompilerPath),'');

View File

@ -72,6 +72,7 @@ type
fEngine: TIDECfgScriptEngine;
fSynCompletion: TSynCompletion;
FOptionsReader: TCompilerOptReader;
FUseComments: boolean;
procedure SetIdleConnected(AValue: TIdleActions);
procedure SetStatusMessage(const AValue: string);
procedure StartCompletion;
@ -107,7 +108,6 @@ type
property CompletionValues: TStrings read FCompletionValues;
property CompletionHistory: TStrings read FCompletionHistory;
property IdleConnected: TIdleActions read FIdleConnected write SetIdleConnected;
property CompOptions: TBaseCompilerOptions read FCompOptions;
property OptionsReader: TCompilerOptReader read FOptionsReader;
end;
@ -125,10 +125,12 @@ begin
FOptionsReader.FromCustomOptions(memoCustomOptions.Lines);
AllOpts := TfrmAllCompilerOptions.Create(Nil);
try
AllOpts.OptionsReader:=FOptionsReader;
AllOpts.OptionsReader := FOptionsReader;
AllOpts.cbUseComments.Checked := FUseComments;
if AllOpts.ShowModal = mrOK then
begin
// Synchronize with custom options memo
FUseComments := AllOpts.cbUseComments.Checked;
AllOpts.ToCustomOptions(memoCustomOptions.Lines);
memoCustomOptions.Invalidate;
end;
@ -531,10 +533,10 @@ begin
AddWord(ParsedCompilerOptsUsageVars[pcouv]);
// add build macros and values
if CompOptions.BuildMacros<>nil then begin
for i:=0 to CompOptions.BuildMacros.Count-1 do
if FCompOptions.BuildMacros<>nil then begin
for i:=0 to FCompOptions.BuildMacros.Count-1 do
begin
Macro:=CompOptions.BuildMacros[i];
Macro:=FCompOptions.BuildMacros[i];
AddWord(Macro.Identifier);
for j:=0 to Macro.Values.Count-1 do
AddWord(Macro.Values[j]);
@ -709,10 +711,10 @@ var
Vars: TCTCfgScriptVariables;
begin
FCompOptions := AOptions as TBaseCompilerOptions;
FIsPackage := CompOptions is TPkgCompilerOptions;
FIsPackage := FCompOptions is TPkgCompilerOptions;
//debugln(['TCompilerOtherOptionsFrame.ReadSettings ',dbgs(Pointer(FCompOptions)),' ',FCompOptions=Project1.CompilerOptions]);
CondSynEdit.Lines.Text := CompOptions.Conditionals;
CondSynEdit.Lines.Text := FCompOptions.Conditionals;
if FHighlighter=nil then
begin
FHighlighter := TPreviewPasSyn.Create(Self);
@ -721,14 +723,15 @@ begin
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
EditorOpts.GetSynEditSettings(CondSynEdit);
Vars := GetBuildMacroValues(CompOptions,false);
Vars := GetBuildMacroValues(FCompOptions,false);
if Vars<>nil then
DefaultVariables.Assign(Vars)
else
DefaultVariables.Clear;
// Custom Options
memoCustomOptions.Text := CompOptions.CustomOptions;
memoCustomOptions.Text := FCompOptions.CustomOptions;
FUseComments := FCompOptions.UseCommentsInCustomOptions;
UpdateStatusBar;
end;
@ -743,6 +746,7 @@ begin
begin
Conditionals := CondSynEdit.Lines.Text;
CustomOptions := memoCustomOptions.Text;
UseCommentsInCustomOptions := FUseComments;
end;
end;