From 72edd414d86495097b28a5a8d24e3eafd2f6e290 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 3 Jun 2018 13:02:11 +0000 Subject: [PATCH] pas2js: added macro $(pas2js), do not add packages git-svn-id: trunk@58096 - --- components/pas2js/pjscontroller.pp | 52 ++++++++++++++++++-------- components/pas2js/pjsdsgnoptions.pas | 10 ++--- components/pas2js/pjsdsgnoptsframe.pas | 2 +- components/pas2js/pjsdsgnregister.pas | 19 +++------- components/pas2js/pjsprojectoptions.pp | 5 +-- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/components/pas2js/pjscontroller.pp b/components/pas2js/pjscontroller.pp index ed80611c4d..ce149345ac 100644 --- a/components/pas2js/pjscontroller.pp +++ b/components/pas2js/pjscontroller.pp @@ -52,9 +52,10 @@ Type Private FOnRefresh: TNotifyEvent; FServerInstances: TServerInstanceList; - 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 GetPas2JSPath(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; + function GetPas2JSBrowser(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; + function GetPas2JSNodeJS(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; + function GetPas2jsProjectURL(const s: string; const {%H-}Data: PtrInt; var Abort: boolean): string; function MaybeStartServer(Sender: TObject; var Handled: boolean): TModalResult; Public Constructor Create; @@ -189,42 +190,62 @@ end; { TPJSController } -function TPJSController.GetPasJSBrowser(const s: string; const Data: PtrInt; var Abort: boolean): string; +function TPJSController.GetPas2JSPath(const s: string; const Data: PtrInt; + var Abort: boolean): string; +begin + Abort:=False; + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetPas2JSPath] ignoring macro Pas2JS parameter "',s,'"']); + Result:=PJSOptions.CompilerFilename; + if Result='' then + Result:='pas2js'+GetExeExt + else + IdeMacros.SubstituteMacros(Result); + if (Result<>'') and (ExtractFilePath(Result)='') then + Result:=FindDefaultExecutablePath(Result); + if (Result<>'') and not FilenameIsAbsolute(Result) then begin + if ConsoleVerbosity>=0 then + debugln(['Hint: (lazarus) [TPJSController.GetPas2JSPath] invalid pas2js filename "',Result,'"']); + Result:=''; + end; +end; + +function TPJSController.GetPas2JSBrowser(const s: string; const Data: PtrInt; var Abort: boolean): string; begin Abort:=False; + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetPas2JSBrowser] ignoring macro Pas2JSBrowser parameter "',s,'"']); Result:=PJSOptions.BrowserFileName; if Result='' then Result:=GetStandardBrowser; 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; +function TPJSController.GetPas2JSNodeJS(const s: string; const Data: PtrInt; var Abort: boolean): string; begin Abort:=False; + if (s<>'') and (ConsoleVerbosity>=0) then + debugln(['Hint: (lazarus) [TPJSController.GetPas2JSNodeJS] ignoring macro Pas2JSNodeJS parameter "',s,'"']); Result:=PJSOptions.NodeJSFileName; if Result='' then Result:=GetStandardNodeJS; 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; +function TPJSController.GetPas2jsProjectURL(const s: string; const Data: PtrInt; var Abort: boolean): string; Var FN : String; begin if (s<>'') and (ConsoleVerbosity>=0) then - debugln(['Hint: (lazarus) [TPJSController.GetProjectURL] ignoring macro Pas2JSProjectURL parameter "',s,'"']); + debugln(['Hint: (lazarus) [TPJSController.GetPas2jsProjectURL] ignoring macro Pas2JSProjectURL parameter "',s,'"']); if ConsoleVerbosity>0 then DebugLN(['LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]: ',LazarusIDE.ActiveProject.CustomData[PJSProjectWebBrowser]]); @@ -253,7 +274,7 @@ begin end; Abort:=(Result=''); if ConsoleVerbosity>0 then - DebugLN(['GetProjectURL : ',Result]); + DebugLN(['GetPas2jsProjectURL : ',Result]); end; function TPJSController.MaybeStartServer(Sender: TObject; var Handled: boolean): TModalResult; @@ -320,9 +341,10 @@ end; procedure TPJSController.Hook; begin - IDEMacros.Add(TTransferMacro.Create('Pas2JSBrowser','','Pas2JS selected Browser executable',@GetPasJSBrowser,[])); - IDEMacros.Add(TTransferMacro.Create('Pas2JSNodeJS','','Pas2JS selected NodeJS xecutable',@GetPasJSNodeJS,[])); - IDEMacros.Add(TTransferMacro.Create('Pas2JSProjectURL','','Pas2JS current project URL',@GetProjectURL,[])); + IDEMacros.Add(TTransferMacro.Create('Pas2JS','','Pas2JS executable',@GetPas2JSPath,[])); + IDEMacros.Add(TTransferMacro.Create('Pas2JSBrowser','','Pas2JS selected Browser executable',@GetPas2JSBrowser,[])); + IDEMacros.Add(TTransferMacro.Create('Pas2JSNodeJS','','Pas2JS selected NodeJS excutable',@GetPas2JSNodeJS,[])); + IDEMacros.Add(TTransferMacro.Create('Pas2JSProjectURL','','Pas2JS current project URL',@GetPas2jsProjectURL,[])); LazarusIDE.AddHandlerOnRunWithoutDebugInit(@MaybeStartServer); end; diff --git a/components/pas2js/pjsdsgnoptions.pas b/components/pas2js/pjsdsgnoptions.pas index ff8efdd347..583142f7f2 100644 --- a/components/pas2js/pjsdsgnoptions.pas +++ b/components/pas2js/pjsdsgnoptions.pas @@ -17,7 +17,7 @@ const PJSDsgnOptsFile = 'pas2jsdsgnoptions.xml'; PJSDefaultCompiler = '$MakeExe(IDE,pas2js)'; PJSDefaultHTTPServer = '$MakeExe(IDE,simpleserver)'; - PJSDefaultStartAtPort = 3000; // Simpleserver default + PJSDefaultStartAtPort = 4000; // Simpleserver default PJSDefaultBrowser = '$MakeExe(IDE,firefox)'; PJSDefaultNodeJS = '$MakeExe(IDE,nodejs)'; @@ -75,7 +75,7 @@ implementation function GetStandardPas2jsExe: string; begin - Result:='$MakeExe(IDE,pas2js)'; + Result:=PJSDefaultCompiler; if not IDEMacros.SubstituteMacros(Result) then Result:='pas2js'; end; @@ -83,7 +83,7 @@ end; function GetStandardNodeJS: string; begin - Result:='$MakeExe(IDE,nodejs)'; + Result:=PJSDefaultNodeJS; if not IDEMacros.SubstituteMacros(Result) then Result:='nodejs'; end; @@ -91,7 +91,7 @@ end; function GetStandardHTTPServer: string; begin - Result:='$MakeExe(IDE,simpleserver)'; + Result:=PJSDefaultHTTPServer; if not IDEMacros.SubstituteMacros(Result) then Result:='simpleserver'; end; @@ -233,7 +233,7 @@ Const procedure TPas2jsOptions.LoadFromConfig(Cfg: TConfigStorage); begin - CompilerFilename:=Cfg.GetValue(KeyCompiler ,PJSDefaultCompiler); + CompilerFilename:=Cfg.GetValue(KeyCompiler,PJSDefaultCompiler); HTTPServerFileName:=Cfg.GetValue(KeyHTTPServer,PJSDefaultHTTPServer); BrowserFileName:=Cfg.GetValue(KeyBrowser,PJSDefaultBrowser); NodeJSFileName:=Cfg.GetValue(KeyNodeJS,PJSDefaultNodeJS); diff --git a/components/pas2js/pjsdsgnoptsframe.pas b/components/pas2js/pjsdsgnoptsframe.pas index 6925b55352..3be91e93e7 100644 --- a/components/pas2js/pjsdsgnoptsframe.pas +++ b/components/pas2js/pjsdsgnoptsframe.pas @@ -37,7 +37,7 @@ Type procedure NodeJSBrowseButtonClick(Sender: TObject); procedure Pas2jsPathBrowseButtonClick(Sender: TObject); private - function CheckCompiler(Buttons: TMsgDlgButtons): boolean; + function CheckCompiler({%H-}Buttons: TMsgDlgButtons): boolean; public function GetTitle: String; override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override; diff --git a/components/pas2js/pjsdsgnregister.pas b/components/pas2js/pjsdsgnregister.pas index 4284124b24..25bbed5372 100644 --- a/components/pas2js/pjsdsgnregister.pas +++ b/components/pas2js/pjsdsgnregister.pas @@ -108,7 +108,6 @@ begin RegisterIdeMenuCommand(itmViewDebugWindows,'Pas2JSWebservers',SPasJSWebserversCaption,nil,@ShowServerDialog); // Add project options frame RegisterIDEOptionsEditor(GroupProject,TPas2JSProjectOptionsFrame, Pas2JSOptionsIndex); - end; { TProjectPas2JSNodeJSApp } @@ -256,9 +255,9 @@ begin // create program source AProject.MainFile.SetSourceText(CreateProjectSource,true); - AProject.AddPackageDependency('pas2js_rtl'); - if naoUseNodeJSApp in Options then - AProject.AddPackageDependency('fcl_base_pas2js'); + //AProject.AddPackageDependency('pas2js_rtl'); + //if naoUseNodeJSApp in Options then + // AProject.AddPackageDependency('fcl_base_pas2js'); end; function TProjectPas2JSNodeJSApp.CreateStartFiles(AProject: TLazProject @@ -277,12 +276,6 @@ begin Flags:=DefaultProjectNoApplicationFlags-[pfRunnable]; end; -(*function TProjectPas2JSWebApp.GetBrowserCommand(AFileName : string): String; - -begin - Result:='$(Pas2JSBrowser) $(Pas2JSProjectURL)' -end; *) - function TProjectPas2JSWebApp.GetNextPort : Word; begin @@ -537,9 +530,9 @@ begin if baoRunOnReady in options then AProject.CustomData[PJSProjectRunAtReady]:='1'; end; - AProject.AddPackageDependency('pas2js_rtl'); - if baoUseBrowserApp in Options then - AProject.AddPackageDependency('fcl_base_pas2js'); + //AProject.AddPackageDependency('pas2js_rtl'); + //if baoUseBrowserApp in Options then + // AProject.AddPackageDependency('fcl_base_pas2js'); end; function TProjectPas2JSWebApp.CreateStartFiles(AProject: TLazProject diff --git a/components/pas2js/pjsprojectoptions.pp b/components/pas2js/pjsprojectoptions.pp index 166baf3ac3..a605b08dfd 100644 --- a/components/pas2js/pjsprojectoptions.pp +++ b/components/pas2js/pjsprojectoptions.pp @@ -107,10 +107,7 @@ begin CompOpts.WriteFPCLogo:=true; CompOpts.CustomOptions:=CustomOpts; - if PJSOptions.CompilerFilename='' then - Compiler:='$MakeExe(IDE,pas2js)' - else - Compiler:=PJSOptions.CompilerFilename; + Compiler:='$(pas2js)'; CompOpts.CompilerPath:=Compiler; debugln(['Hint: (lazarus) [pjsprojectoptions.SetPasJSCompileOptions] Compiler=',CompOpts.CompilerPath,' TargetOS=',CompOpts.TargetOS,' Custom="',CompOpts.CustomOptions,'"']); end;