IDEIntf: added ConsoleVerbosity, pas2js: less hints, fixed getting compiler options, fixed uninitialized result

git-svn-id: trunk@57023 -
This commit is contained in:
mattias 2018-01-09 11:08:04 +00:00
parent 4bddb9a44b
commit 76a5a3cd5d
10 changed files with 54 additions and 35 deletions

View File

@ -42,6 +42,9 @@ var
// the global IDE values // the global IDE values
IDEMacros: TIDEMacros = nil; // set by the IDE 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); procedure RenameIDEMacroInString(var s: string; const OldName, NewName: string);
implementation implementation

View File

@ -5,7 +5,8 @@ unit pjscontroller;
interface interface
uses uses
Classes, SysUtils, MacroIntf, MacroDefIntf, forms, lazideintf, lazlogger, process ; Classes, SysUtils, MacroIntf, MacroDefIntf, forms, Controls, lazideintf,
lazlogger, process ;
Type Type
@ -51,9 +52,9 @@ Type
Private Private
FOnRefresh: TNotifyEvent; FOnRefresh: TNotifyEvent;
FServerInstances: TServerInstanceList; FServerInstances: TServerInstanceList;
function GetPasJSBrowser(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 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 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; function MaybeStartServer(Sender: TObject; var Handled: boolean): TModalResult;
Public Public
Constructor Create; Constructor Create;
@ -150,6 +151,7 @@ begin
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
FProcess.Options:=[poNoConsole]; FProcess.Options:=[poNoConsole];
{$ENDIF} {$ENDIF}
if ConsoleVerbosity>=0 then
DebugLN(['Starting server from Directory : ',BaseDir]); DebugLN(['Starting server from Directory : ',BaseDir]);
FProcess.CurrentDirectory:=BaseDir; FProcess.CurrentDirectory:=BaseDir;
try try
@ -197,6 +199,8 @@ begin
IdeMacros.SubstituteMacros(Result); IdeMacros.SubstituteMacros(Result);
if (Result<>'') and not FilenameIsAbsolute(Result) then if (Result<>'') and not FilenameIsAbsolute(Result) then
Result:=FindDefaultExecutablePath(Result); Result:=FindDefaultExecutablePath(Result);
if (s<>'') and (ConsoleVerbosity>=0) then
debugln(['Hint: (lazarus) [TPJSController.GetPasJSBrowser] ignoring macro Pas2JSBrowser parameter "',s,'"']);
end; end;
function TPJSController.GetPasJSNodeJS(const s: string; const Data: PtrInt; var Abort: boolean): string; function TPJSController.GetPasJSNodeJS(const s: string; const Data: PtrInt; var Abort: boolean): string;
@ -209,6 +213,8 @@ begin
IdeMacros.SubstituteMacros(Result); IdeMacros.SubstituteMacros(Result);
if (Result<>'') and not FilenameIsAbsolute(Result) then if (Result<>'') and not FilenameIsAbsolute(Result) then
Result:=FindDefaultExecutablePath(Result); Result:=FindDefaultExecutablePath(Result);
if (s<>'') and (ConsoleVerbosity>=0) then
debugln(['Hint: (lazarus) [TPJSController.GetPasJSNodeJS] ignoring macro Pas2JSNodeJS parameter "',s,'"']);
end; end;
function TPJSController.GetProjectURL(const s: string; const Data: PtrInt; var Abort: boolean): string; function TPJSController.GetProjectURL(const s: string; const Data: PtrInt; var Abort: boolean): string;
@ -217,15 +223,21 @@ Var
FN : String; FN : String;
begin begin
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]]); DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]]);
Abort:=LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]<>'1'; Abort:=LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]<>'1';
if Abort then if Abort then
exit; exit;
if ConsoleVerbosity>0 then
DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectURL]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectURL]]); DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectURL]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectURL]]);
Result:=LazarusIDE.ActiveProject.CustomData[PJSProjectURL]; Result:=LazarusIDE.ActiveProject.CustomData[PJSProjectURL];
if (Result='') then if (Result='') then
begin begin
FN:=LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]; FN:=LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile];
if ConsoleVerbosity>0 then
DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]]); DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectHTMLFile]]);
if (FN='') then if (FN='') then
FN:=ChangeFileExt(ExtractFileName(LazarusIDE.ActiveProject.ProjectInfoFile),'.html'); FN:=ChangeFileExt(ExtractFileName(LazarusIDE.ActiveProject.ProjectInfoFile),'.html');
@ -240,6 +252,7 @@ begin
{$ENDIF} {$ENDIF}
end; end;
Abort:=(Result=''); Abort:=(Result='');
if ConsoleVerbosity>0 then
DebugLN(['GetProjectURL : ',Result]); DebugLN(['GetProjectURL : ',Result]);
end; end;
@ -252,11 +265,15 @@ Var
aInstance : TServerInstance; aInstance : TServerInstance;
begin begin
Result:=mrOK;
With LazarusIDE.ActiveProject do With LazarusIDE.ActiveProject do
begin begin
DebugLn(['WebProject:=',CustomData[PJSProjectWebBrowser]]); if ConsoleVerbosity>=0 then
DebugLn(['ServerPort:=',CustomData[PJSProjectPort]]); begin
DebugLn(['BaseDir:=',ProjectInfoFile]); DebugLn(['WebProject=',CustomData[PJSProjectWebBrowser]]);
DebugLn(['ServerPort=',CustomData[PJSProjectPort]]);
DebugLn(['BaseDir=',ProjectInfoFile]);
end;
WebProject:=CustomData[PJSProjectWebBrowser]='1'; WebProject:=CustomData[PJSProjectWebBrowser]='1';
ServerPort:=StrToIntDef(CustomData[PJSProjectPort],0); ServerPort:=StrToIntDef(CustomData[PJSProjectPort],0);
BaseDir:=ExtractFilePath(ProjectInfoFile); BaseDir:=ExtractFilePath(ProjectInfoFile);
@ -267,9 +284,11 @@ begin
aInstance:=ServerInstances.FindByPort(ServerPort); aInstance:=ServerInstances.FindByPort(ServerPort);
If Ainstance<>Nil then If Ainstance<>Nil then
begin begin
if ConsoleVerbosity>=0 then
Writeln('Have instance running on port ',ServerPort); Writeln('Have instance running on port ',ServerPort);
if Not SameFileName(BaseDir,aInstance.BaseDir) then if Not SameFileName(BaseDir,aInstance.BaseDir) then
begin begin
if ConsoleVerbosity>=0 then
Writeln('Instance on port ',ServerPort,' serves different directory: ',aInstance.BaseDir); Writeln('Instance on port ',ServerPort,' serves different directory: ',aInstance.BaseDir);
// We should ask the user what to do ? // We should ask the user what to do ?
If aInstance.Running then If aInstance.Running then

View File

@ -240,9 +240,6 @@ function TProjectPas2JSNodeJSApp.InitProject(AProject: TLazProject ): TModalResu
var var
MainFile : TLazProjectFile; MainFile : TLazProjectFile;
CompOpts : TLazCompilerOptions; CompOpts : TLazCompilerOptions;
RunParams : TAbstractRunParamsOptionsMode;
Compiler : String;
begin begin
Result:=inherited InitProject(AProject); Result:=inherited InitProject(AProject);
@ -250,6 +247,7 @@ begin
MainFile.IsPartOfProject:=true; MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false); AProject.AddFile(MainFile,false);
AProject.MainFileID:=0; AProject.MainFileID:=0;
CompOpts:=AProject.LazBuildModes.BuildModes[0].LazCompilerOptions;
CompOpts.TargetFilename:='project1'; CompOpts.TargetFilename:='project1';
SetDefaultNodeJSCompileOptions(AProject.LazCompilerOptions); SetDefaultNodeJSCompileOptions(AProject.LazCompilerOptions);

View File

@ -143,8 +143,6 @@ procedure TPas2JSProjectOptionsFrame.BResetRunCommandClick(Sender: TObject);
Var Var
Prj : TLazProject; Prj : TLazProject;
RP : TAbstractRunParamsOptionsMode;
begin begin
PRJ:=LazarusIDE.ActiveProject; PRJ:=LazarusIDE.ActiveProject;
SetDefaultWebRunParams(Prj.RunParameters.GetOrCreate('Default')); SetDefaultWebRunParams(Prj.RunParameters.GetOrCreate('Default'));
@ -205,7 +203,7 @@ end;
Function TPas2JSProjectOptionsFrame.FillFilesCombo(PRJ : TLazProject) : Integer; Function TPas2JSProjectOptionsFrame.FillFilesCombo(PRJ : TLazProject) : Integer;
Var Var
I,H : integer; I: integer;
HPF,PF : TLazProjectFile; HPF,PF : TLazProjectFile;
Ext : String; Ext : String;
L : TStringList; L : TStringList;
@ -245,6 +243,7 @@ Var
URL : String; URL : String;
begin begin
if AOptions=nil then ;
PRJ:=LazarusIDE.ActiveProject; PRJ:=LazarusIDE.ActiveProject;
HTMLIdx:=FillFilesCombo(PRJ); HTMLIdx:=FillFilesCombo(PRJ);
CBWebProject.Checked:=PRJ.CustomData[PJSProjectWebBrowser]='1'; CBWebProject.Checked:=PRJ.CustomData[PJSProjectWebBrowser]='1';
@ -277,6 +276,7 @@ Var
end; end;
begin begin
if AOptions=nil then ;
PRJ:=LazarusIDE.ActiveProject; PRJ:=LazarusIDE.ActiveProject;
// Clear everything // Clear everything
With PRJ.CustomData do With PRJ.CustomData do

View File

@ -39,7 +39,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, Forms, Controls, contnrs, strutils, Classes, SysUtils, LCLProc, Forms, Controls, contnrs, strutils,
IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, LazUTF8, IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, MacroIntf, LazUTF8,
IDECmdLine, LazarusIDEStrConsts, CompilerOptions, Project, IDECmdLine, LazarusIDEStrConsts, CompilerOptions, Project,
DefineTemplates, TransferMacros, EnvironmentOpts, LazFileUtils; DefineTemplates, TransferMacros, EnvironmentOpts, LazFileUtils;

View File

@ -86,9 +86,6 @@ function ParamsAndCfgCount: Integer;
function ParamsAndCfgStr(Idx: Integer): String; function ParamsAndCfgStr(Idx: Integer): String;
procedure ResetParamsAndCfg; procedure ResetParamsAndCfg;
var
ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose
implementation implementation
var var

View File

@ -41,7 +41,7 @@ interface
uses uses
Classes, SysUtils, math, lazutf8classes, LazConf, LCLProc, Classes, SysUtils, math, lazutf8classes, LazConf, LCLProc,
FileProcs, LazFileUtils, IDECmdLine; FileProcs, LazFileUtils, MacroIntf, IDECmdLine;
procedure ParseGuiCmdLineParams(var SkipAutoLoadingLastProject, procedure ParseGuiCmdLineParams(var SkipAutoLoadingLastProject,
StartedByStartLazarus, StartedByStartLazarus,

View File

@ -35,7 +35,8 @@ uses
// CodeTools // CodeTools
BasicCodeTools, SourceLog, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache, BasicCodeTools, SourceLog, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache,
// LazUtils // LazUtils
FileUtil, LazFileUtils, LazFileCache, LazUTF8, lazutf8classes, Laz2_XMLCfg, AvgLvlTree, FileUtil, LazFileUtils, LazFileCache, LazUTF8, lazutf8classes, Laz2_XMLCfg,
AvgLvlTree, MacroIntf,
// IDE // IDE
IDECmdLine, LazConf; IDECmdLine, LazConf;

View File

@ -71,14 +71,15 @@ uses
// DebuggerIntf // DebuggerIntf
DbgIntfBaseTypes, DbgIntfDebuggerBase, DbgIntfBaseTypes, DbgIntfDebuggerBase,
// IDE units // IDE units
IDECmdLine, LazarusIDEStrConsts, IDECommands, EditorOptions, EnvironmentOpts, IDECmdLine, LazarusIDEStrConsts, IDECommands, MacroIntf, EditorOptions,
WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs, IDEHelpManager, EnvironmentOpts, WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs,
MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm, etMessagesWnd, IDEHelpManager, MacroPromptDlg, TransferMacros, CodeContextForm,
etSrcEditMarks, CodeMacroPrompt, CodeTemplatesDlg, CodeToolsOptions, SrcEditHintFrm, etMessagesWnd, etSrcEditMarks, CodeMacroPrompt,
editor_general_options, SortSelectionDlg, EncloseSelectionDlg, EncloseIfDef, CodeTemplatesDlg, CodeToolsOptions, editor_general_options, SortSelectionDlg,
InvertAssignTool, SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm, EncloseSelectionDlg, EncloseIfDef, InvertAssignTool, SourceEditProcs,
MultiPasteDlg, EditorMacroListViewer, EditorToolbarStatic, editortoolbar_options, SourceMarks, CharacterMapDlg, SearchFrm, MultiPasteDlg, EditorMacroListViewer,
InputhistoryWithSearchOpt, FPDocHints, MainIntf, GotoFrm, BaseDebugManager, Debugger; EditorToolbarStatic, editortoolbar_options, InputhistoryWithSearchOpt,
FPDocHints, MainIntf, GotoFrm, BaseDebugManager, Debugger;
type type
TSourceNotebook = class; TSourceNotebook = class;

View File

@ -60,7 +60,7 @@ uses
// IDE // IDE
LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf, LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf,
TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks, TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks,
PackageDefs, ComponentReg; PackageDefs, ComponentReg, MacroIntf;
const const
MakefileCompileVersion = 2; MakefileCompileVersion = 2;