From 00970a7e27253d10bb1cb0d6bace0b4c3a91ba1e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 13 Mar 2013 00:55:56 +0000 Subject: ide: when a project is loaded, project macros are merged with ide macros --- examples/apps/ide/src/ideconst.pas | 2 ++ examples/apps/ide/src/project.pas | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/examples/apps/ide/src/ideconst.pas b/examples/apps/ide/src/ideconst.pas index 3570bcbf..03c43ec4 100644 --- a/examples/apps/ide/src/ideconst.pas +++ b/examples/apps/ide/src/ideconst.pas @@ -26,6 +26,8 @@ const // Predefined Macros + cMacroPrefix = '${'; + cMacroSuffix = '}'; cMacro_FPCSrcDir = '${FPCSRCDIR}'; cMacro_FPGuiDir = '${FPGUIDIR}'; cMacro_FPGuiLibDir = '${FPGUILIBDIR}'; diff --git a/examples/apps/ide/src/project.pas b/examples/apps/ide/src/project.pas index f31e724f..1aa740aa 100644 --- a/examples/apps/ide/src/project.pas +++ b/examples/apps/ide/src/project.pas @@ -25,6 +25,7 @@ type FMakeOptions: TStringList; FMacroNames: TStringList; FUnitOutputDir: TfpgString; + procedure MergeWithGlobalMacros; public constructor Create; destructor Destroy; override; @@ -33,6 +34,7 @@ type function GenerateCmdLine(const AShowOnly: Boolean = False; const ABuildMode: integer = -1): TfpgString; procedure ClearAndInitMakeOptions(const ASize: integer); procedure ClearAndInitUnitDirsGrid(const ASize: integer); + procedure ClearAndInitMacrosGrid(const ASize: integer); property ProjectDir: TfpgString read FProjectDir write FProjectDir; property ProjectName: TfpgString read FProjectName write FProjectName; property MainUnit: TfpgString read FMainUnit write FMainUnit; @@ -60,6 +62,7 @@ uses ideconst ,ideutils ,fpg_utils + ,idemacros ; @@ -82,6 +85,20 @@ end; { TProject } +procedure TProject.MergeWithGlobalMacros; +var + o: TIDEMacro; + i: integer; + n,v: TfpgString; +begin + for i := 0 to MacroNames.Count-1 do + begin + MacroNames.GetNameValue(i, n, v); + o := TIDEMacro.Create(cMacroPrefix + n + cMacroSuffix, v, ''); + GMacroList.Add(o); + end; +end; + constructor TProject.Create; begin inherited Create; @@ -264,6 +281,9 @@ begin // Load Macro definitions LoadList(cProjectOptions, MacroNames, 'MacroCount', 'Macro'); + if MacroNames.Count > 0 then + GMacroList.ResetToDefaults; + MergeWithGlobalMacros; // Load Unit search dirs LoadList(cProjectOptions, UnitDirs, 'UnitDirsCount', 'UnitDir'); @@ -357,6 +377,11 @@ begin SetLength(FUnitDirsGrid, 10, ASize); // 10 columns by X rows end; +procedure TProject.ClearAndInitMacrosGrid(const ASize: integer); +begin + FMacroNames.Clear; +end; + initialization uProject := nil; -- cgit v1.2.3-70-g09d2