diff --git a/converter/delphiproject2laz.pas b/converter/delphiproject2laz.pas index 08d2b82012..1db9a2d592 100644 --- a/converter/delphiproject2laz.pas +++ b/converter/delphiproject2laz.pas @@ -28,15 +28,14 @@ Author: Mattias Gaertner Abstract: - Functions to convert delphi projects to lazarus projects. + Functions to convert delphi projects/packages to lazarus projects/packages. - Converting a delphi project/unit to lazarus can be a very difficult task, - but also contains some monotone and boring work. These functions try to - help here. + The process of converting a delphi project/package/unit to lazarus contains + some monotone and boring work. These functions try to help here. Because any conversion step can fail and can need manual fix before continuing, the functions are written to recognize, what have been done. So, you can call the delphi conversion, abort at any step, fix a few things, - and invoke it again, till you have a working lazarus project. + and invoke it again. } unit DelphiProject2Laz; @@ -48,18 +47,14 @@ uses Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, FileProcs, FileUtil, ExprEval, DefineTemplates, CodeCache, CodeToolManager, CodeToolsStructs, LinkScanner, - SrcEditorIntf, MsgIntf, MainIntf, LazIDEIntf, ProjectIntf, + SrcEditorIntf, MsgIntf, MainIntf, LazIDEIntf, PackageIntf, ProjectIntf, IDEProcs, DelphiUnit2Laz, Project, DialogProcs, CheckLFMDlg, - EditorOptions, ProjectInspector, CompilerOptions, + EditorOptions, ProjectInspector, CompilerOptions, PackageDefs, BasePkgManager, PkgManager; const SettingDelphiModeTemplName = 'Setting Delphi Mode'; -function ConvertDelphiToLazarusProject(const ProjectFilename: string - ): TModalResult; -function FindAllDelphiProjectUnits(AProject: TProject): TModalResult; - type TConvertDelphiToLazarusUnitFlag = ( cdtlufRenameLowercase, // rename the unit lowercase @@ -69,21 +64,37 @@ type ); TConvertDelphiToLazarusUnitFlags = set of TConvertDelphiToLazarusUnitFlag; +// project +function ConvertDelphiToLazarusProject(const ProjectFilename: string + ): TModalResult; +function FindAllDelphiProjectUnits(AProject: TProject): TModalResult; function ConvertAllDelphiProjectUnits(AProject: TProject; Flags: TConvertDelphiToLazarusUnitFlags): TModalResult; + +// package +function ConvertDelphiToLazarusPackage(const PackageFilename: string + ): TModalResult; + +// unit function ConvertDelphiToLazarusUnit(const DelphiFilename: string; Flags: TConvertDelphiToLazarusUnitFlags): TModalResult; -function CreateDelphiToLazarusProject(const LPIFilename: string): TModalResult; +// project parts +function CreateDelphiToLazarusProjectInstance(const LPIFilename: string; + out AProject: TProject): TModalResult; function CreateDelphiToLazarusMainSourceFile(AProject: TProject; - const DPRFilename, MainSourceFilename: string; - out LPRCode: TCodeBuffer): TModalResult; + const DPRFilename, MainSourceFilename: string; + out LPRCode: TCodeBuffer): TModalResult; function FindDPRFilename(const StartFilename: string): string; function ReadDelphiProjectConfigFiles(AProject: TProject): TModalResult; procedure CleanUpProjectSearchPaths(AProject: TProject); procedure SetCompilerModeForProjectSrcDirs(AProject: TProject); procedure UnsetCompilerModeForProjectSrcDirs(AProject: TProject); +// package parts +function CreateDelphiToLazarusPackageInstance(const LPKFilename: string; + out APackage: TLazPackage): TModalResult; + implementation @@ -101,13 +112,14 @@ var DPRFilename: String; MainSourceFilename: String; ConvertUnitFlags: TConvertDelphiToLazarusUnitFlags; + AProject: TProject; begin debugln('ConvertDelphiToLazarusProject ProjectFilename="',ProjectFilename,'"'); IDEMessagesWindow.Clear; // create/open lazarus project file LPIFilename:=ChangeFileExt(ProjectFilename,'.lpi'); - Result:=CreateDelphiToLazarusProject(LPIFilename); + Result:=CreateDelphiToLazarusProjectInstance(LPIFilename,AProject); if Result<>mrOk then begin DebugLn('ConvertDelphiToLazarusProject failed to create/open project LPIFilename="',LPIFilename,'"'); exit; @@ -117,30 +129,30 @@ begin DPRFilename:=FindDPRFilename(ProjectFilename); DebugLn('ConvertDelphiToLazarusProject DPRFilename="',DPRFilename,'"'); MainSourceFilename:=ChangeFileExt(LPIFilename,'.lpr'); - Result:=CreateDelphiToLazarusMainSourceFile(Project1,DPRFilename, + Result:=CreateDelphiToLazarusMainSourceFile(AProject,DPRFilename, MainSourceFilename,LPRCode); if Result<>mrOk then exit; // read config files (they often contain clues about paths, switches and defines) - Result:=ReadDelphiProjectConfigFiles(Project1); + Result:=ReadDelphiProjectConfigFiles(AProject); if Result<>mrOk then begin DebugLn('ConvertDelphiToLazarusProject failed reading Delphi configs'); exit; end; // clean up project - Project1.RemoveNonExistingFiles(false); - CleanUpProjectSearchPaths(Project1); + AProject.RemoveNonExistingFiles(false); + CleanUpProjectSearchPaths(AProject); // load required packages - Project1.AddPackageDependency('LCL');// Nearly all Delphi projects require it - PkgBoss.AddDefaultDependencies(Project1); + AProject.AddPackageDependency('LCL');// Nearly all Delphi projects require it + PkgBoss.AddDefaultDependencies(AProject); // we have now enough information to parse the .dpr file, // but not enough to parse the units // set Delphi mode for all project source directories - SetCompilerModeForProjectSrcDirs(Project1); + SetCompilerModeForProjectSrcDirs(AProject); try // init codetools @@ -159,18 +171,18 @@ begin end; // get all options from .lpr (the former .dpr) - Result:=ExtractOptionsFromDPR(LPRCode,Project1); + Result:=ExtractOptionsFromDPR(LPRCode,AProject); if Result<>mrOk then exit; // find and convert all project files - Result:=FindAllDelphiProjectUnits(Project1); + Result:=FindAllDelphiProjectUnits(AProject); if Result<>mrOk then exit; // convert all project files - Result:=ConvertAllDelphiProjectUnits(Project1,[cdtlufIsSubProc,cdtlufCheckLFM]); + Result:=ConvertAllDelphiProjectUnits(AProject,[cdtlufIsSubProc,cdtlufCheckLFM]); if Result<>mrOk then exit; finally - UnsetCompilerModeForProjectSrcDirs(Project1); + UnsetCompilerModeForProjectSrcDirs(AProject); end; debugln('ConvertDelphiToLazarusProject Done'); @@ -226,19 +238,19 @@ begin CurFilename:=copy(CurFilename,p+4,length(CurFilename)); if CurFilename='' then continue; if not FilenameIsAbsolute(CurFilename) then - CurFilename:=AppendPathDelim(Project1.ProjectDirectory)+CurFilename; + CurFilename:=AppendPathDelim(AProject.ProjectDirectory)+CurFilename; CurFilename:=TrimFilename(CurFilename); if not FileExists(CurFilename) then begin DebugLn('ConvertDelphiToLazarusProject file not found: "',CurFilename,'"'); continue; end; - CurUnitInfo:=Project1.UnitInfoWithFilename(CurFilename); + CurUnitInfo:=AProject.UnitInfoWithFilename(CurFilename); if CurUnitInfo<>nil then begin CurUnitInfo.IsPartOfProject:=true; end else begin if FilenameIsPascalUnit(CurFilename) then begin // check unitname - OffendingUnit:=Project1.UnitWithUnitname( + OffendingUnit:=AProject.UnitWithUnitname( ExtractFileNameOnly(CurFilename)); if OffendingUnit<>nil then begin Result:=QuestionDlg('Unitname exists twice', @@ -262,31 +274,31 @@ begin CurUnitInfo:=TUnitInfo.Create(nil); CurUnitInfo.Filename:=CurFilename; CurUnitInfo.IsPartOfProject:=true; - Project1.AddFile(CurUnitInfo,false); + AProject.AddFile(CurUnitInfo,false); end; end; finally // set unit paths to find all project units - NewSearchPath:=MergeSearchPaths(Project1.CompilerOptions.OtherUnitFiles, - Project1.SourceDirectories.CreateSearchPathFromAllFiles); + NewSearchPath:=MergeSearchPaths(AProject.CompilerOptions.OtherUnitFiles, + AProject.SourceDirectories.CreateSearchPathFromAllFiles); NewSearchPath:=RemoveSearchPaths(NewSearchPath, '.;'+VirtualDirectory+';'+VirtualTempDir - +';'+Project1.ProjectDirectory); - Project1.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath( - RemoveNonExistingPaths(NewSearchPath,Project1.ProjectDirectory)); + +';'+AProject.ProjectDirectory); + AProject.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath( + RemoveNonExistingPaths(NewSearchPath,AProject.ProjectDirectory)); // set include path - NewSearchPath:=MergeSearchPaths(Project1.CompilerOptions.IncludeFiles, - Project1.SourceDirectories.CreateSearchPathFromAllFiles); + NewSearchPath:=MergeSearchPaths(AProject.CompilerOptions.IncludeFiles, + AProject.SourceDirectories.CreateSearchPathFromAllFiles); NewSearchPath:=RemoveSearchPaths(NewSearchPath, '.;'+VirtualDirectory+';'+VirtualTempDir - +';'+Project1.ProjectDirectory); - Project1.CompilerOptions.IncludeFiles:=MinimizeSearchPath( - RemoveNonExistingPaths(NewSearchPath,Project1.ProjectDirectory)); + +';'+AProject.ProjectDirectory); + AProject.CompilerOptions.IncludeFiles:=MinimizeSearchPath( + RemoveNonExistingPaths(NewSearchPath,AProject.ProjectDirectory)); // clear caches - Project1.DefineTemplates.SourceDirectoriesChanged; + AProject.DefineTemplates.SourceDirectoriesChanged; CodeToolBoss.DefineTree.ClearCache; - DebugLn('ConvertDelphiToLazarusProject UnitPath="',Project1.CompilerOptions.OtherUnitFiles,'"'); + DebugLn('ConvertDelphiToLazarusProject UnitPath="',AProject.CompilerOptions.OtherUnitFiles,'"'); end; // save project @@ -316,8 +328,8 @@ function ConvertAllDelphiProjectUnits(AProject: TProject; begin // convert all units i:=0; - while imrOk then begin + DebugLn('ConvertDelphiToLazarusPackage failed to create/open package LPKFilename="',LPKFilename,'"'); + exit; + end; + + Result:=mrOk; +end; + function ConvertDelphiToLazarusUnit(const DelphiFilename: string; Flags: TConvertDelphiToLazarusUnitFlags): TModalResult; var @@ -467,29 +499,33 @@ begin Result:=mrOk; end; -function CreateDelphiToLazarusProject(const LPIFilename: string): TModalResult; +function CreateDelphiToLazarusProjectInstance(const LPIFilename: string; + out AProject: TProject): TModalResult; // If .lpi does not exist, create it // open new project begin - DebugLn('CreateDelphiToLazarusProject LPIFilename="',LPIFilename,'"'); + DebugLn('CreateDelphiToLazarusProjectInstance LPIFilename="',LPIFilename,'"'); + AProject:=Project1; if FileExists(LPIFilename) then begin // there is already a lazarus project -> open it, if not already open - if CompareFilenames(Project1.ProjectInfoFile,LPIFilename)<>0 then begin + if CompareFilenames(AProject.ProjectInfoFile,LPIFilename)<>0 then begin DebugLn('CreateDelphiToLazarusProject open "',LPIFilename,'"'); Result:=LazarusIDE.DoOpenProjectFile(LPIFilename,[]); + AProject:=Project1; if Result<>mrOk then exit; end; end else begin // create a new lazarus project Result:=LazarusIDE.DoNewProject(ProjectDescriptorEmptyProject); + AProject:=Project1; if Result<>mrOk then begin - DebugLn('CreateDelphiToLazarusProject failed to create a new project'); + DebugLn('CreateDelphiToLazarusProjectInstance failed to create a new project'); exit; end; - Project1.ProjectInfoFile:=LPIFilename; + AProject.ProjectInfoFile:=LPIFilename; end; // save to disk (this makes sure, all editor changes are saved too) - DebugLn('CreateDelphiToLazarusProject saving project ...'); + DebugLn('CreateDelphiToLazarusProjectInstance saving project ...'); Result:=LazarusIDE.DoSaveProject([]); end; @@ -597,5 +633,30 @@ begin CodeToolBoss.DefineTree.ClearCache; end; +function CreateDelphiToLazarusPackageInstance(const LPKFilename: string; out + APackage: TLazPackage): TModalResult; +// If .lpk does not exist, create it +// open new package +begin + DebugLn('CreateDelphiToLazarusPackageInstance LPKFilename="',LPKFilename,'"'); + APackage:=nil; + if FileExists(LPKFilename) then begin + // there is already a lazarus package file + // open the package editor + Result:=PackageEditingInterface.DoOpenPackageFile(LPKFilename,[pofAddToRecent]); + // TODO: get package + Result:=mrAbort; + if Result<>mrOk then exit; + end else begin + // create a new lazarus package + // TODO: get package + Result:=mrAbort; + if Result<>mrOk then exit; + end; + // save to disk (this makes sure, all editor changes are saved too) + DebugLn('CreateDelphiToLazarusProject saving project ...'); + Result:=PackageEditingInterface.DoSaveAllPackages([]); +end; + end. diff --git a/ide/inputhistory.pas b/ide/inputhistory.pas index 9054113dc9..653b3c72ac 100644 --- a/ide/inputhistory.pas +++ b/ide/inputhistory.pas @@ -168,6 +168,7 @@ type // Find- and replace-history FFindHistory: TStringList; FFindInFilesSearchOptions: TLazFindInFileSearchOptions; + FLastConvertDelphiPackage: string; FLastConvertDelphiProject: string; FLastConvertDelphiUnit: string; FReplaceHistory: TStringList; @@ -251,6 +252,8 @@ type // Delphi conversion property LastConvertDelphiProject: string read FLastConvertDelphiProject write FLastConvertDelphiProject; + property LastConvertDelphiPackage: string read FLastConvertDelphiPackage + write FLastConvertDelphiPackage; property LastConvertDelphiUnit: string read FLastConvertDelphiUnit write FLastConvertDelphiUnit; end; @@ -403,6 +406,7 @@ begin // delphi conversion FLastConvertDelphiProject:=XMLConfig.GetValue(Path+'Conversion/Delphi/Project',''); + FLastConvertDelphiPackage:=XMLConfig.GetValue(Path+'Conversion/Delphi/Package',''); FLastConvertDelphiUnit:=XMLConfig.GetValue(Path+'Conversion/Delphi/Unit',''); end; @@ -454,6 +458,8 @@ begin // delphi conversion XMLConfig.SetDeleteValue(Path+'Conversion/Delphi/Project', FLastConvertDelphiProject,''); + XMLConfig.SetDeleteValue(Path+'Conversion/Delphi/Package', + FLastConvertDelphiPackage,''); XMLConfig.SetDeleteValue(Path+'Conversion/Delphi/Unit', FLastConvertDelphiUnit,''); end; diff --git a/ide/keymapping.pp b/ide/keymapping.pp index 83cdf5b9c0..9dfdb24a94 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -404,6 +404,7 @@ begin ecCheckLFM: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); + ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); ecFindProcedureDefinition: SetResult(VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[]); ecFindProcedureMethod: SetResult(VK_DOWN,[ssShift,SSCtrl],VK_UNKNOWN,[]); ecFindDeclaration: SetResult(VK_UP,[ssAlt],VK_UNKNOWN,[]); @@ -713,6 +714,7 @@ begin ecCheckLFM: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); + ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); ecFindProcedureDefinition: SetResult(VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); ecFindProcedureMethod: SetResult(VK_DOWN,[ssShift,SSCtrl],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); ecFindDeclaration: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]); @@ -1335,6 +1337,7 @@ begin ecCheckLFM : Result:= lisMenuCheckLFM; ecConvertDelphiUnit : Result:= lisMenuConvertDelphiUnit; ecConvertDelphiProject : Result:= lisMenuConvertDelphiProject; + ecConvertDelphiPackage : Result:= lisMenuConvertDelphiPackage; ecFindDeclaration : Result:= srkmecFindDeclaration; ecFindBlockOtherEnd : Result:= srkmecFindBlockOtherEnd; ecFindBlockStart : Result:= srkmecFindBlockStart; @@ -2313,6 +2316,7 @@ begin AddDefault(C,'Convert DFM file to LFM',ecConvertDFM2LFM); AddDefault(C,'Convert Delphi unit to Lazarus unit',ecConvertDelphiUnit); AddDefault(C,'Convert Delphi project to Lazarus project',ecConvertDelphiProject); + AddDefault(C,'Convert Delphi package to Lazarus package',ecConvertDelphiPackage); // environment menu C:=Categories[AddCategory('EnvironmentMenu',srkmCatEnvMenu,nil)]; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 57e39d587f..18fb6821f1 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -280,7 +280,8 @@ resourcestring lisMenuConvertDFMtoLFM = 'Convert DFM file to LFM'; lisMenuCheckLFM = 'Check LFM file in editor'; lisMenuConvertDelphiUnit = 'Convert Delphi unit to Lazarus unit'; - lisMenuConvertDelphiProject = 'Convert Delphi Project to Lazarus Project'; + lisMenuConvertDelphiProject = 'Convert Delphi project to Lazarus project'; + lisMenuConvertDelphiPackage = 'Convert Delphi package to Lazarus package'; lisMenuBuildLazarus = 'Build Lazarus'; lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus"'; @@ -312,6 +313,7 @@ resourcestring lisCompilerOptionsForProject = 'Compiler Options for Project: %s'; lisChooseDelphiUnit = 'Choose Delphi unit (*.pas)'; lisChooseDelphiProject = 'Choose Delphi project (*.dpr)'; + lisChooseDelphiPackage = 'Choose Delphi package (*.dpk)'; lisDelphiProject = 'Delphi project'; lisUnableToReadFileError = 'Unable to read file %s%s%s%sError: %s'; lisFormatError = 'Format error'; diff --git a/ide/main.pp b/ide/main.pp index 6fa77345f7..c44c370c49 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -266,6 +266,7 @@ type procedure mnuToolCheckLFMClicked(Sender: TObject); procedure mnuToolConvertDelphiUnitClicked(Sender: TObject); procedure mnuToolConvertDelphiProjectClicked(Sender: TObject); + procedure mnuToolConvertDelphiPackageClicked(Sender: TObject); procedure mnuToolBuildLazarusClicked(Sender: TObject); procedure mnuToolConfigBuildLazClicked(Sender: TObject); procedure mnuCustomExtToolClick(Sender: TObject); @@ -669,6 +670,7 @@ type function DoCheckLFMInEditor: TModalResult; function DoConvertDelphiUnit(const DelphiFilename: string): TModalResult; function DoConvertDelphiProject(const DelphiFilename: string): TModalResult; + function DoConvertDelphiPackage(const DelphiFilename: string): TModalResult; procedure UpdateCustomToolsInMenu; // external tools @@ -2043,6 +2045,7 @@ begin itmToolConvertDFMtoLFM.OnClick := @mnuToolConvertDFMtoLFMClicked; itmToolConvertDelphiUnit.OnClick := @mnuToolConvertDelphiUnitClicked; itmToolConvertDelphiProject.OnClick := @mnuToolConvertDelphiProjectClicked; + itmToolConvertDelphiPackage.OnClick := @mnuToolConvertDelphiPackageClicked; itmToolBuildLazarus.OnClick := @mnuToolBuildLazarusClicked; itmToolConfigureBuildLazarus.OnClick := @mnuToolConfigBuildLazClicked; end; @@ -3229,8 +3232,6 @@ var OpenDialog: TOpenDialog; AFilename: string; begin - //MessageDlg('ConvertDelphiProject','Under construction',mtInformation,[mbCancel],0); exit; - OpenDialog:=TOpenDialog.Create(nil); try InputHistories.ApplyFileDialogSettings(OpenDialog); @@ -3245,7 +3246,6 @@ begin end; if OpenDialog.Execute then begin AFilename:=CleanAndExpandFilename(OpenDialog.Filename); - //debugln('TMainIDE.mnuToolConvertDelphiProjectClicked A ',AFilename); if FileExists(AFilename) then DoConvertDelphiProject(AFilename); UpdateEnvironment; @@ -3256,6 +3256,43 @@ begin end; end; +procedure TMainIDE.mnuToolConvertDelphiPackageClicked(Sender: TObject); + + procedure UpdateEnvironment; + begin + SetRecentFilesMenu; + SaveEnvironment; + end; + +var + OpenDialog: TOpenDialog; + AFilename: string; +begin + OpenDialog:=TOpenDialog.Create(nil); + try + InputHistories.ApplyFileDialogSettings(OpenDialog); + OpenDialog.Title:=lisChooseDelphiPackage; + OpenDialog.Filter:=lisDelphiProject+' (*.dpk)|*.dpk|'+dlgAllFiles+' (*.*)|*' + +'.*'; + if InputHistories.LastConvertDelphiPackage<>'' then begin + OpenDialog.InitialDir:= + ExtractFilePath(InputHistories.LastConvertDelphiPackage); + OpenDialog.Filename:= + ExtractFileName(InputHistories.LastConvertDelphiPackage); + end; + if OpenDialog.Execute then begin + AFilename:=CleanAndExpandFilename(OpenDialog.Filename); + //debugln('TMainIDE.mnuToolConvertDelphiProjectClicked A ',AFilename); + if FileExists(AFilename) then + DoConvertDelphiPackage(AFilename); + UpdateEnvironment; + end; + InputHistories.StoreFileDialogSettings(OpenDialog); + finally + OpenDialog.Free; + end; +end; + procedure TMainIDE.mnuToolBuildLazarusClicked(Sender: TObject); begin if MiscellaneousOptions.BuildLazOpts.ConfirmBuild then @@ -8159,6 +8196,21 @@ begin end; end; +function TMainIDE.DoConvertDelphiPackage(const DelphiFilename: string + ): TModalResult; +var + OldChange: Boolean; +begin + InputHistories.LastConvertDelphiPackage:=DelphiFilename; + OldChange:=FOpenEditorsOnCodeToolChange; + FOpenEditorsOnCodeToolChange:=true; + try + Result:=DelphiProject2Laz.ConvertDelphiToLazarusPackage(DelphiFilename); + finally + FOpenEditorsOnCodeToolChange:=OldChange; + end; +end; + {------------------------------------------------------------------------------- procedure TMainIDE.UpdateCustomToolsInMenu; diff --git a/ide/mainbar.pas b/ide/mainbar.pas index ecce502f46..bec3a77c11 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -280,6 +280,7 @@ type itmToolCheckLFM: TIDEMenuCommand; itmToolConvertDelphiUnit: TIDEMenuCommand; itmToolConvertDelphiProject: TIDEMenuCommand; + itmToolConvertDelphiPackage: TIDEMenuCommand; itmToolConvertDFMtoLFM: TIDEMenuCommand; //itmBuildingLazarus: TIDEMenuSection; itmToolBuildLazarus: TIDEMenuCommand; diff --git a/ide/mainbase.pas b/ide/mainbase.pas index 0da6d239f5..e1022aa103 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -704,6 +704,7 @@ begin CreateMenuItem(ParentMI,itmToolCheckLFM,'itmToolCheckLFM',lisMenuCheckLFM); CreateMenuItem(ParentMI,itmToolConvertDelphiUnit,'itmToolConvertDelphiUnit',lisMenuConvertDelphiUnit); CreateMenuItem(ParentMI,itmToolConvertDelphiProject,'itmToolConvertDelphiProject',lisMenuConvertDelphiProject); + CreateMenuItem(ParentMI,itmToolConvertDelphiPackage,'itmToolConvertDelphiPackage',lisMenuConvertDelphiPackage); CreateMenuItem(ParentMI,itmToolConvertDFMtoLFM,'itmToolConvertDFMtoLFM',lisMenuConvertDFMtoLFM); CreateMenuSeparatorSection(mnuTools,itmBuildingLazarus,'itmBuildingLazarus'); @@ -927,6 +928,7 @@ begin itmToolCheckLFM.Command:=GetCommand(ecCheckLFM); itmToolConvertDelphiUnit.Command:=GetCommand(ecConvertDelphiUnit); itmToolConvertDelphiProject.Command:=GetCommand(ecConvertDelphiProject); + itmToolConvertDelphiPackage.Command:=GetCommand(ecConvertDelphiPackage); itmToolBuildLazarus.Command:=GetCommand(ecBuildLazarus); itmToolConfigureBuildLazarus.Command:=GetCommand(ecConfigBuildLazarus); diff --git a/ideintf/idecommands.pas b/ideintf/idecommands.pas index 92237eba35..71069cf834 100644 --- a/ideintf/idecommands.pas +++ b/ideintf/idecommands.pas @@ -128,13 +128,14 @@ const ecCheckLFM = ecFirstLazarus + 107; ecConvertDelphiUnit = ecFirstLazarus + 108; ecConvertDelphiProject = ecFirstLazarus + 109; - ecMakeResourceString = ecFirstLazarus + 110; - ecDiff = ecFirstLazarus + 111; - ecExtractProc = ecFirstLazarus + 112; - ecFindIdentifierRefs = ecFirstLazarus + 113; - ecRenameIdentifier = ecFirstLazarus + 114; - ecInvertAssignment = ecFirstLazarus + 115; - ecShowCodeContext = ecFirstLazarus + 116; + ecConvertDelphiPackage = ecFirstLazarus + 110; + ecMakeResourceString = ecFirstLazarus + 111; + ecDiff = ecFirstLazarus + 112; + ecExtractProc = ecFirstLazarus + 113; + ecFindIdentifierRefs = ecFirstLazarus + 114; + ecRenameIdentifier = ecFirstLazarus + 115; + ecInvertAssignment = ecFirstLazarus + 116; + ecShowCodeContext = ecFirstLazarus + 117; // file menu ecNew = ecFirstLazarus + 201; diff --git a/ideintf/packageintf.pas b/ideintf/packageintf.pas index 4d145076fb..c9620ac875 100644 --- a/ideintf/packageintf.pas +++ b/ideintf/packageintf.pas @@ -30,10 +30,37 @@ const PkgDescNameStandard = 'Standard Package'; type + TPkgSaveFlag = ( + psfSaveAs, + psfAskBeforeSaving + ); + TPkgSaveFlags = set of TPkgSaveFlag; + + TPkgOpenFlag = ( + pofAddToRecent, + pofRevert + ); + TPkgOpenFlags = set of TPkgOpenFlag; + + TPkgCompileFlag = ( + pcfCleanCompile, // append -B to the compiler options + pcfDoNotCompileDependencies, + pcfDoNotCompilePackage, + pcfCompileDependenciesClean, + pcfOnlyIfNeeded, + pcfDoNotSaveEditorFiles, + pcfCreateMakefile + ); + TPkgCompileFlags = set of TPkgCompileFlag; + { TPackageEditingInterface } TPackageEditingInterface = class(TComponent) public + function DoOpenPackageFile(AFilename: string; + Flags: TPkgOpenFlags): TModalResult; virtual; abstract; + function DoSaveAllPackages(Flags: TPkgSaveFlags): TModalResult; virtual; abstract; + function AddUnitDependenciesForComponentClasses(const UnitFilename: string; ComponentClassnames: TStrings): TModalResult; virtual; abstract; function GetOwnersOfUnit(const UnitFilename: string): TList; virtual; abstract; diff --git a/packager/basepkgmanager.pas b/packager/basepkgmanager.pas index f7ea899470..4cad8cda05 100644 --- a/packager/basepkgmanager.pas +++ b/packager/basepkgmanager.pas @@ -48,29 +48,6 @@ uses PackageDefs, ComponentReg, CompilerOptions, Project, PackageIntf, MenuIntf; type - TPkgSaveFlag = ( - psfSaveAs, - psfAskBeforeSaving - ); - TPkgSaveFlags = set of TPkgSaveFlag; - - TPkgOpenFlag = ( - pofAddToRecent, - pofRevert - ); - TPkgOpenFlags = set of TPkgOpenFlag; - - TPkgCompileFlag = ( - pcfCleanCompile, // append -B to the compiler options - pcfDoNotCompileDependencies, - pcfDoNotCompilePackage, - pcfCompileDependenciesClean, - pcfOnlyIfNeeded, - pcfDoNotSaveEditorFiles, - pcfCreateMakefile - ); - TPkgCompileFlags = set of TPkgCompileFlag; - { TBasePkgManager } TBasePkgManager = class(TPackageEditingInterface) @@ -119,11 +96,8 @@ type // package editors function DoNewPackage: TModalResult; virtual; abstract; function DoOpenPackage(APackage: TLazPackage): TModalResult; virtual; abstract; - function DoOpenPackageFile(AFilename: string; - Flags: TPkgOpenFlags): TModalResult; virtual; abstract; function DoSavePackage(APackage: TLazPackage; Flags: TPkgSaveFlags): TModalResult; virtual; abstract; - function DoSaveAllPackages(Flags: TPkgSaveFlags): TModalResult; virtual; abstract; function DoClosePackageEditor(APackage: TLazPackage): TModalResult; virtual; abstract; function DoCloseAllPackageEditors: TModalResult; virtual; abstract;