Add new TUnsortedCompilerOptionsStringList class

which sets Duplicates to dupAccept explicitly in constructor.
 Use new TUnsortedCompilerOptionsStringList class to instanciate
 all TStrings containing list of complier options.
This commit is contained in:
Pierre Muller 2023-10-26 09:40:31 +00:00
parent 1e64126fba
commit 76becd36b7

View File

@ -1850,6 +1850,11 @@ type
function Add(const S: string): Integer; override;
end;
TUnsortedCompilerOptionsStringList = class(TStringList)
public
constructor Create;
end;
var
CustomFpmakeCommandlineOptions: TStrings;
CustomFpMakeCommandlineValues: TStrings;
@ -2933,7 +2938,7 @@ end;
procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, HelpMessage : string);
begin
if not assigned(CustomFpmakeCommandlineOptions) then
CustomFpmakeCommandlineOptions := TStringList.Create;
CustomFpmakeCommandlineOptions := TUnsortedCompilerOptionsStringList.Create;
CustomFpmakeCommandlineOptions.Values[ACommandLineOption]:=HelpMessage;
end;
@ -3007,7 +3012,7 @@ begin
Result:=Nil;
If (S='') then
Exit;
Result:=TStringList.Create;
Result:=TUnsortedCompilerOptionsStringList.Create;
Repeat
P:=Pos(' ',S);
If P=0 then
@ -3597,7 +3602,7 @@ constructor TPackageVariant.Create(ACollection: TCollection);
begin
inherited Create(ACollection);
FTargets := TTargets.Create(TTarget);
FOptions := TStringList.Create;
FOptions := TUnsortedCompilerOptionsStringList.Create;
FIncludePath:=TConditionalStrings.Create(TConditionalString);
FSourcePath:=TConditionalStrings.Create(TConditionalString);
end;
@ -3613,9 +3618,7 @@ end;
procedure TPackageVariant.AddOption(const aValue: string);
begin
// Cannot use duplicates, requires ordering
if Options.Indexof(aValue)=-1 then
Options.Add(aValue);
Options.Add(aValue);
end;
{ TPackageVariants }
@ -3806,6 +3809,16 @@ begin
inherited Add(S);
end;
{****************************************************************************
TUnsortedCompilerOptionsStringList
****************************************************************************}
constructor TUnsortedCompilerOptionsStringList.Create;
begin
Inherited Create;
Duplicates:=DupAccept;
end;
{****************************************************************************
TNamedItem
****************************************************************************}
@ -4625,14 +4638,14 @@ end;
function TPackage.GetOptions: TStrings;
begin
If (FOptions=Nil) then
FOptions:=TStringList.Create;
FOptions:=TUnsortedCompilerOptionsStringList.Create;
Result:=FOptions;
end;
function TPackage.GetTransmitOptions: TStrings;
begin
If (FTransmitOptions=Nil) then
FTransmitOptions:=TStringList.Create;
FTransmitOptions:=TUnsortedCompilerOptionsStringList.Create;
Result:=FTransmitOptions;
end;
@ -4872,8 +4885,7 @@ begin
begin
PackageVariants := TPackageVariants(FPackageVariants.Items[i]);
for S in PackageVariants.ActivePackageVariant.Options do
if ACompilerOptions.IndexOf(S)=-1 then
ACompilerOptions.Add(S);
ACompilerOptions.Add(S);
end;
end;
@ -5391,7 +5403,7 @@ end;
function TCustomDefaults.GetOptions: TStrings;
begin
If (FOptions=Nil) then
FOptions:=TStringList.Create;
FOptions:=TUnsortedCompilerOptionsStringList.Create;
Result:=FOptions;
end;
@ -5663,9 +5675,7 @@ end;
procedure TCustomDefaults.AddOption(const aValue: string);
begin
// Cannot use duplicates, requires ordering
if Options.Indexof(aValue)=-1 then
Options.Add(aValue);
Options.Add(aValue);
end;
function TCustomDefaults.IsBuildDifferentFromTarget: boolean;
@ -6365,7 +6375,7 @@ begin
else if assigned(CustomFpmakeCommandlineOptions) and CheckCustomOption(I,CustOptName) then
begin
if not assigned(CustomFpMakeCommandlineValues) then
CustomFpMakeCommandlineValues := TStringList.Create;
CustomFpMakeCommandlineValues := TUnsortedCompilerOptionsStringList.Create;
CustomFpMakeCommandlineValues.Values[CustOptName]:=OptionArg(I, true)
end
else if (not CheckBuildOptionSetValue(I)) and (not CheckPackageVariantOptionSetValue(I))
@ -10098,7 +10108,7 @@ end;
function TTarget.GetOptions: TStrings;
begin
If Foptions=Nil then
FOptions:=TStringList.Create;
FOptions:=TUnsortedCompilerOptionsStringList.Create;
Result:=FOptions;
end;
@ -10457,9 +10467,7 @@ end;
procedure TTarget.AddOption(const aValue: String);
begin
// Cannot use duplicates, requires ordering
if Options.IndexOf(aValue)=-1 then
Options.Add(aValue);
Options.Add(aValue);
end;
@ -11113,7 +11121,7 @@ end;
function TCommand.GetOptions: TStrings;
begin
If (FOptions=Nil) then
FOptions:=TStringList.Create;
FOptions:=TUnsortedCompilerOptionsStringList.Create;
Result:=FOptions;
end;