From 5f5b73b22e4ff09dd9d82aac830c094079a0021b Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 8 Dec 2022 20:21:27 +0100 Subject: [PATCH] IDE: Move ModeMatrixOpts and IdeOptionDefs to new base-package "IdeConfig" --- ide/frames/compiler_modematrix.pas | 89 ++++++++++++++++++ ide/lazarus.lpi | 9 -- ide/packages/ideconfig/fpmake.pp | 4 + ide/packages/ideconfig/ideconfig.lpk | 10 +- ide/packages/ideconfig/ideconfig.pas | 2 +- .../ideconfig}/ideoptiondefs.pas | 2 +- .../ideconfig}/modematrixopts.pas | 91 +------------------ 7 files changed, 105 insertions(+), 102 deletions(-) rename ide/{ => packages/ideconfig}/ideoptiondefs.pas (99%) rename ide/{ => packages/ideconfig}/modematrixopts.pas (92%) diff --git a/ide/frames/compiler_modematrix.pas b/ide/frames/compiler_modematrix.pas index 376f74e5fb..2abf4c5a2e 100644 --- a/ide/frames/compiler_modematrix.pas +++ b/ide/frames/compiler_modematrix.pas @@ -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); diff --git a/ide/lazarus.lpi b/ide/lazarus.lpi index 9141107967..bedeeef643 100644 --- a/ide/lazarus.lpi +++ b/ide/lazarus.lpi @@ -653,10 +653,6 @@ - - - - @@ -1228,11 +1224,6 @@ - - - - - diff --git a/ide/packages/ideconfig/fpmake.pp b/ide/packages/ideconfig/fpmake.pp index bba23a3f2a..148511f766 100644 --- a/ide/packages/ideconfig/fpmake.pp +++ b/ide/packages/ideconfig/fpmake.pp @@ -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'); diff --git a/ide/packages/ideconfig/ideconfig.lpk b/ide/packages/ideconfig/ideconfig.lpk index 0c466335e4..69cd82d61c 100644 --- a/ide/packages/ideconfig/ideconfig.lpk +++ b/ide/packages/ideconfig/ideconfig.lpk @@ -42,7 +42,15 @@ Files in this package are for the main configuration of the IDE."/> - + + + + + + + + + diff --git a/ide/packages/ideconfig/ideconfig.pas b/ide/packages/ideconfig/ideconfig.pas index b53772e7e8..d7b50251f3 100644 --- a/ide/packages/ideconfig/ideconfig.pas +++ b/ide/packages/ideconfig/ideconfig.pas @@ -9,7 +9,7 @@ interface uses SearchPathProcs, RecentListProcs, IdeXmlConfigProcs, LazConf, - TransferMacrosIntf, LazarusPackageIntf; + TransferMacrosIntf, IDEOptionDefs, ModeMatrixOpts, LazarusPackageIntf; implementation diff --git a/ide/ideoptiondefs.pas b/ide/packages/ideconfig/ideoptiondefs.pas similarity index 99% rename from ide/ideoptiondefs.pas rename to ide/packages/ideconfig/ideoptiondefs.pas index 9d83110c65..9eafa8506c 100644 --- a/ide/ideoptiondefs.pas +++ b/ide/packages/ideconfig/ideoptiondefs.pas @@ -39,7 +39,7 @@ uses LazFileUtils, LazConfigStorage, Laz2_XMLCfg, LazUTF8, // IdeIntf BaseIDEIntf, IDEExternToolIntf, - // IDE + // IdeConfig LazConf; type diff --git a/ide/modematrixopts.pas b/ide/packages/ideconfig/modematrixopts.pas similarity index 92% rename from ide/modematrixopts.pas rename to ide/packages/ideconfig/modematrixopts.pas index 3481bfd559..feae1f90ba 100644 --- a/ide/modematrixopts.pas +++ b/ide/packages/ideconfig/modematrixopts.pas @@ -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