IDE: Move ModeMatrixOpts and IdeOptionDefs to new base-package "IdeConfig"

This commit is contained in:
Martin 2022-12-08 20:21:27 +01:00
parent 051506b5a1
commit 5f5b73b22e
7 changed files with 105 additions and 102 deletions

View File

@ -46,6 +46,7 @@ uses
LCLProc, Controls, Graphics, ComCtrls, Menus,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEImagesIntf, CompOptsIntf,
KeywordFuncLists,
// IDE
EnvironmentOpts, PackageSystem, PackageDefs, Project, LazarusIDEStrConsts,
TransferMacros, ModeMatrixOpts, ModeMatrixCtrl, compiler_config_target;
@ -170,6 +171,10 @@ function CaptionToBuildMatrixOptionType(s: string): TBuildMatrixOptionType;
function BuildMatrixOptionTypeHint(Typ: TBuildMatrixOptionType): string;
function BuildMatrixDefaultValue(Typ: TBuildMatrixOptionType): string;
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
function SplitMatrixMacro(MacroAssignment: string;
out MacroName, MacroValue: string; ExceptionOnError: boolean): boolean;
var
ModeMatrixFrame: TCompOptModeMatrixFrame = nil;
@ -1280,6 +1285,90 @@ begin
IncreaseCompilerParseStamp;
end;
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
var
p: PChar;
procedure WarnInvalidChar;
begin
Result:=Format(lisMMInvalidCharacterAt, [dbgstr(p^), IntToStr(p-PChar(
Targets)+1)]);
end;
begin
Result:='';
if Targets='' then exit;
p:=PChar(Targets);
repeat
case p^ of
#0:
if p-PChar(Targets)=length(Targets) then
break
else begin
WarnInvalidChar;
exit;
end;
#1..#32,#127:
begin
WarnInvalidChar;
exit;
end;
end;
inc(p);
until false;
end;
function SplitMatrixMacro(MacroAssignment: string; out MacroName,
MacroValue: string; ExceptionOnError: boolean): boolean;
procedure E(Msg: string);
begin
raise EMMMacroSyntaxException.Create(Msg);
end;
var
p: PChar;
StartP: PChar;
begin
Result:=false;
MacroName:='';
MacroValue:='';
if MacroAssignment='' then begin
if ExceptionOnError then
E(lisMMMissingMacroName);
exit;
end;
p:=PChar(MacroAssignment);
if not IsIdentStartChar[p^] then begin
if ExceptionOnError then
E(Format(lisMMExpectedMacroNameButFound, [dbgstr(p^)]));
exit;
end;
StartP:=p;
repeat
inc(p);
until not IsIdentChar[p^];
MacroName:=copy(MacroAssignment,1,p-StartP);
if (p^<>':') or (p[1]<>'=') then begin
if ExceptionOnError then
E(Format(lisMMExpectedAfterMacroNameButFound, [dbgstr(p^)]));
exit;
end;
inc(p,2);
StartP:=p;
repeat
if (p^=#0) and (p-PChar(MacroAssignment)=length(MacroAssignment)) then break;
if p^ in [#0..#31,#127] then begin
if ExceptionOnError then
E(Format(lisMMInvalidCharacterInMacroValue, [dbgstr(p^)]));
exit;
end;
inc(p);
until false;
MacroValue:=copy(MacroAssignment,StartP-PChar(MacroAssignment)+1,p-StartP);
Result:=true;
end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompOptModeMatrixFrame,
CompilerOptionsAdditionsAndOverrides);

View File

@ -653,10 +653,6 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="CleanPkgDeps"/>
</Unit>
<Unit>
<Filename Value="modematrixopts.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="frames/compiler_modematrix.pas"/>
<IsPartOfProject Value="True"/>
@ -1228,11 +1224,6 @@
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
</Unit>
<Unit>
<Filename Value="ideoptiondefs.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="IDEOptionDefs"/>
</Unit>
<Unit>
<Filename Value="sourceeditprocs.pas"/>
<IsPartOfProject Value="True"/>

View File

@ -55,12 +55,16 @@ begin
t.Dependencies.AddUnit('idexmlconfigprocs');
t.Dependencies.AddUnit('lazconf');
t.Dependencies.AddUnit('transfermacrosintf');
t.Dependencies.AddUnit('ideoptiondefs');
t.Dependencies.AddUnit('modematrixopts');
T:=P.Targets.AddUnit('searchpathprocs.pas');
T:=P.Targets.AddUnit('recentlistprocs.pas');
T:=P.Targets.AddUnit('idexmlconfigprocs.pas');
T:=P.Targets.AddUnit('lazconf.pp');
T:=P.Targets.AddUnit('transfermacrosintf.pas');
T:=P.Targets.AddUnit('ideoptiondefs.pas');
T:=P.Targets.AddUnit('modematrixopts.pas');
// copy the compiled file, so the IDE knows how the package was compiled
P.Sources.AddSrc('IdeConfig.compiled');

View File

@ -42,7 +42,15 @@ Files in this package are for the main configuration of the IDE."/>
</Item>
<Item>
<Filename Value="transfermacrosintf.pas"/>
<UnitName Value="transfermacrosintf"/>
<UnitName Value="TransferMacrosIntf"/>
</Item>
<Item>
<Filename Value="ideoptiondefs.pas"/>
<UnitName Value="IDEOptionDefs"/>
</Item>
<Item>
<Filename Value="modematrixopts.pas"/>
<UnitName Value="ModeMatrixOpts"/>
</Item>
</Files>
<RequiredPkgs>

View File

@ -9,7 +9,7 @@ interface
uses
SearchPathProcs, RecentListProcs, IdeXmlConfigProcs, LazConf,
TransferMacrosIntf, LazarusPackageIntf;
TransferMacrosIntf, IDEOptionDefs, ModeMatrixOpts, LazarusPackageIntf;
implementation

View File

@ -39,7 +39,7 @@ uses
LazFileUtils, LazConfigStorage, Laz2_XMLCfg, LazUTF8,
// IdeIntf
BaseIDEIntf, IDEExternToolIntf,
// IDE
// IdeConfig
LazConf;
type

View File

@ -30,9 +30,7 @@ uses
// LazUtils
LazConfigStorage, Laz2_XMLCfg, LazLoggerBase, LazStringUtils,
// Codetools
FileProcs, KeywordFuncLists, CodeToolsCfgScript,
// IDE
LazarusIDEStrConsts;
FileProcs, KeywordFuncLists, CodeToolsCfgScript;
const
BuildMatrixProjectName = '#project';
@ -165,13 +163,10 @@ type
function BuildMatrixTargetFits(Target, Targets: string): boolean;
function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean;
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType;
function CreateBuildMatrixOptionGUID: string;
function SplitMatrixMacro(MacroAssignment: string;
out MacroName, MacroValue: string; ExceptionOnError: boolean): boolean;
procedure ApplyBuildMatrixMacros(Options: TBuildMatrixOptions; Target, ActiveMode: string;
CfgVars: TCTCfgScriptVariables);
@ -273,39 +268,6 @@ begin
until false;
end;
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
var
p: PChar;
procedure WarnInvalidChar;
begin
Result:=Format(lisMMInvalidCharacterAt, [dbgstr(p^), IntToStr(p-PChar(
Targets)+1)]);
end;
begin
Result:='';
if Targets='' then exit;
p:=PChar(Targets);
repeat
case p^ of
#0:
if p-PChar(Targets)=length(Targets) then
break
else begin
WarnInvalidChar;
exit;
end;
#1..#32,#127:
begin
WarnInvalidChar;
exit;
end;
end;
inc(p);
until false;
end;
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
var
p: PChar;
@ -344,57 +306,6 @@ begin
Result[i]:=chr(ord('0')+random(10));
end;
function SplitMatrixMacro(MacroAssignment: string; out MacroName,
MacroValue: string; ExceptionOnError: boolean): boolean;
procedure E(Msg: string);
begin
raise EMMMacroSyntaxException.Create(Msg);
end;
var
p: PChar;
StartP: PChar;
begin
Result:=false;
MacroName:='';
MacroValue:='';
if MacroAssignment='' then begin
if ExceptionOnError then
E(lisMMMissingMacroName);
exit;
end;
p:=PChar(MacroAssignment);
if not IsIdentStartChar[p^] then begin
if ExceptionOnError then
E(Format(lisMMExpectedMacroNameButFound, [dbgstr(p^)]));
exit;
end;
StartP:=p;
repeat
inc(p);
until not IsIdentChar[p^];
MacroName:=copy(MacroAssignment,1,p-StartP);
if (p^<>':') or (p[1]<>'=') then begin
if ExceptionOnError then
E(Format(lisMMExpectedAfterMacroNameButFound, [dbgstr(p^)]));
exit;
end;
inc(p,2);
StartP:=p;
repeat
if (p^=#0) and (p-PChar(MacroAssignment)=length(MacroAssignment)) then break;
if p^ in [#0..#31,#127] then begin
if ExceptionOnError then
E(Format(lisMMInvalidCharacterInMacroValue, [dbgstr(p^)]));
exit;
end;
inc(p);
until false;
MacroValue:=copy(MacroAssignment,StartP-PChar(MacroAssignment)+1,p-StartP);
Result:=true;
end;
procedure ApplyBuildMatrixMacros(Options: TBuildMatrixOptions;
Target, ActiveMode: string; CfgVars: TCTCfgScriptVariables);
var