From 76a5a3cd5d6a5e87e4fa1bfa3b53757cdaf4532b Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 9 Jan 2018 11:08:04 +0000 Subject: [PATCH] IDEIntf: added ConsoleVerbosity, pas2js: less hints, fixed getting compiler options, fixed uninitialized result git-svn-id: trunk@57023 - --- components/ideintf/macrointf.pas | 3 ++ components/pas2js/pjscontroller.pp | 47 ++++++++++++++++++-------- components/pas2js/pjsdsgnregister.pas | 4 +-- components/pas2js/pjsprojectoptions.pp | 6 ++-- ide/compiler.pp | 2 +- ide/idecmdline.pas | 3 -- ide/ideguicmdline.pas | 2 +- ide/ideprocs.pp | 3 +- ide/sourceeditor.pp | 17 +++++----- packager/packagesystem.pas | 2 +- 10 files changed, 54 insertions(+), 35 deletions(-) diff --git a/components/ideintf/macrointf.pas b/components/ideintf/macrointf.pas index 8082278c81..23a9679360 100644 --- a/components/ideintf/macrointf.pas +++ b/components/ideintf/macrointf.pas @@ -42,6 +42,9 @@ var // the global IDE values IDEMacros: TIDEMacros = nil; // set by the IDE +var + ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose + procedure RenameIDEMacroInString(var s: string; const OldName, NewName: string); implementation diff --git a/components/pas2js/pjscontroller.pp b/components/pas2js/pjscontroller.pp index 7def06e679..43992287ba 100644 --- a/components/pas2js/pjscontroller.pp +++ b/components/pas2js/pjscontroller.pp @@ -5,7 +5,8 @@ unit pjscontroller; interface uses - Classes, SysUtils, MacroIntf, MacroDefIntf, forms, lazideintf, lazlogger, process ; + Classes, SysUtils, MacroIntf, MacroDefIntf, forms, Controls, lazideintf, + lazlogger, process ; Type @@ -51,9 +52,9 @@ Type Private FOnRefresh: TNotifyEvent; FServerInstances: TServerInstanceList; - function GetPasJSBrowser(const s: string; const Data: PtrInt; var Abort: boolean): string; - function GetPasJSNodeJS(const s: string; const Data: PtrInt; var Abort: boolean): string; - function GetProjectURL(const s: string; const Data: PtrInt; var Abort: boolean): string; + function GetPasJSBrowser(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; + function GetPasJSNodeJS(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; + function GetProjectURL(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; function MaybeStartServer(Sender: TObject; var Handled: boolean): TModalResult; Public Constructor Create; @@ -150,7 +151,8 @@ begin {$IFDEF WINDOWS} FProcess.Options:=[poNoConsole]; {$ENDIF} - DebugLN(['Starting server from Directory : ',BaseDir]); + if ConsoleVerbosity>=0 then + DebugLN(['Starting server from Directory : ',BaseDir]); FProcess.CurrentDirectory:=BaseDir; try FProcess.Execute; @@ -197,6 +199,8 @@ begin IdeMacros.SubstituteMacros(Result); if (Result<>'') and not FilenameIsAbsolute(Result) then Result:=FindDefaultExecutablePath(Result); + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetPasJSBrowser] ignoring macro Pas2JSBrowser parameter "',s,'"']); end; function TPJSController.GetPasJSNodeJS(const s: string; const Data: PtrInt; var Abort: boolean): string; @@ -209,6 +213,8 @@ begin IdeMacros.SubstituteMacros(Result); if (Result<>'') and not FilenameIsAbsolute(Result) then Result:=FindDefaultExecutablePath(Result); + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetPasJSNodeJS] ignoring macro Pas2JSNodeJS parameter "',s,'"']); end; function TPJSController.GetProjectURL(const s: string; const Data: PtrInt; var Abort: boolean): string; @@ -217,16 +223,22 @@ Var FN : String; begin - DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]]); + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetProjectURL] ignoring macro Pas2JSProjectURL parameter "',s,'"']); + + if ConsoleVerbosity>0 then + DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]]); Abort:=LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]<>'1'; if Abort then exit; - DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectURL]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectURL]]); + if ConsoleVerbosity>0 then + DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectURL]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectURL]]); Result:=LazarusIDE.ActiveProject.CustomData[PJSProjectURL]; if (Result='') then begin FN:=LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]; - DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]]); + if ConsoleVerbosity>0 then + DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]]); if (FN='') then FN:=ChangeFileExt(ExtractFileName(LazarusIDE.ActiveProject.ProjectInfoFile),'.html'); Result:=LazarusIDE.ActiveProject.CustomData[PJSProjectPort]; @@ -240,7 +252,8 @@ begin {$ENDIF} end; Abort:=(Result=''); - DebugLN(['GetProjectURL : ',Result]); + if ConsoleVerbosity>0 then + DebugLN(['GetProjectURL : ',Result]); end; function TPJSController.MaybeStartServer(Sender: TObject; var Handled: boolean): TModalResult; @@ -252,11 +265,15 @@ Var aInstance : TServerInstance; begin + Result:=mrOK; With LazarusIDE.ActiveProject do begin - DebugLn(['WebProject:=',CustomData[PJSProjectWebBrowser]]); - DebugLn(['ServerPort:=',CustomData[PJSProjectPort]]); - DebugLn(['BaseDir:=',ProjectInfoFile]); + if ConsoleVerbosity>=0 then + begin + DebugLn(['WebProject=',CustomData[PJSProjectWebBrowser]]); + DebugLn(['ServerPort=',CustomData[PJSProjectPort]]); + DebugLn(['BaseDir=',ProjectInfoFile]); + end; WebProject:=CustomData[PJSProjectWebBrowser]='1'; ServerPort:=StrToIntDef(CustomData[PJSProjectPort],0); BaseDir:=ExtractFilePath(ProjectInfoFile); @@ -267,10 +284,12 @@ begin aInstance:=ServerInstances.FindByPort(ServerPort); If Ainstance<>Nil then begin - Writeln('Have instance running on port ',ServerPort); + if ConsoleVerbosity>=0 then + Writeln('Have instance running on port ',ServerPort); if Not SameFileName(BaseDir,aInstance.BaseDir) then begin - Writeln('Instance on port ',ServerPort,' serves different directory: ',aInstance.BaseDir); + if ConsoleVerbosity>=0 then + Writeln('Instance on port ',ServerPort,' serves different directory: ',aInstance.BaseDir); // We should ask the user what to do ? If aInstance.Running then aInstance.StopServer; diff --git a/components/pas2js/pjsdsgnregister.pas b/components/pas2js/pjsdsgnregister.pas index 7748e34a03..7e3b14eab5 100644 --- a/components/pas2js/pjsdsgnregister.pas +++ b/components/pas2js/pjsdsgnregister.pas @@ -240,9 +240,6 @@ function TProjectPas2JSNodeJSApp.InitProject(AProject: TLazProject ): TModalResu var MainFile : TLazProjectFile; CompOpts : TLazCompilerOptions; - RunParams : TAbstractRunParamsOptionsMode; - Compiler : String; - begin Result:=inherited InitProject(AProject); @@ -250,6 +247,7 @@ begin MainFile.IsPartOfProject:=true; AProject.AddFile(MainFile,false); AProject.MainFileID:=0; + CompOpts:=AProject.LazBuildModes.BuildModes[0].LazCompilerOptions; CompOpts.TargetFilename:='project1'; SetDefaultNodeJSCompileOptions(AProject.LazCompilerOptions); diff --git a/components/pas2js/pjsprojectoptions.pp b/components/pas2js/pjsprojectoptions.pp index 9702630277..0ff0037b8a 100644 --- a/components/pas2js/pjsprojectoptions.pp +++ b/components/pas2js/pjsprojectoptions.pp @@ -143,8 +143,6 @@ procedure TPas2JSProjectOptionsFrame.BResetRunCommandClick(Sender: TObject); Var Prj : TLazProject; - RP : TAbstractRunParamsOptionsMode; - begin PRJ:=LazarusIDE.ActiveProject; SetDefaultWebRunParams(Prj.RunParameters.GetOrCreate('Default')); @@ -205,7 +203,7 @@ end; Function TPas2JSProjectOptionsFrame.FillFilesCombo(PRJ : TLazProject) : Integer; Var - I,H : integer; + I: integer; HPF,PF : TLazProjectFile; Ext : String; L : TStringList; @@ -245,6 +243,7 @@ Var URL : String; begin + if AOptions=nil then ; PRJ:=LazarusIDE.ActiveProject; HTMLIdx:=FillFilesCombo(PRJ); CBWebProject.Checked:=PRJ.CustomData[PJSProjectWebBrowser]='1'; @@ -277,6 +276,7 @@ Var end; begin + if AOptions=nil then ; PRJ:=LazarusIDE.ActiveProject; // Clear everything With PRJ.CustomData do diff --git a/ide/compiler.pp b/ide/compiler.pp index 2027f69fe8..8c830675ef 100644 --- a/ide/compiler.pp +++ b/ide/compiler.pp @@ -39,7 +39,7 @@ interface uses Classes, SysUtils, LCLProc, Forms, Controls, contnrs, strutils, - IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, LazUTF8, + IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, MacroIntf, LazUTF8, IDECmdLine, LazarusIDEStrConsts, CompilerOptions, Project, DefineTemplates, TransferMacros, EnvironmentOpts, LazFileUtils; diff --git a/ide/idecmdline.pas b/ide/idecmdline.pas index c9ff4b6b36..c89c9b22b0 100644 --- a/ide/idecmdline.pas +++ b/ide/idecmdline.pas @@ -86,9 +86,6 @@ function ParamsAndCfgCount: Integer; function ParamsAndCfgStr(Idx: Integer): String; procedure ResetParamsAndCfg; -var - ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose - implementation var diff --git a/ide/ideguicmdline.pas b/ide/ideguicmdline.pas index 718368109c..c684550d2a 100644 --- a/ide/ideguicmdline.pas +++ b/ide/ideguicmdline.pas @@ -41,7 +41,7 @@ interface uses Classes, SysUtils, math, lazutf8classes, LazConf, LCLProc, - FileProcs, LazFileUtils, IDECmdLine; + FileProcs, LazFileUtils, MacroIntf, IDECmdLine; procedure ParseGuiCmdLineParams(var SkipAutoLoadingLastProject, StartedByStartLazarus, diff --git a/ide/ideprocs.pp b/ide/ideprocs.pp index ffdcdbe21e..6e402edc41 100644 --- a/ide/ideprocs.pp +++ b/ide/ideprocs.pp @@ -35,7 +35,8 @@ uses // CodeTools BasicCodeTools, SourceLog, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache, // LazUtils - FileUtil, LazFileUtils, LazFileCache, LazUTF8, lazutf8classes, Laz2_XMLCfg, AvgLvlTree, + FileUtil, LazFileUtils, LazFileCache, LazUTF8, lazutf8classes, Laz2_XMLCfg, + AvgLvlTree, MacroIntf, // IDE IDECmdLine, LazConf; diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 40ccf01d5d..f700fef074 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -71,14 +71,15 @@ uses // DebuggerIntf DbgIntfBaseTypes, DbgIntfDebuggerBase, // IDE units - IDECmdLine, LazarusIDEStrConsts, IDECommands, EditorOptions, EnvironmentOpts, - WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs, IDEHelpManager, - MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm, etMessagesWnd, - etSrcEditMarks, CodeMacroPrompt, CodeTemplatesDlg, CodeToolsOptions, - editor_general_options, SortSelectionDlg, EncloseSelectionDlg, EncloseIfDef, - InvertAssignTool, SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm, - MultiPasteDlg, EditorMacroListViewer, EditorToolbarStatic, editortoolbar_options, - InputhistoryWithSearchOpt, FPDocHints, MainIntf, GotoFrm, BaseDebugManager, Debugger; + IDECmdLine, LazarusIDEStrConsts, IDECommands, MacroIntf, EditorOptions, + EnvironmentOpts, WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs, + IDEHelpManager, MacroPromptDlg, TransferMacros, CodeContextForm, + SrcEditHintFrm, etMessagesWnd, etSrcEditMarks, CodeMacroPrompt, + CodeTemplatesDlg, CodeToolsOptions, editor_general_options, SortSelectionDlg, + EncloseSelectionDlg, EncloseIfDef, InvertAssignTool, SourceEditProcs, + SourceMarks, CharacterMapDlg, SearchFrm, MultiPasteDlg, EditorMacroListViewer, + EditorToolbarStatic, editortoolbar_options, InputhistoryWithSearchOpt, + FPDocHints, MainIntf, GotoFrm, BaseDebugManager, Debugger; type TSourceNotebook = class; diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index 0120e09a38..b7fd7b9b2e 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -60,7 +60,7 @@ uses // IDE LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf, TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks, - PackageDefs, ComponentReg; + PackageDefs, ComponentReg, MacroIntf; const MakefileCompileVersion = 2;