pas2c engine now writes debug log webgl
authorunc0rr
Tue, 07 Jan 2014 22:08:02 +0400
branchwebgl
changeset 9966 01e198990211
parent 9964 12b0ed9910cd
child 9968 7fb2f35bdd5b
pas2c engine now writes debug log
hedgewars/options.inc
hedgewars/pas2cRedo.pas
hedgewars/uUtils.pas
project_files/hwc/rtl/fileio.c
tools/pas2c/PascalPreprocessor.hs
--- a/hedgewars/options.inc	Tue Jan 07 01:58:23 2014 +0400
+++ b/hedgewars/options.inc	Tue Jan 07 22:08:02 2014 +0400
@@ -30,7 +30,7 @@
 {$DEFINE USE_LUA_SCRIPT}
 
 {$IF DEFINED(WEBGL) AND NOT DEFINED(PAS2C)}
-{$UNDEF WEBGL}
+{$ERROR WEBGL defined, but PAS2C isn't}
 {$ENDIF}
 
 {$IFDEF WEBGL}
--- a/hedgewars/pas2cRedo.pas	Tue Jan 07 01:58:23 2014 +0400
+++ b/hedgewars/pas2cRedo.pas	Tue Jan 07 22:08:02 2014 +0400
@@ -48,7 +48,7 @@
     Handle = integer;
 
 var
-    write, writeLn, read, readLn, flush: procedure;
+    write, writeLn, read, readLn, flush, CreateDir: procedure;
 
     halt:procedure;
 
--- a/hedgewars/uUtils.pas	Tue Jan 07 01:58:23 2014 +0400
+++ b/hedgewars/uUtils.pas	Tue Jan 07 22:08:02 2014 +0400
@@ -351,6 +351,7 @@
 procedure AddFileLogRaw(s: pchar); cdecl;
 begin
 s:= s;
+{$IFNDEF PAS2C}
 {$IFDEF DEBUGFILE}
 {$IFDEF USE_VIDEO_RECORDING}
 EnterCriticalSection(logMutex);
@@ -361,6 +362,7 @@
 LeaveCriticalSection(logMutex);
 {$ENDIF}
 {$ENDIF}
+{$ENDIF}
 end;
 
 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
@@ -507,13 +509,16 @@
     InitCriticalSection(logMutex);
 {$ENDIF}
 {$I-}
+{$IFNDEF PAS2C}
     f:= stderr; // if everything fails, write to stderr
+{$ENDIF}
     if (UserPathPrefix <> '') then
         begin
+        {$IFNDEF PAS2C}
         // create directory if it doesn't exist
         if not FileExists(UserPathPrefix + '/Logs/') then
             CreateDir(UserPathPrefix + '/Logs/');
-
+        {$ENDIF}
         // if log is locked, write to the next one
         i:= 0;
         while(i < 7) do
--- a/project_files/hwc/rtl/fileio.c	Tue Jan 07 01:58:23 2014 +0400
+++ b/project_files/hwc/rtl/fileio.c	Tue Jan 07 22:08:02 2014 +0400
@@ -216,8 +216,7 @@
 }
 
 void __attribute__((overloadable)) fpcrtl_flush(Text f) {
-    printf("flush not implemented\n");
-    assert(0);
+    fflush(f->fp);
 }
 
 void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {
--- a/tools/pas2c/PascalPreprocessor.hs	Tue Jan 07 01:58:23 2014 +0400
+++ b/tools/pas2c/PascalPreprocessor.hs	Tue Jan 07 22:08:02 2014 +0400
@@ -21,6 +21,7 @@
 initDefines = Map.fromList [
     ("FPC", "")
     , ("PAS2C", "")
+    , ("DEBUGFILE", "")
 --    , ("WEBGL", "")
 --    , ("AI_MAINTHREAD", "")
     , ("ENDIAN_LITTLE", "")