diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 70d4686e93..be1d903364 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,12 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-16 19:40 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * src/common/hbtrace.c + * contrib/xhb/hbsyslog.c + + Added Android specific logging support. Untested. + + * contrib/xhb/hbsyslog.c + ! Disabled syslog() call for Symbian. + + * include/hbsetup.h + + Added Android OS platform detection. Untested. + + * utils/hbmk2/hbmk2.prg + % Disabled some very old HB_INSTALL_PREFIX autodetection logic, + which supports some obsolete looking scenarios when hbmk2 executable + is not in standard location. Rest of logic and failure detection + rearranged accordingly. After this step hbmk2 no more requires + harbour executable to be present next to it. + IMPORTANT: This is live testing, pls report any problems. + 2011-04-16 09:30 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpfontdialog.prg ! Minor. * contrib/hbxbp/xbpwindow.prg - ! Protected: :setStyleSheet() method. + ! Protected: :setStyleSheet() method. It was not Xbase++ compatible so to achieve exactly Xbase++ compatibility, this is necessary. diff --git a/harbour/contrib/xhb/hbsyslog.c b/harbour/contrib/xhb/hbsyslog.c index 72aee99068..d0a8d0a226 100644 --- a/harbour/contrib/xhb/hbsyslog.c +++ b/harbour/contrib/xhb/hbsyslog.c @@ -12,11 +12,19 @@ #include "hblogdef.ch" #if defined( HB_OS_WIN ) -#include "windows.h" -static HANDLE s_RegHandle; + #include "windows.h" -#elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) && !defined( HB_OS_VXWORKS ) + static HANDLE s_RegHandle; + +#elif defined( HB_OS_ANDROID ) + + #include + +#elif defined( HB_OS_UNIX ) && \ + ! defined( __WATCOMC__ ) && \ + ! defined( HB_OS_VXWORKS ) && \ + ! defined( HB_OS_SYMBIAN ) #include @@ -105,16 +113,37 @@ HB_FUNC( HB_SYSLOGMESSAGE ) else #endif hb_retl( HB_FALSE ); - #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) && !defined( HB_OS_VXWORKS ) + + #elif defined( HB_OS_ANDROID ) + + int logval; + + switch( hb_parni( 2 ) ) + { + case HB_LOG_CRITICAL: logval = ANDROID_LOG_VERBOSE; break; + case HB_LOG_ERROR: logval = ANDROID_LOG_ERROR; break; + case HB_LOG_WARN: logval = ANDROID_LOG_WARN; break; + case HB_LOG_INFO: logval = ANDROID_LOG_INFO; break; + default: logval = ANDROID_LOG_DEBUG; + } + + __android_log_print( logval, "xhb", "[%lX]: %s", hb_parnl( 3 ), hb_parcx( 1 ) ); + hb_retl( HB_TRUE ); + + #elif defined( HB_OS_UNIX ) && \ + ! defined( __WATCOMC__ ) && \ + ! defined( HB_OS_VXWORKS ) && \ + ! defined( HB_OS_SYMBIAN ) + int logval; switch( hb_parni( 2 ) ) { case HB_LOG_CRITICAL: logval = LOG_CRIT; break; - case HB_LOG_ERROR: logval = LOG_ERR; break; - case HB_LOG_WARN: logval = LOG_WARNING; break; - case HB_LOG_INFO: logval = LOG_INFO; break; - default: logval = LOG_DEBUG; + case HB_LOG_ERROR: logval = LOG_ERR; break; + case HB_LOG_WARN: logval = LOG_WARNING; break; + case HB_LOG_INFO: logval = LOG_INFO; break; + default: logval = LOG_DEBUG; } syslog( logval, "[%lX]: %s", hb_parnl( 3 ), hb_parcx( 1 ) ); diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index c443e4507c..c9bc442459 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -410,6 +410,12 @@ #endif #endif +#ifndef HB_OS_ANDROID /* Experimental */ + #if defined( __ANDROID__ ) + #define HB_OS_ANDROID + #endif +#endif + #ifndef HB_OS_CYGWIN #if defined( __CYGWIN__ ) #define HB_OS_CYGWIN @@ -432,6 +438,7 @@ defined( HB_OS_VXWORKS ) || \ defined( HB_OS_BEOS ) || \ defined( HB_OS_SYMBIAN ) || \ + defined( HB_OS_ANDROID ) || \ defined( HB_OS_CYGWIN ) || \ defined( HB_OS_MINIX ) #define HB_OS_UNIX diff --git a/harbour/src/common/hbtrace.c b/harbour/src/common/hbtrace.c index a588bf67f6..449d0b424c 100644 --- a/harbour/src/common/hbtrace.c +++ b/harbour/src/common/hbtrace.c @@ -63,6 +63,8 @@ #if defined( HB_OS_WIN ) #include +#elif defined( HB_OS_ANDROID ) + #include #elif defined( HB_OS_UNIX ) && \ ! defined( __WATCOMC__ ) && \ ! defined( HB_OS_VXWORKS ) && \ @@ -282,7 +284,6 @@ static void hb_tracelog_( int level, const char * file, int line, const char * p TCHAR lp[ 1024 ]; } buf; - /* We add \n at the end of the buffer to make WinDbg display look readable. */ if( proc ) hb_snprintf( buf.psz, sizeof( buf.psz ), "%s:%d:%s() %s %s\n", @@ -298,6 +299,29 @@ static void hb_tracelog_( int level, const char * file, int line, const char * p #endif OutputDebugString( buf.lp ); } +# elif defined( HB_OS_ANDROID ) + { + char psz[ 1024 ]; + int slevel; + + switch( level ) + { + case HB_TR_ALWAYS: slevel = ANDROID_LOG_ASSERT; break; + case HB_TR_FATAL: slevel = ANDROID_LOG_VERBOSE; break; + case HB_TR_ERROR: slevel = ANDROID_LOG_ERROR break; + case HB_TR_WARNING: slevel = ANDROID_LOG_WARN; break; + case HB_TR_INFO: slevel = ANDROID_LOG_INFO; break; + case HB_TR_DEBUG: slevel = ANDROID_LOG_DEBUG; break; + default: slevel = ANDROID_LOG_DEBUG; + } + + if( proc ) + hb_snprintf( psz, sizeof( psz ), "%s:%d:%s() %s", file, line, proc, pszLevel ); + else + hb_snprintf( psz, sizeof( psz ), "%s:%d: %s", file, line, pszLevel ); + + __android_log_print( slevel, psz, message ); + } # else { int slevel; diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 0b09f4c2c3..2b7d5979f2 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -1468,6 +1468,8 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) l_cHB_INSTALL_PREFIX := MacroProc( hbmk, PathSepToSelf( GetEnv( "HB_INSTALL_PREFIX" ) ), NIL, _MACRO_NO_PREFIX ) IF Empty( l_cHB_INSTALL_PREFIX ) + l_cHB_INSTALL_PREFIX := hb_DirSepAdd( hb_DirBase() ) + ".." +#if 0 DO CASE CASE hb_FileExists( hb_DirSepAdd( hb_DirBase() ) + cBin_CompPRG + hbmk[ _HBMK_cCCEXT ] ) l_cHB_INSTALL_PREFIX := hb_DirSepAdd( hb_DirBase() ) + ".." @@ -1481,6 +1483,7 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) hbmk_OutErr( hbmk, I_( "Error: HB_INSTALL_PREFIX not set, failed to autodetect.\nPlease run this tool from its original location inside the Harbour installation or set HB_INSTALL_PREFIX environment variable to Harbour's root directory." ) ) RETURN _ERRLEV_FAILHBDETECT ENDCASE +#endif ENDIF /* Detect special non-installed dir layout (after simple 'make') */ @@ -1496,10 +1499,8 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) hb_FileExists( hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + Replicate( ".." + hb_ps(), PathSepCount( hbmk[ _HBMK_cBUILD ] ) ) + ".." + hb_ps() + ".." + hb_ps() + "include" +; hb_ps() + "hbvm.h" ) l_cHB_INSTALL_PREFIX := hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + Replicate( ".." + hb_ps(), PathSepCount( hbmk[ _HBMK_cBUILD ] ) ) + ".." + hb_ps() + ".." + hb_ps() - ENDIF - /* Detect special *nix dir layout (/bin, /lib/harbour, /lib64/harbour, /include/harbour) */ - IF hb_FileExists( hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + "include" +; + ELSEIF hb_FileExists( hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + "include" +; hb_ps() + iif( _HBMODE_IS_XHB( hbmk[ _HBMK_nHBMODE ] ), "xharbour", "harbour" ) +; hb_ps() + "hbvm.h" ) IF Empty( l_cHB_INSTALL_BIN ) @@ -1515,6 +1516,10 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) IF Empty( l_cHB_INSTALL_INC ) l_cHB_INSTALL_INC := hb_PathNormalize( hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + "include" + hb_ps() + iif( _HBMODE_IS_XHB( hbmk[ _HBMK_nHBMODE ] ), "xharbour", "harbour" ) ) ENDIF + ELSEIF ! hb_FileExists( hb_DirSepAdd( l_cHB_INSTALL_PREFIX ) + hb_ps() + "include" +; + hb_ps() + "hbvm.h" ) + hbmk_OutErr( hbmk, I_( "Error: HB_INSTALL_PREFIX not set, failed to autodetect.\nPlease run this tool from its original location inside the Harbour installation or set HB_INSTALL_PREFIX environment variable to Harbour's root directory." ) ) + RETURN _ERRLEV_FAILHBDETECT ENDIF #if defined( __PLATFORM__UNIX )