From fc805c4bd2ea0bd32f781ce910c08ebf64a7c2e1 Mon Sep 17 00:00:00 2001 From: Mattias Gaertner Date: Tue, 6 Feb 2018 13:50:18 +0000 Subject: [PATCH] pas2js: marker for checking writeln statements git-svn-id: trunk@38139 - --- utils/pas2js/dirwatch.pp | 2 ++ utils/pas2js/httpcompiler.pp | 60 ++++++++++++++++++++---------------- utils/pas2js/pas2js.pp | 2 ++ 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/utils/pas2js/dirwatch.pp b/utils/pas2js/dirwatch.pp index 3b3892acd4..189f5ad4e0 100644 --- a/utils/pas2js/dirwatch.pp +++ b/utils/pas2js/dirwatch.pp @@ -432,9 +432,11 @@ begin setlength(fn,fnl); if (fnl>0) then move(e^.name,fn[1],fnl); + {$ifdef VerboseDirWatch} Writeln('Change ',e^.mask,' (', // InotifyEventsToString(e^.mask), ') detected for file "',fn,'"'); + {$endif} ptrint(e):=ptrint(e)+sizeof(inotify_event)+e^.len-1; end; end; diff --git a/utils/pas2js/httpcompiler.pp b/utils/pas2js/httpcompiler.pp index cdc4417ecb..b41c5587f3 100644 --- a/utils/pas2js/httpcompiler.pp +++ b/utils/pas2js/httpcompiler.pp @@ -208,12 +208,12 @@ end; constructor TDirWatcher.Create(App: THTTPCompilerApplication; ADir: String); begin - Inherited create(APP); - FApp:=App; - FDW:=TDirwatch.Create(Self); - FDW.AddWatch(ADir,allEvents); - FDW.OnChange:=@DoChange; - TThread.ExecuteInThread(@FDW.StartWatch); + Inherited create(APP); + FApp:=App; + FDW:=TDirwatch.Create(Self); + FDW.AddWatch(ADir,allEvents); + FDW.OnChange:=@DoChange; + TThread.ExecuteInThread(@FDW.StartWatch); end; destructor TDirWatcher.Destroy; @@ -228,31 +228,35 @@ end; procedure THTTPCompilerApplication.DoLog(EventType: TEventType; const Msg: String); begin - if Quiet then - exit; - if IsConsole then - Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz',Now),' [',EventType,'] ',Msg) - else - inherited DoLog(EventType, Msg); + {AllowWriteln} + if Quiet then + exit; + if IsConsole then + Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz',Now),' [',EventType,'] ',Msg) + else + inherited DoLog(EventType, Msg); + {AllowWriteln-} end; procedure THTTPCompilerApplication.Usage(Msg : String); begin - if (Msg<>'') then - Writeln('Error: ',Msg); - Writeln('Usage ',ExtractFileName(ParamStr(0)),' [options] '); - Writeln('Where options is one or more of : '); - Writeln('-d --directory=dir Base directory from which to serve files.'); - Writeln(' Default is current working directory: ',GetCurrentDir); - Writeln('-h --help This help text'); - Writeln('-i --indexpage=name Directory index page to use (default: index.html)'); - Writeln('-n --noindexpage Do not allow index page.'); - Writeln('-p --port=NNNN TCP/IP port to listen on (default is 3000)'); - Writeln('-q --quiet Do not write diagnostic messages'); - Writeln('-w --watch Watch directory for changes'); - Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr'); - Halt(Ord(Msg<>'')); + {AllowWriteln} + if (Msg<>'') then + Writeln('Error: ',Msg); + Writeln('Usage ',ExtractFileName(ParamStr(0)),' [options] '); + Writeln('Where options is one or more of : '); + Writeln('-d --directory=dir Base directory from which to serve files.'); + Writeln(' Default is current working directory: ',GetCurrentDir); + Writeln('-h --help This help text'); + Writeln('-i --indexpage=name Directory index page to use (default: index.html)'); + Writeln('-n --noindexpage Do not allow index page.'); + Writeln('-p --port=NNNN TCP/IP port to listen on (default is 3000)'); + Writeln('-q --quiet Do not write diagnostic messages'); + Writeln('-w --watch Watch directory for changes'); + Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr'); + Halt(Ord(Msg<>'')); + {AllowWriteln-} end; constructor THTTPCompilerApplication.Create(AOWner: TComponent); @@ -312,7 +316,9 @@ procedure THTTPCompilerApplication.AddToStatus(O : TJSONObject); begin FStatusLock.Enter; try + {$ifdef VerboseHTTPCompiler} Writeln('Adding to status ',Assigned(O),' : ',O.ClassName); + {$endif} FStatusList.Add(O); finally FStatusLock.Leave; @@ -356,7 +362,9 @@ begin R:=TJSONObject.Create(['ping',True]) else begin + {$ifdef VerboseHTTPCompiler} Writeln(FStatusList[0].ClassName); + {$endif} O:=FStatusList[0] as TJSONObject; FStatusList.Delete(0); if O.Get('action','')<>'file' then diff --git a/utils/pas2js/pas2js.pp b/utils/pas2js/pas2js.pp index c00ea2b881..d8775c74a8 100644 --- a/utils/pas2js/pas2js.pp +++ b/utils/pas2js/pas2js.pp @@ -46,7 +46,9 @@ begin on E: ECompilerTerminate do ; on E: Exception do begin + {AllowWriteln} writeln(E.Message); + {AllowWriteln-} if ExitCode=0 then ExitCode:=ExitCodeErrorInternal; end;