From 034fdfe9b31d5921274a0ec44129c92fe4cc3e8e Mon Sep 17 00:00:00 2001 From: joost Date: Sat, 1 Dec 2018 22:33:45 +0000 Subject: [PATCH] fppkg: Implement support for package-variants git-svn-id: trunk@59712 - --- .gitattributes | 1 + components/fppkg/src/fppkg_interface.pas | 184 ++- .../fppkg/src/fppkg_packageoptionsfrm.lfm | 1384 ++++++++++++++++- .../fppkg/src/fppkg_packageoptionsfrm.pas | 359 ++++- components/fppkg/src/fppkg_packagevariant.pas | 212 +++ components/fppkg/src/fppkgpackagemanager.lpk | 21 +- components/fppkg/src/fppkgpackagemanager.pas | 2 +- components/ideintf/fppkgintf.pas | 6 +- packager/packagesystem.pas | 36 +- 9 files changed, 2154 insertions(+), 51 deletions(-) create mode 100644 components/fppkg/src/fppkg_packagevariant.pas diff --git a/.gitattributes b/.gitattributes index fa8f45313c..311808df16 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1505,6 +1505,7 @@ components/fppkg/src/fppkg_optionsfrm.lfm svneol=native#text/plain components/fppkg/src/fppkg_optionsfrm.pas svneol=native#text/plain components/fppkg/src/fppkg_packageoptionsfrm.lfm svneol=native#text/plain components/fppkg/src/fppkg_packageoptionsfrm.pas svneol=native#text/pascal +components/fppkg/src/fppkg_packagevariant.pas svneol=native#text/pascal components/fppkg/src/fppkgpackagemanager.lpk svneol=native#text/plain components/fppkg/src/fppkgpackagemanager.pas svneol=native#text/plain components/fppkg/src/fppkgworkerthread.pas svneol=native#text/plain diff --git a/components/fppkg/src/fppkg_interface.pas b/components/fppkg/src/fppkg_interface.pas index 3c0f4828c2..d8af332861 100644 --- a/components/fppkg/src/fppkg_interface.pas +++ b/components/fppkg/src/fppkg_interface.pas @@ -7,23 +7,37 @@ interface uses Classes, SysUtils, + StrUtils, + PackageIntf, FppkgIntf, - Fppkg_EnvironmentOptions; + Fppkg_EnvironmentOptions, + fppkg_packagevariant; type { TFppkgInterfaceEx } TFppkgInterfaceEx = class(TFppkgInterface) + private + function GetComponentName(AName: string): String; protected function GetInstallFPMakeDependencies: Boolean; override; function GetUseFPMakeWhenPossible: Boolean; override; + public + function ConstructFpMakeImplementationSection(APackage: TIDEPackage): string; override; + function ConstructFpMakeInterfaceSection(APackage: TIDEPackage): string; override; + function ConstructFpMakeDependenciesFileSection(APackage: TIDEPackage): string; override; end; implementation { TFppkgInterfaceEx } +function TFppkgInterfaceEx.GetComponentName(AName: string): String; +begin + Result := StringsReplace(AName, ['/',' ', '\', ':', ';', '.', ',','(',')'], ['_','_', '_', '_', '_', '_', '_', '_', '_'], [rfReplaceAll]); +end; + function TFppkgInterfaceEx.GetInstallFPMakeDependencies: Boolean; begin Result := TFppkgEnvironmentOptions(TFppkgEnvironmentOptions.GetInstance).InstallFPMakeDependencies; @@ -34,6 +48,174 @@ begin Result := TFppkgEnvironmentOptions(TFppkgEnvironmentOptions.GetInstance).UseFPMakeWhenPossible; end; +function TFppkgInterfaceEx.ConstructFpMakeInterfaceSection(APackage: TIDEPackage): string; +var + VariantList: TFppkgPackageVariantList; + Variant: TFppkgPackageVariant; + i, j: Integer; +begin + Result := ''; + VariantList := TFppkgPackageVariantList.Create(True); + try + APackage.CustomOptions.AppendBasePath('Fppkg/'); + APackage.CustomOptions.AppendBasePath('PackageVariants/'); + try + VariantList.Load(APackage.CustomOptions); + + for i := 0 to VariantList.Count -1 do + begin + Variant := VariantList.Items[i]; + result := Result + ' ' + GetComponentName(Variant.Name) + 'Variant: TPackageVariants;' + LineEnding +' '; + if Variant.Items.Count > 0 then + begin + for j := 0 to Variant.Items.Count -1 do + begin + result := result + GetComponentName(Variant.Items[j].Name) + 'VariantItem, '; + end; + SetLength(Result, length(Result) -2); + Result := Result + ': TPackageVariant;' + LineEnding; + end; + end; + + if Result <> '' then + Result := 'var' + LineEnding + Result; + finally + APackage.CustomOptions.UndoAppendBasePath; + APackage.CustomOptions.UndoAppendBasePath; + end; + finally + VariantList.Free; + end; +end; + +function TFppkgInterfaceEx.ConstructFpMakeDependenciesFileSection(APackage: TIDEPackage): string; +var + VariantList: TFppkgPackageVariantList; + Variant: TFppkgPackageVariant; + i, j, k: Integer; + Found: Boolean; +begin + Result := ''; + VariantList := TFppkgPackageVariantList.Create(True); + try + APackage.CustomOptions.AppendBasePath('Fppkg/'); + APackage.CustomOptions.AppendBasePath('PackageVariants/'); + try + VariantList.Load(APackage.CustomOptions); + + for i := 0 to APackage.FileCount -1 do + if APackage.Files[i].FileType = pftUnit then + begin + Found := False; + + for j := 0 to VariantList.Count -1 do + begin + Variant := VariantList.Items[j]; + for k := 0 to Variant.Items.Count -1 do + begin + if Variant.Items[k].PackageFiles.IndexOf(APackage.Files[i].GetShortFilename(False)) > -1 then + begin + Found := True; + //Result := Result + ' ' + GetComponentName(Variant.Items[k].Name) +'VariantItem.Targets.AddImplicitUnit('''+APackage.Files[i].GetShortFilename(False)+''');' + LineEnding; + end; + end; + end; + + if not Found then + Result := Result + ' t.Dependencies.AddUnit('''+APackage.files[i].Unit_Name+''');' + LineEnding; + end; + + for i := 0 to APackage.FileCount-1 do + if (APackage.Files[i].FileType=pftUnit) then + begin + Found := False; + + for j := 0 to VariantList.Count -1 do + begin + Variant := VariantList.Items[j]; + for k := 0 to Variant.Items.Count -1 do + begin + if Variant.Items[k].PackageFiles.IndexOf(APackage.Files[i].GetShortFilename(False)) > -1 then + begin + Found := True; + //if (pffAddToPkgUsesSection in APackage.Files[i].Flags) then + // Result := Result + ' ' + GetComponentName(Variant.Items[k].Name) +'VariantItem.Targets.AddUnit('''+APackage.Files[i].GetShortFilename(False)+''');' + LineEnding; + //else + Result := Result + ' ' + GetComponentName(Variant.Items[k].Name) +'VariantItem.Targets.AddImplicitUnit('''+APackage.Files[i].GetShortFilename(False)+''');' + LineEnding; + end; + end; + end; + + if not found then + begin + //if (pffAddToPkgUsesSection in APackage.Files[i].Flags) then + // Result:=Result+' T:=P.Targets.AddUnit('''+CreateRelativePath(APackage.Files[i].Filename,APackage.Directory)+''');'+LineEnding) + //else + Result:=Result+' P.Targets.AddImplicitUnit('''+APackage.Files[i].GetShortFilename(False)+''');'+LineEnding; + end; + end; + finally + APackage.CustomOptions.UndoAppendBasePath; + APackage.CustomOptions.UndoAppendBasePath; + end; + finally + VariantList.Free; + end; +end; + +function TFppkgInterfaceEx.ConstructFpMakeImplementationSection(APackage: TIDEPackage): string; +var + VariantList: TFppkgPackageVariantList; + Variant: TFppkgPackageVariant; + ItemName: string; + i, j, k: Integer; + CustomCode: TStrings; +begin + Result := ''; + VariantList := TFppkgPackageVariantList.Create(True); + try + APackage.CustomOptions.AppendBasePath('Fppkg/'); + try + APackage.CustomOptions.AppendBasePath('PackageVariants/'); + try + VariantList.Load(APackage.CustomOptions); + + for i := 0 to VariantList.Count -1 do + begin + Variant := VariantList.Items[i]; + result := result + ' ' + GetComponentName(Variant.Name) + 'Variant := AddPackageVariant('''+Variant.Name+''',true);' + LineEnding; + result := result + ' P.AddPackageVariant('+GetComponentName(Variant.Name)+'Variant);' + LineEnding; + if Variant.Items.Count > 0 then + begin + for j := 0 to Variant.Items.Count -1 do + begin + ItemName := GetComponentName(Variant.Items[j].Name) + 'VariantItem'; + result := result + ' ' + ItemName + ' := ' + GetComponentName(Variant.Name) + 'Variant.add('''+Variant.Items[j].Name+''');' + LineEnding; + for k := 0 to Variant.Items[j].CompilerOptions.Count -1 do + begin + Result := Result + ' ' + ItemName + '.Options.Add(''' + Variant.Items[j].CompilerOptions[k] + ''');' + LineEnding; + end; + end; + end; + end; + finally + APackage.CustomOptions.UndoAppendBasePath; + end; + CustomCode := TStringList.Create; + try + APackage.CustomOptions.GetValue('CustomCode', CustomCode); + result := result + CustomCode.Text; + finally + CustomCode.Free; + end; + finally + APackage.CustomOptions.UndoAppendBasePath; + end; + finally + VariantList.Free; + end; +end; + initialization FppkgInterface := TFppkgInterfaceEx.Create; finalization diff --git a/components/fppkg/src/fppkg_packageoptionsfrm.lfm b/components/fppkg/src/fppkg_packageoptionsfrm.lfm index d17e3400a8..afb990e548 100644 --- a/components/fppkg/src/fppkg_packageoptionsfrm.lfm +++ b/components/fppkg/src/fppkg_packageoptionsfrm.lfm @@ -1,55 +1,1385 @@ object FppkgPackageOptionsFrm: TFppkgPackageOptionsFrm Left = 0 - Height = 240 + Height = 1565 Top = 0 - Width = 320 - ClientHeight = 240 - ClientWidth = 320 + Width = 1040 + ClientHeight = 1565 + ClientWidth = 1040 + DesignTimePPI = 192 + ParentFont = False TabOrder = 0 - DesignLeft = 831 - DesignTop = 330 + DesignLeft = 2768 + DesignTop = 392 object gbBuildMethod: TGroupBox Left = 0 - Height = 240 + Height = 152 Top = 0 - Width = 320 - Align = alClient + Width = 1040 + Align = alTop Caption = 'Build method' - ClientHeight = 220 - ClientWidth = 318 + ClientHeight = 132 + ClientWidth = 1038 + ParentFont = False TabOrder = 0 object Panel1: TPanel - Left = 3 - Height = 42 - Top = 3 - Width = 312 + Left = 20 + Height = 80 + Top = 20 + Width = 998 Align = alTop - BorderSpacing.Around = 3 + BorderSpacing.Around = 20 BevelOuter = bvNone - ClientHeight = 42 - ClientWidth = 312 + ClientHeight = 80 + ClientWidth = 998 + ParentFont = False TabOrder = 0 object cbBuildMethod: TComboBox - Left = 88 - Height = 42 + Left = 201 + Height = 80 Top = 0 - Width = 224 - Align = alRight + Width = 797 + Align = alClient ItemHeight = 0 + ParentFont = False Style = csDropDownList TabOrder = 0 end object Label1: TLabel - Left = 3 - Height = 36 - Top = 3 - Width = 55 + Left = 6 + Height = 68 + Top = 6 + Width = 109 Align = alLeft - BorderSpacing.Around = 3 + BorderSpacing.Right = 80 + BorderSpacing.Around = 6 Caption = 'Package' Layout = tlCenter ParentColor = False + ParentFont = False end end end + object gbPackageVariant: TGroupBox + Left = 0 + Height = 1203 + Top = 362 + Width = 1040 + Align = alClient + Caption = 'Package variants' + ClientHeight = 1183 + ClientWidth = 1038 + ParentFont = False + TabOrder = 1 + object Panel2: TPanel + Left = 0 + Height = 336 + Top = 100 + Width = 1038 + Align = alTop + BevelOuter = bvNone + ClientHeight = 336 + ClientWidth = 1038 + ParentFont = False + TabOrder = 0 + object lbPackageVariant: TListBox + Left = 20 + Height = 240 + Top = 76 + Width = 392 + Align = alLeft + BorderSpacing.Around = 20 + ItemHeight = 0 + OnClick = lbPackageVariantClick + ParentFont = False + ScrollWidth = 390 + TabOrder = 0 + TopIndex = -1 + end + object Label2: TLabel + Left = 20 + Height = 36 + Top = 20 + Width = 998 + Align = alTop + BorderSpacing.Around = 20 + Caption = 'Possible variants:' + ParentColor = False + ParentFont = False + end + object Panel4: TPanel + Left = 432 + Height = 260 + Top = 76 + Width = 606 + Align = alClient + BevelOuter = bvNone + ClientHeight = 260 + ClientWidth = 606 + ParentFont = False + TabOrder = 1 + object Panel5: TPanel + Left = 0 + Height = 100 + Top = 0 + Width = 606 + Align = alTop + BevelOuter = bvNone + ClientHeight = 100 + ClientWidth = 606 + ParentFont = False + TabOrder = 0 + object Button3: TButton + Left = 0 + Height = 60 + Top = 20 + Width = 150 + Action = aAddPackageVariantItem + Align = alLeft + BorderSpacing.Top = 20 + BorderSpacing.Right = 20 + BorderSpacing.Bottom = 20 + ParentFont = False + TabOrder = 0 + end + object Button4: TButton + Left = 170 + Height = 60 + Top = 20 + Width = 150 + Action = aDeletePackageVariantItem + Align = alLeft + BorderSpacing.Around = 20 + ParentFont = False + TabOrder = 1 + end + end + end + end + object Panel3: TPanel + Left = 0 + Height = 100 + Top = 0 + Width = 1038 + Align = alTop + BevelOuter = bvNone + ClientHeight = 100 + ClientWidth = 1038 + ParentFont = False + TabOrder = 1 + object cbPackageVariants: TComboBox + Left = 20 + Height = 60 + Top = 20 + Width = 328 + Align = alClient + BorderSpacing.Around = 20 + ItemHeight = 0 + OnChange = cbPackageVariantsChange + ParentFont = False + Style = csDropDownList + TabOrder = 0 + end + object Button1: TButton + Left = 368 + Height = 60 + Top = 20 + Width = 286 + Action = aAddPackageVariant + Align = alRight + BorderSpacing.Around = 20 + ParentFont = False + TabOrder = 1 + end + object Button2: TButton + Left = 674 + Height = 60 + Top = 20 + Width = 344 + Action = aDeletePackageVariant + Align = alRight + BorderSpacing.Around = 20 + ParentFont = False + TabOrder = 2 + end + end + object pPackageVariantItem: TPanel + Left = 0 + Height = 747 + Top = 436 + Width = 1038 + Align = alClient + BevelOuter = bvNone + ClientHeight = 747 + ClientWidth = 1038 + ParentFont = False + TabOrder = 2 + object lPackageItem: TLabel + Left = 20 + Height = 36 + Top = 20 + Width = 998 + Align = alTop + BorderSpacing.Around = 20 + Caption = 'Package variant [] - []' + ParentColor = False + ParentFont = False + end + inline seCompilerOptions: TSynEdit + Left = 20 + Height = 251 + Top = 76 + Width = 998 + Align = alClient + BorderSpacing.Around = 20 + Font.Height = 26 + Font.Name = 'DejaVu Sans Mono' + Font.Pitch = fpFixed + Font.Quality = fqNonAntialiased + ParentColor = False + ParentFont = False + TabOrder = 0 + Gutter.Width = 113 + Gutter.MouseActions = <> + RightGutter.Width = 0 + RightGutter.MouseActions = <> + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 24649 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 24661 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel3 + ShortCut = 41011 + end + item + Command = EcFoldLevel4 + ShortCut = 41012 + end + item + Command = EcFoldLevel5 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = <> + MouseTextActions = <> + MouseSelActions = <> + Lines.Strings = ( + 'seCompilerOptions' + ) + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + OnChange = seCompilerOptionsChange + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 48 + MouseActions = <> + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 33 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 8 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 4 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + Width = 20 + MouseActions = <> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = <> + MouseActionsCollapsed = <> + end + end + end + object Panel6: TPanel + Left = 0 + Height = 400 + Top = 347 + Width = 1038 + Align = alBottom + BevelOuter = bvNone + ClientHeight = 400 + ClientWidth = 1038 + ParentFont = False + TabOrder = 1 + object lbPackageFiles: TListBox + Left = 20 + Height = 304 + Top = 76 + Width = 420 + Align = alLeft + BorderSpacing.Around = 20 + ItemHeight = 0 + ParentFont = False + ScrollWidth = 418 + TabOrder = 0 + TopIndex = -1 + end + object Panel7: TPanel + Left = 460 + Height = 324 + Top = 76 + Width = 578 + Align = alClient + BevelOuter = bvNone + ClientHeight = 324 + ClientWidth = 578 + ParentFont = False + TabOrder = 1 + object Panel8: TPanel + Left = 0 + Height = 100 + Top = 0 + Width = 578 + Align = alTop + BevelOuter = bvNone + ClientHeight = 100 + ClientWidth = 578 + ParentFont = False + TabOrder = 0 + object Button5: TButton + Left = 388 + Height = 60 + Top = 20 + Width = 150 + Action = aFileAdd + Align = alLeft + BorderSpacing.Around = 20 + ParentFont = False + TabOrder = 0 + end + object cbProjectFiles: TComboBox + Left = 20 + Height = 60 + Top = 20 + Width = 348 + Align = alLeft + AutoComplete = True + AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending] + BorderSpacing.Around = 20 + ItemHeight = 0 + ParentFont = False + Sorted = True + Style = csDropDownList + TabOrder = 1 + end + end + object Panel9: TPanel + Left = 0 + Height = 100 + Top = 224 + Width = 578 + Align = alBottom + BevelOuter = bvNone + ClientHeight = 100 + ClientWidth = 578 + ParentFont = False + TabOrder = 1 + object Button6: TButton + Left = 20 + Height = 60 + Top = 20 + Width = 204 + Action = aFileRemove + Align = alLeft + BorderSpacing.Around = 20 + ParentFont = False + TabOrder = 0 + end + end + end + object lPackageItem1: TLabel + Left = 20 + Height = 36 + Top = 20 + Width = 998 + Align = alTop + BorderSpacing.Around = 20 + Caption = 'Package-files linked to this variant' + ParentColor = False + ParentFont = False + end + end + end + end + object GroupBox1: TGroupBox + Left = 0 + Height = 210 + Top = 152 + Width = 1040 + Align = alTop + Caption = 'Custom FPMake code' + ClientHeight = 190 + ClientWidth = 1038 + ParentFont = False + TabOrder = 2 + inline seCustomFPMakeCode: TSynEdit + Left = 20 + Height = 150 + Top = 20 + Width = 998 + Align = alClient + BorderSpacing.Around = 20 + Font.Height = 26 + Font.Name = 'DejaVu Sans Mono' + Font.Pitch = fpFixed + Font.Quality = fqNonAntialiased + ParentColor = False + ParentFont = False + TabOrder = 0 + Gutter.Width = 113 + Gutter.MouseActions = <> + RightGutter.Width = 0 + RightGutter.MouseActions = <> + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 24649 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 24661 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel3 + ShortCut = 41011 + end + item + Command = EcFoldLevel4 + ShortCut = 41012 + end + item + Command = EcFoldLevel5 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = <> + MouseTextActions = <> + MouseSelActions = <> + Lines.Strings = ( + 'seCustomFPMakeCode' + ) + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 48 + MouseActions = <> + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 33 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 8 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 4 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + Width = 20 + MouseActions = <> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = <> + MouseActionsCollapsed = <> + end + end + end + end + object ActionList: TActionList + Left = 720 + Top = 448 + object aAddPackageVariant: TAction + Caption = 'Add package variant' + OnExecute = aAddPackageVariantExecute + end + object aDeletePackageVariant: TAction + Caption = 'Delete package variant' + OnExecute = aDeletePackageVariantExecute + OnUpdate = aDeletePackageVariantUpdate + end + object aAddPackageVariantItem: TAction + Caption = 'Add' + OnExecute = aAddPackageVariantItemExecute + end + object aDeletePackageVariantItem: TAction + Caption = 'Delete' + OnExecute = aDeletePackageVariantItemExecute + OnUpdate = aDeletePackageVariantItemUpdate + end + object aFileAdd: TAction + Caption = 'Add file' + OnExecute = aFileAddExecute + OnUpdate = aFileAddUpdate + end + object aFileRemove: TAction + Caption = 'File remove' + OnExecute = aFileRemoveExecute + OnUpdate = aFileRemoveUpdate + end + end end diff --git a/components/fppkg/src/fppkg_packageoptionsfrm.pas b/components/fppkg/src/fppkg_packageoptionsfrm.pas index 042abb7e33..24af80018e 100644 --- a/components/fppkg/src/fppkg_packageoptionsfrm.pas +++ b/components/fppkg/src/fppkg_packageoptionsfrm.pas @@ -7,24 +7,83 @@ interface uses Classes, SysUtils, + Math, Forms, Controls, StdCtrls, ExtCtrls, + Dialogs, + ActnList, ComboEx, PackageIntf, IDEOptEditorIntf, - IDEOptionsIntf; + IDEOptionsIntf, SynEdit, + fppkg_packagevariant; type { TFppkgPackageOptionsFrm } TFppkgPackageOptionsFrm = class(TAbstractIDEOptionsEditor) + aAddPackageVariant: TAction; + aAddPackageVariantItem: TAction; + aFileRemove: TAction; + aFileAdd: TAction; + aDeletePackageVariantItem: TAction; + aDeletePackageVariant: TAction; + ActionList: TActionList; + Button1: TButton; + Button2: TButton; + Button3: TButton; + Button4: TButton; + Button5: TButton; + Button6: TButton; cbBuildMethod: TComboBox; + cbPackageVariants: TComboBox; + cbProjectFiles: TComboBox; gbBuildMethod: TGroupBox; + gbPackageVariant: TGroupBox; + GroupBox1: TGroupBox; Label1: TLabel; + Label2: TLabel; + lbPackageFiles: TListBox; + lPackageItem: TLabel; + lbPackageVariant: TListBox; + lPackageItem1: TLabel; Panel1: TPanel; + Panel2: TPanel; + Panel3: TPanel; + Panel4: TPanel; + Panel5: TPanel; + Panel6: TPanel; + Panel7: TPanel; + Panel8: TPanel; + Panel9: TPanel; + pPackageVariantItem: TPanel; + seCompilerOptions: TSynEdit; + seCustomFPMakeCode: TSynEdit; + procedure aAddPackageVariantExecute(Sender: TObject); + procedure aAddPackageVariantItemExecute(Sender: TObject); + procedure aDeletePackageVariantExecute(Sender: TObject); + procedure aDeletePackageVariantItemExecute(Sender: TObject); + procedure aDeletePackageVariantItemUpdate(Sender: TObject); + procedure aDeletePackageVariantUpdate(Sender: TObject); + procedure aFileAddExecute(Sender: TObject); + procedure aFileAddUpdate(Sender: TObject); + procedure aFileRemoveExecute(Sender: TObject); + procedure aFileRemoveUpdate(Sender: TObject); + procedure cbPackageVariantsChange(Sender: TObject); + procedure lbPackageVariantClick(Sender: TObject); + function GetCurrentPackageVariant: TFppkgPackageVariant; + function GetCurrentPackageVariantItem: TFppkgPackageVariantItem; + procedure seCompilerOptionsChange(Sender: TObject); protected + FModified: Boolean; + FPackageVariantList: TFppkgPackageVariantList; + FPackageList: TStrings; + procedure ShowPackageVariants(); + procedure ShowCurrentPackageVariant(); + procedure ShowCurrentPackageVariantItem(); + public function GetTitle: String; override; procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override; @@ -32,6 +91,8 @@ type class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; end; @@ -44,7 +105,7 @@ var {$R *.lfm} resourcestring - lisFppkgPckOptsTitle = 'Build method'; + lisFppkgPckOptsTitle = 'Fppkg'; lisFppkgPckOptsBuildMethod = 'Supported build methods'; lisFppkgBuildMethodFPMake = 'FPMake'; lisFppkgBuildMethodLazarus = 'Lazbuild'; @@ -53,6 +114,238 @@ resourcestring { TFppkgPackageOptionsFrm } +procedure TFppkgPackageOptionsFrm.lbPackageVariantClick(Sender: TObject); +begin + ShowCurrentPackageVariantItem(); +end; + +function TFppkgPackageOptionsFrm.GetCurrentPackageVariant: TFppkgPackageVariant; +begin + if cbPackageVariants.ItemIndex > -1 then + Result := FPackageVariantList.Items[cbPackageVariants.ItemIndex] + else + Result := Nil; +end; + +function TFppkgPackageOptionsFrm.GetCurrentPackageVariantItem: TFppkgPackageVariantItem; +begin + if not Assigned(GetCurrentPackageVariant) then + Result := Nil + else if lbPackageVariant.ItemIndex > -1 then + Result := GetCurrentPackageVariant.Items[lbPackageVariant.ItemIndex] + else + Result := Nil; +end; + +procedure TFppkgPackageOptionsFrm.seCompilerOptionsChange(Sender: TObject); +begin + GetCurrentPackageVariantItem.CompilerOptions.Assign(seCompilerOptions.Lines); +end; + +procedure TFppkgPackageOptionsFrm.ShowPackageVariants(); +var + i: Integer; +begin + for i := 0 to FPackageVariantList.Count -1 do + begin + if cbPackageVariants.Items.Count <= i then + cbPackageVariants.Items.Add(FPackageVariantList[i].Name) + else + cbPackageVariants.Items[i] := FPackageVariantList[i].Name; + end; + for i := cbPackageVariants.Items.Count -1 downto FPackageVariantList.Count do + cbPackageVariants.Items.Delete(i); + if FPackageVariantList.Count > 0 then + begin + if cbPackageVariants.ItemIndex = -1 then + cbPackageVariants.ItemIndex := 0; + end + else + begin + cbPackageVariants.ItemIndex := -1; + end; + ShowCurrentPackageVariant; +end; + +procedure TFppkgPackageOptionsFrm.ShowCurrentPackageVariant(); +var + CurrentPackageVariant: TFppkgPackageVariant; + i: Integer; +begin + CurrentPackageVariant := GetCurrentPackageVariant; + if Assigned(CurrentPackageVariant) then + begin + for i := 0 to CurrentPackageVariant.Items.Count -1 do + begin + if lbPackageVariant.Items.Count <= i then + lbPackageVariant.Items.Add(CurrentPackageVariant.Items[i].Name) + else + lbPackageVariant.Items[i] := CurrentPackageVariant.Items[i].Name; + end; + for i := lbPackageVariant.Count -1 downto CurrentPackageVariant.Items.Count do + lbPackageVariant.Items.Delete(i); + Panel2.Visible := True; + end + else + begin + Panel2.Visible := False; + end; + ShowCurrentPackageVariantItem(); +end; + +procedure TFppkgPackageOptionsFrm.ShowCurrentPackageVariantItem(); +var + PackageVariantItem: TFppkgPackageVariantItem; + i, StoredItemIndex: Integer; + s: String; +begin + PackageVariantItem := GetCurrentPackageVariantItem; + if Assigned(PackageVariantItem) then + begin + pPackageVariantItem.Visible := True; + lPackageItem.Caption := Format('Package variant [%s]-[%s]', [GetCurrentPackageVariant.Name, PackageVariantItem.Name]); + seCompilerOptions.Lines.Assign(PackageVariantItem.CompilerOptions); + StoredItemIndex := cbProjectFiles.ItemIndex; + lbPackageFiles.Clear; + cbProjectFiles.Clear; + + for i := 0 to FPackageList.Count -1 do + begin + s := FPackageList.Strings[i]; + if PackageVariantItem.PackageFiles.IndexOf(s) > -1 then + lbPackageFiles.Items.Add(s) + else + cbProjectFiles.Items.Add(s); + end; + cbProjectFiles.ItemIndex := min(cbProjectFiles.Items.Count -1, StoredItemIndex); + + end + else + begin + pPackageVariantItem.Visible := False; + end; +end; + +procedure TFppkgPackageOptionsFrm.aDeletePackageVariantUpdate(Sender: TObject); +begin + aDeletePackageVariant.Enabled := cbPackageVariants.ItemIndex > -1; +end; + +procedure TFppkgPackageOptionsFrm.aFileAddExecute(Sender: TObject); +begin + if cbProjectFiles.ItemIndex > -1 then + GetCurrentPackageVariantItem.PackageFiles.Add(cbProjectFiles.Text); + ShowCurrentPackageVariantItem(); + FModified := True; +end; + +procedure TFppkgPackageOptionsFrm.aFileAddUpdate(Sender: TObject); +begin + aFileAdd.Enabled := cbProjectFiles.ItemIndex > -1; +end; + +procedure TFppkgPackageOptionsFrm.aFileRemoveExecute(Sender: TObject); +var + i: Integer; +begin + i := lbPackageFiles.ItemIndex; + if i > -1 then + GetCurrentPackageVariantItem.PackageFiles.Delete(GetCurrentPackageVariantItem.PackageFiles.IndexOf(lbPackageFiles.Items[i])); + ShowCurrentPackageVariantItem(); + FModified := True; +end; + +procedure TFppkgPackageOptionsFrm.aFileRemoveUpdate(Sender: TObject); +begin + aFileRemove.Enabled := lbPackageFiles.ItemIndex > -1; +end; + +procedure TFppkgPackageOptionsFrm.cbPackageVariantsChange(Sender: TObject); +begin + ShowCurrentPackageVariant; +end; + +procedure TFppkgPackageOptionsFrm.aDeletePackageVariantExecute(Sender: TObject); +var + PackageVariant: TFppkgPackageVariant; +begin + PackageVariant := FPackageVariantList.FindItemByName(cbPackageVariants.Text); + if Assigned(PackageVariant) then + begin + if MessageDlg('Fppkg', Format('Are you sure you want to remove the package variant [%s]?', [PackageVariant.Name]), mtConfirmation, mbYesNo, 0) = mrYes then + begin + FPackageVariantList.Remove(PackageVariant); + end; + end; + FModified := True; + ShowPackageVariants; +end; + +procedure TFppkgPackageOptionsFrm.aDeletePackageVariantItemExecute(Sender: TObject); +var + PackageVariantItem: TFppkgPackageVariantItem; +begin + PackageVariantItem := GetCurrentPackageVariant.Items.FindItemByName(lbPackageVariant.Items[lbPackageVariant.ItemIndex]); + if Assigned(PackageVariantItem) then + begin + if MessageDlg('Fppkg', Format('Are you sure you want to remove the item [%s]?', [PackageVariantItem.Name]), mtConfirmation, mbYesNo, 0) = mrYes then + begin + GetCurrentPackageVariant.Items.Remove(PackageVariantItem); + end; + end; + FModified := True; + ShowCurrentPackageVariant; +end; + +procedure TFppkgPackageOptionsFrm.aDeletePackageVariantItemUpdate(Sender: TObject); +begin + aDeletePackageVariantItem.Enabled := lbPackageVariant.ItemIndex > -1; +end; + +procedure TFppkgPackageOptionsFrm.aAddPackageVariantExecute(Sender: TObject); +var + NameVal: String; + Variant: TFppkgPackageVariant; +begin + if InputQuery('Fppkg', 'Enter the name of the new package-variants', false, NameVal) then + begin + if Assigned(FPackageVariantList.FindItemByName(NameVal)) then + begin + MessageDlg('Fppkg', Format('A packagevariant with the name [%s] already exists.', [NameVal]), mtError, [mbOK], 0); + Exit; + end; + Variant := TFppkgPackageVariant.Create; + Variant.Name := NameVal; + FPackageVariantList.Add(Variant); + end; + FModified := True; + ShowPackageVariants(); +end; + +procedure TFppkgPackageOptionsFrm.aAddPackageVariantItemExecute(Sender: TObject); +var + CurrentVariant: TFppkgPackageVariant; + NameVal: string; + Item: TFppkgPackageVariantItem; +begin + CurrentVariant := GetCurrentPackageVariant; + Assert(Assigned(CurrentVariant)); + + if InputQuery('Fppkg', 'Enter the name of the new item', false, NameVal) then + begin + if Assigned(CurrentVariant.Items.FindItemByName(NameVal)) then + begin + MessageDlg('Fppkg', Format('An item with the name [%s] already exists.', [NameVal]), mtError, [mbOK], 0); + Exit; + end; + Item := TFppkgPackageVariantItem.Create; + Item.Name := NameVal; + CurrentVariant.Items.Add(Item); + end; + FModified := True; + ShowCurrentPackageVariant(); +end; + function TFppkgPackageOptionsFrm.GetTitle: String; begin Result := lisFppkgPckOptsTitle; @@ -70,9 +363,32 @@ end; procedure TFppkgPackageOptionsFrm.ReadSettings(AOptions: TAbstractIDEOptions); var LazPackage: TIDEPackage; + i: Integer; + f: TLazPackageFile; begin LazPackage := (AOptions as TAbstractPackageIDEOptions).Package; cbBuildMethod.ItemIndex := Ord(LazPackage.BuildMethod); + + LazPackage.CustomOptions.AppendBasePath('Fppkg/'); + try + LazPackage.CustomOptions.AppendBasePath('PackageVariants/'); + try + FPackageVariantList.Load(LazPackage.CustomOptions); + finally + LazPackage.CustomOptions.UndoAppendBasePath; + end; + LazPackage.CustomOptions.GetValue('CustomCode', seCustomFPMakeCode.Lines); + finally + LazPackage.CustomOptions.UndoAppendBasePath; + end; + + FPackageList.Clear; + for i := 0 to LazPackage.FileCount -1 do + if LazPackage.Files[i].GetShortFilename(false) <> '' then + FPackageList.Add(LazPackage.Files[i].GetShortFilename(false)); + ShowPackageVariants(); + + FModified := False; end; procedure TFppkgPackageOptionsFrm.WriteSettings(AOptions: TAbstractIDEOptions); @@ -81,6 +397,29 @@ var begin LazPackage := (AOptions as TAbstractPackageIDEOptions).Package; LazPackage.BuildMethod := TBuildMethod(cbBuildMethod.ItemIndex); + + if FModified then + begin + LazPackage.Modified := True; + FModified := False; + end; + + + LazPackage.CustomOptions.AppendBasePath('Fppkg/'); + try + if FPackageVariantList.Count>0 then + begin + LazPackage.CustomOptions.AppendBasePath('PackageVariants/'); + try + FPackageVariantList.Save(LazPackage.CustomOptions); + finally + LazPackage.CustomOptions.UndoAppendBasePath; + end; + end; + LazPackage.CustomOptions.SetValue('CustomCode', seCustomFPMakeCode.Lines); + finally + LazPackage.CustomOptions.UndoAppendBasePath; + end; end; class function TFppkgPackageOptionsFrm.SupportedOptionsClass: TAbstractIDEOptionsClass; @@ -88,6 +427,22 @@ begin Result := TAbstractPackageIDEOptions; end; +constructor TFppkgPackageOptionsFrm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FPackageVariantList := TFppkgPackageVariantList.Create(True); + FPackageList := TStringList.Create; + TStringList(FPackageList).Sorted := True; + TStringList(FPackageList).Duplicates := dupIgnore; +end; + +destructor TFppkgPackageOptionsFrm.Destroy; +begin + FPackageVariantList.Free; + FPackageList.Free; + inherited Destroy; +end; + initialization RegisterIDEOptionsEditor(GroupPackage, TFppkgPackageOptionsFrm, FppkgPackageOptionID); end. diff --git a/components/fppkg/src/fppkg_packagevariant.pas b/components/fppkg/src/fppkg_packagevariant.pas new file mode 100644 index 0000000000..a4a875d603 --- /dev/null +++ b/components/fppkg/src/fppkg_packagevariant.pas @@ -0,0 +1,212 @@ +unit fppkg_packagevariant; + +{$mode objfpc}{$H+} + +interface + +uses + fgl, + Classes, + SysUtils, + Generics.Collections, + LazConfigStorage; + +type + + + { TFppkgNamedItem } + + TFppkgNamedItem = class + private + FName: string; + public + constructor Create; virtual; + procedure Save(Config: TConfigStorage); virtual; + procedure Load(Config: TConfigStorage); virtual; + property Name: string read FName write FName; + end; + + { TFppkgNamedItemList } + + generic TFppkgNamedItemList = class(specialize TObjectList) + public + function FindItemByName(AName: string): T; + procedure Load(Config: TConfigStorage); + procedure Save(Config: TConfigStorage); + end; + + { TFppkgPackageVariantItem } + + TFppkgPackageVariantItem = class(TFppkgNamedItem) + private + FCompilerOptions: TStrings; + FPackageFiles: TStrings; + public + constructor Create(); override; + destructor Destroy; override; + procedure Save(Config: TConfigStorage); override; + procedure Load(Config: TConfigStorage); override; + property CompilerOptions: TStrings read FCompilerOptions; + property PackageFiles: TStrings read FPackageFiles; + end; + TFppkgPackageVariantItemList = specialize TFppkgNamedItemList; + + { TFppkgPackageVariant } + + TFppkgPackageVariant = class(TFppkgNamedItem) + private + FItems: TFppkgPackageVariantItemList; + public + constructor Create; + destructor Destroy; override; + procedure Save(Config: TConfigStorage); override; + procedure Load(Config: TConfigStorage); override; + + property Items: TFppkgPackageVariantItemList read FItems write FItems; + end; + + TFppkgPackageVariantList = specialize TFppkgNamedItemList; + +implementation + +{ TFppkgNamedItem } + +constructor TFppkgNamedItem.Create; +begin + // +end; + +procedure TFppkgNamedItem.Save(Config: TConfigStorage); +begin + Config.SetValue('name', Name); +end; + +procedure TFppkgNamedItem.Load(Config: TConfigStorage); +begin + Name := Config.GetValue('name', ''); +end; + +{ TFppkgNamedItemList } + +function TFppkgNamedItemList.FindItemByName(AName: string): T; +var + i: Integer; +begin + Result := Nil; + for i := 0 to Count -1 do + begin + if SameText(Items[I].Name, AName) then + begin + Result := Items[I]; + Break; + end; + end; +end; + +procedure TFppkgNamedItemList.Load(Config: TConfigStorage); +var + Cnt: Integer; + i: Integer; + Item: T; +begin + Config.AppendBasePath('Items'); + try + Cnt := Config.GetValue('Count',0); + for i:=0 to Cnt-1 do + begin + Config.AppendBasePath('Item'+IntToStr(i+1)+'/'); + try + Item := T.Create; + Add(Item); + Item.Load(Config); + finally + Config.UndoAppendBasePath; + end; + end; + finally + Config.UndoAppendBasePath; + end; +end; + +procedure TFppkgNamedItemList.Save(Config: TConfigStorage); +var + i: Integer; +begin + if Count > 0 then + begin + Config.AppendBasePath('Items'); + try + Config.SetDeleteValue('Count', Count, 0); + for i:=0 to Count-1 do + begin + Config.AppendBasePath('Item'+IntToStr(i+1)+'/'); + try + Items[i].Save(Config); + finally + Config.UndoAppendBasePath; + end; + end; + finally + Config.UndoAppendBasePath; + end; + end; +end; + +{ TFppkgPackageVariantItem } + +constructor TFppkgPackageVariantItem.Create(); +begin + inherited Create(); + FCompilerOptions := TStringList.Create; + FPackageFiles := TStringList.Create; +end; + +destructor TFppkgPackageVariantItem.Destroy; +begin + FCompilerOptions.Free; + FPackageFiles.Free; + inherited Destroy; +end; + +procedure TFppkgPackageVariantItem.Save(Config: TConfigStorage); +begin + inherited; + Config.SetValue('CompilerOptions', CompilerOptions); + Config.SetValue('PackageFiles', PackageFiles); +end; + +procedure TFppkgPackageVariantItem.Load(Config: TConfigStorage); +begin + inherited; + Config.GetValue('CompilerOptions', CompilerOptions); + Config.GetValue('PackageFiles', PackageFiles); +end; + + +{ TFppkgPackageVariant } + +constructor TFppkgPackageVariant.Create; +begin + FItems := TFppkgPackageVariantItemList.Create(True); +end; + +destructor TFppkgPackageVariant.Destroy; +begin + FItems.Free; + inherited Destroy; +end; + +procedure TFppkgPackageVariant.Save(Config: TConfigStorage); +begin + Inherited; + FItems.Save(Config); +end; + +procedure TFppkgPackageVariant.Load(Config: TConfigStorage); +begin + inherited; + FItems.Load(Config); +end; + +end. + diff --git a/components/fppkg/src/fppkgpackagemanager.lpk b/components/fppkg/src/fppkgpackagemanager.lpk index 48d6915941..b2401c215c 100644 --- a/components/fppkg/src/fppkgpackagemanager.lpk +++ b/components/fppkg/src/fppkgpackagemanager.lpk @@ -19,7 +19,7 @@ - + @@ -64,32 +64,39 @@ - + - + + + + + - + - + - + + + + - + diff --git a/components/fppkg/src/fppkgpackagemanager.pas b/components/fppkg/src/fppkgpackagemanager.pas index 307307be80..5142ab88f3 100644 --- a/components/fppkg/src/fppkgpackagemanager.pas +++ b/components/fppkg/src/fppkgpackagemanager.pas @@ -10,7 +10,7 @@ interface uses lazfppkgmanagerintf, fppkg_const, fppkg_details, fppkg_mainfrm, fppkg_optionsfrm, laz_pkgrepos, FppkgWorkerThread, Fppkg_EnvironmentOptions, Fppkg_Interface, fppkg_packageoptionsfrm, - LazarusPackageIntf; + fppkg_packagevariant, LazarusPackageIntf; implementation diff --git a/components/ideintf/fppkgintf.pas b/components/ideintf/fppkgintf.pas index fc3520360a..fd74b294ca 100644 --- a/components/ideintf/fppkgintf.pas +++ b/components/ideintf/fppkgintf.pas @@ -6,7 +6,8 @@ interface uses Classes, - SysUtils; + SysUtils, + PackageIntf; type @@ -17,6 +18,9 @@ type function GetUseFPMakeWhenPossible: Boolean; virtual; abstract; function GetInstallFPMakeDependencies: Boolean; virtual; abstract; public + function ConstructFpMakeInterfaceSection(APackage: TIDEPackage): string; virtual; abstract; + function ConstructFpMakeImplementationSection(APackage: TIDEPackage): string; virtual; abstract; + function ConstructFpMakeDependenciesFileSection(APackage: TIDEPackage): string; virtual; abstract; property InstallFPMakeDependencies: Boolean read GetInstallFPMakeDependencies; property UseFPMakeWhenPossible: Boolean read GetUseFPMakeWhenPossible; end; diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index 8e1a3cdab9..7718bd263a 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -4878,6 +4878,10 @@ begin s:=s+' P : TPackage;'+e; s:=s+' T : TTarget;'+e; s:=s+''+e; + + if Assigned(FppkgInterface) then + s := s + FppkgInterface.ConstructFpMakeInterfaceSection(APackage); + s:=s+'begin'+e; s:=s+' with Installer do'+e; s:=s+' begin'+e; @@ -4901,23 +4905,31 @@ begin s := s + StringToFpmakeOptionGroup(' P.IncludePath.Add',IncPath); s := s + StringToFpmakeOptionGroup(' P.UnitPath.Add', UnitPath); + if Assigned(FppkgInterface) then + s := s + FppkgInterface.ConstructFpMakeImplementationSection(APackage); + s:=s+' T:=P.Targets.AddUnit('''+MainSrcFile+''');'+e; - for i := 0 to APackage.FileCount-1 do - if (APackage.Files[i].FileType=pftUnit) then - s:=s+' t.Dependencies.AddUnit('''+ExtractFileNameOnly(APackage.Files[i].Filename)+''');'+e; + if Assigned(FppkgInterface) then + s := s + FppkgInterface.ConstructFpMakeDependenciesFileSection(APackage) + else + begin + for i := 0 to APackage.FileCount-1 do + if (APackage.Files[i].FileType=pftUnit) then + s:=s+' t.Dependencies.AddUnit('''+ExtractFileNameOnly(APackage.Files[i].Filename)+''');'+e; - s:=s+''+e; + s:=s+''+e; - for i := 0 to APackage.FileCount-1 do - if (APackage.Files[i].FileType=pftUnit) then - begin - if (pffAddToPkgUsesSection in APackage.Files[i].Flags) then - s:=s+' T:=P.Targets.AddUnit('''+CreateRelativePath(APackage.Files[i].Filename,APackage.Directory)+''');'+e - else + for i := 0 to APackage.FileCount-1 do + if (APackage.Files[i].FileType=pftUnit) then begin - s:=s+' P.Targets.AddImplicitUnit('''+CreateRelativePath(APackage.Files[i].Filename,APackage.Directory)+''');'+e; + if (pffAddToPkgUsesSection in APackage.Files[i].Flags) then + s:=s+' T:=P.Targets.AddUnit('''+CreateRelativePath(APackage.Files[i].Filename,APackage.Directory)+''');'+e + else + begin + s:=s+' P.Targets.AddImplicitUnit('''+CreateRelativePath(APackage.Files[i].Filename,APackage.Directory)+''');'+e; + end; end; - end; + end; s:=s+''+e; s:=s+' // copy the compiled file, so the IDE knows how the package was compiled'+e;