IDE: Refactor, move code from TProjectBuildModes to TBuildMatrixOptions.

git-svn-id: trunk@45413 -
This commit is contained in:
juha 2014-06-08 23:46:49 +00:00
parent 0f98855e32
commit c9836f4278
2 changed files with 22 additions and 23 deletions

View File

@ -147,6 +147,7 @@ type
procedure AppendCustomOptions(Target, ActiveMode: string; var Options: string);
procedure GetOutputDirectory(Target, ActiveMode: string; var OutDir: string);
function FindOption(const ID: string): TBuildMatrixOption;
function FindMacro(const MacroName, MacroValue: string): TBuildMatrixOption;
end;
EMMMacroSyntaxException = class(Exception)
@ -625,6 +626,25 @@ begin
Result:=nil;
end;
function TBuildMatrixOptions.FindMacro(const MacroName, MacroValue: string): TBuildMatrixOption;
var
i: Integer;
begin
i:=Count-1;
while i>=0 do
begin
Result:=Items[i];
if (Result.Typ=bmotIDEMacro)
and (Result.Targets='*')
and (Result.MacroName=MacroName)
and (Result.Value=MacroValue)
then
exit;
dec(i);
end;
Result:=nil;
end;
{ TBuildMatrixOption }
procedure TBuildMatrixOption.SetMacroName(AValue: string);

View File

@ -6977,34 +6977,13 @@ end;
procedure TProjectBuildModes.AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string;
InSession: boolean);
function FindMacro(MatrixOptions: TBuildMatrixOptions;
const MacroName, MacroValue: string): TBuildMatrixOption;
var
j: Integer;
begin
j:=MatrixOptions.Count-1;
while j>=0 do
begin
Result:=MatrixOptions[j];
if (Result.Typ=bmotIDEMacro)
and (Result.Targets='*')
and (Result.MacroName=MacroName)
and (Result.Value=MacroValue)
then
exit;
dec(j);
end;
Result:=nil;
end;
var
MatrixOptions: TBuildMatrixOptions;
MatrixOption: TBuildMatrixOption;
begin
MatrixOption:=FindMacro(SharedMatrixOptions,MacroName,MacroValue);
MatrixOption:=SharedMatrixOptions.FindMacro(MacroName,MacroValue);
if MatrixOption=nil then
MatrixOption:=FindMacro(SessionMatrixOptions,MacroName,MacroValue);
MatrixOption:=SessionMatrixOptions.FindMacro(MacroName,MacroValue);
if MatrixOption<>nil then begin
// Macro already exists => enable mode for this macro
MatrixOption.EnableMode(ModeIdentifier);