IDE: Fix error in all compiler options parser.

git-svn-id: trunk@47182 -
This commit is contained in:
juha 2014-12-12 16:37:27 +00:00
parent 42c4bdafbf
commit 9454def0c9
2 changed files with 34 additions and 21 deletions

View File

@ -809,8 +809,7 @@ procedure TBuildManager.RescanCompilerDefines(ResetBuildTarget,
if ConsoleVerbosity>=0 then if ConsoleVerbosity>=0 then
debugln(['PPUFilesAndCompilerMatch Compiler=',Cfg.Compiler,' RealComp=',Cfg.RealCompiler,' InPath=',Cfg.RealCompilerInPath]); debugln(['PPUFilesAndCompilerMatch Compiler=',Cfg.Compiler,' RealComp=',Cfg.RealCompiler,' InPath=',Cfg.RealCompilerInPath]);
IDEMessageDialog(lisCCOErrorCaption, Format( IDEMessageDialog(lisCCOErrorCaption, Format(
lisCompilerDoesNotSupportTarget, [Cfg.Compiler, Cfg.TargetCPU, lisCompilerDoesNotSupportTarget, [Cfg.Compiler, Cfg.TargetCPU, Cfg.TargetOS]),
Cfg.TargetOS]),
mtError,[mbOk]); mtError,[mbOk]);
exit(false); exit(false);
end; end;

View File

@ -182,7 +182,7 @@ type
fIsNewFpc: Boolean; fIsNewFpc: Boolean;
fParsedTarget: String; fParsedTarget: String;
fErrorMsg: String; fErrorMsg: String;
fGenStrings: TStringList; // Options generated from GUI. fGeneratedOptions: TStringList; // Options generated from GUI.
fUseComments: Boolean; // Add option's description into generated data. fUseComments: Boolean; // Add option's description into generated data.
function AddChoicesNew(aOpt: string): TStrings; function AddChoicesNew(aOpt: string): TStrings;
function AddNewCategory(aCategoryName: String): TStringList; function AddNewCategory(aCategoryName: String): TStringList;
@ -597,9 +597,15 @@ function TCompilerOptGroup.FindOption(aOptStr: string): TCompilerOpt;
end end
else begin // TCompilerOpt else begin // TCompilerOpt
if aRoot.Option = aOptStr then if aRoot.Option = aOptStr then
Result := aRoot
else if (aRoot.EditKind = oeText) and AnsiStartsStr(aRoot.Option, aOptStr) then
begin
aRoot.SetValue(Copy(aOptStr, Length(aRoot.Option)+1, Length(aOptStr)),
fOwnerReader.fCurOrigLine);
Result := aRoot; Result := aRoot;
end; end;
end; end;
end;
begin begin
Result := FindOptionSub(Self); Result := FindOptionSub(Self);
@ -652,7 +658,7 @@ begin
else else
Break; Break;
end; end;
// Set boolean options if they all are valid. // Set boolean options but only if they all are valid.
if Assigned(Result) then if Assigned(Result) then
for i := 0 to List.Count-1 do for i := 0 to List.Count-1 do
TCompilerOpt(List[i]).SetValue('True', fOwnerReader.fCurOrigLine); TCompilerOpt(List[i]).SetValue('True', fOwnerReader.fCurOrigLine);
@ -669,7 +675,11 @@ var
begin begin
Opt := FindOption(aOptAndValue); Opt := FindOption(aOptAndValue);
if Assigned(Opt) then if Assigned(Opt) then
Opt.SetValue('True', fOwnerReader.fCurOrigLine) begin
// Found. Set boolean option, other type of options are already set.
if Opt.EditKind = oeBoolean then
Opt.SetValue('True', fOwnerReader.fCurOrigLine);
end
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.
@ -690,12 +700,16 @@ begin
if OptLen = 3 then // Can contain one char options like -Criot. Can be combined. if OptLen = 3 then // Can contain one char options like -Criot. Can be combined.
Opt := OneCharOptions(aOptAndValue); Opt := OneCharOptions(aOptAndValue);
end; end;
if Opt = Nil then begin if Opt = Nil then
begin
Opt := FindOption(Copy(aOptAndValue, 1, OptLen)); Opt := FindOption(Copy(aOptAndValue, 1, OptLen));
if Assigned(Opt) then if Assigned(Opt) then
begin
Assert(Opt.Value='', 'TCompilerOptGroup.SelectOption: Opt.Value is already set.');
Opt.SetValue(Param, fOwnerReader.fCurOrigLine) Opt.SetValue(Param, fOwnerReader.fCurOrigLine)
end; end;
end; end;
end;
Result := Assigned(Opt); Result := Assigned(Opt);
end; end;
@ -905,7 +919,7 @@ begin
fDefines := TStringList.Create; fDefines := TStringList.Create;
fInvalidOptions := TStringList.Create; fInvalidOptions := TStringList.Create;
fSupportedCategories := TStringList.Create; fSupportedCategories := TStringList.Create;
fGenStrings := TStringList.Create; fGeneratedOptions := TStringList.Create;
fRootOptGroup := TCompilerOptGroup.Create(Self, Nil); fRootOptGroup := TCompilerOptGroup.Create(Self, Nil);
end; end;
@ -913,7 +927,7 @@ destructor TCompilerOptReader.Destroy;
begin begin
Clear; Clear;
fRootOptGroup.Free; fRootOptGroup.Free;
fGenStrings.Free; fGeneratedOptions.Free;
fSupportedCategories.Free; fSupportedCategories.Free;
fInvalidOptions.Free; fInvalidOptions.Free;
fDefines.Free; fDefines.Free;
@ -1275,7 +1289,7 @@ begin
end; end;
procedure TCompilerOptReader.CopyOptions(aRoot: TCompilerOpt); procedure TCompilerOptReader.CopyOptions(aRoot: TCompilerOpt);
// Collect non-default options to fGenStrings // Collect non-default options from GUI to fGeneratedOptions
var var
Children: TCompilerOptList; Children: TCompilerOptList;
i: Integer; i: Integer;
@ -1288,7 +1302,7 @@ begin
begin // TCompilerOptSet begin // TCompilerOptSet
s := TCompilerOptSet(aRoot).CollectSelectedOptions(fUseComments); s := TCompilerOptSet(aRoot).CollectSelectedOptions(fUseComments);
if s <> '' then if s <> '' then
fGenStrings.AddObject(s, TObject({%H-}Pointer(PtrUInt(aRoot.fOrigLine)))); fGeneratedOptions.AddObject(s, TObject({%H-}Pointer(PtrUInt(aRoot.fOrigLine))));
end end
else begin // TCompilerOptGroup else begin // TCompilerOptGroup
for i := 0 to Children.Count-1 do for i := 0 to Children.Count-1 do
@ -1296,7 +1310,7 @@ begin
end; end;
end end
else if aRoot.Value <> '' then // TCompilerOpt else if aRoot.Value <> '' then // TCompilerOpt
fGenStrings.AddObject(aRoot.GenerateOptValue(fUseComments), fGeneratedOptions.AddObject(aRoot.GenerateOptValue(fUseComments),
TObject({%H-}Pointer(PtrUINt(aRoot.fOrigLine)))); TObject({%H-}Pointer(PtrUINt(aRoot.fOrigLine))));
end; end;
@ -1330,7 +1344,7 @@ var
iGenOrig, iInvOrig: Integer; iGenOrig, iInvOrig: Integer;
begin begin
// Find lowest lines from both generated and invalid options // Find lowest lines from both generated and invalid options
iGen := FindLowestOrigLine(fGenStrings, iGenOrig); iGen := FindLowestOrigLine(fGeneratedOptions, iGenOrig);
iInv := FindLowestOrigLine(fInvalidOptions, iInvOrig); iInv := FindLowestOrigLine(fInvalidOptions, iInvOrig);
// then add the one that is lower. // then add the one that is lower.
if (iGenOrig = -1) and (iInvOrig = -1) then Exit(False); if (iGenOrig = -1) and (iInvOrig = -1) then Exit(False);
@ -1338,9 +1352,9 @@ begin
if ( (iGenOrig > -1) and (iInvOrig > -1) and (iGenOrig <= iInvOrig) ) if ( (iGenOrig > -1) and (iInvOrig > -1) and (iGenOrig <= iInvOrig) )
or ( (iGenOrig > -1) and (iInvOrig = -1) ) then or ( (iGenOrig > -1) and (iInvOrig = -1) ) then
begin begin
OutStrings.Add(fGenStrings[iGen]); OutStrings.Add(fGeneratedOptions[iGen]);
fGenStrings[iGen] := ''; fGeneratedOptions[iGen] := '';
fGenStrings.Objects[iGen] := TObject(Pointer(-1)); // Mark as processed. fGeneratedOptions.Objects[iGen] := TObject(Pointer(-1)); // Mark as processed.
end end
else begin else begin
OutStrings.Add(fInvalidOptions[iInv]); OutStrings.Add(fInvalidOptions[iInv]);
@ -1357,16 +1371,16 @@ var
begin begin
Result := mrOK; Result := mrOK;
fUseComments := aUseComments; fUseComments := aUseComments;
fGenStrings.Clear; fGeneratedOptions.Clear;
CopyOptions(fRootOptGroup); CopyOptions(fRootOptGroup);
// Options are now in fGenStrings. Move them to aStrings in a right order. // Options are now in fGeneratedOptions. Move them to aStrings in a right order.
aStrings.Clear; aStrings.Clear;
// First collect options that were in the original list. // First collect options that were in the original list.
while AddOptInLowestOrigLine(aStrings) do ; while AddOptInLowestOrigLine(aStrings) do ;
// Then add all the rest. // Then add all the rest.
for i := 0 to fGenStrings.Count-1 do for i := 0 to fGeneratedOptions.Count-1 do
if fGenStrings[i] <> '' then if fGeneratedOptions[i] <> '' then
aStrings.Add(fGenStrings[i]); aStrings.Add(fGeneratedOptions[i]);
// Then defines // Then defines
aStrings.AddStrings(fDefines); aStrings.AddStrings(fDefines);
end; end;