diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cb4080cd91..51a5cb20b7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,30 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-08 22:29 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + + Added experimental hbrun script runner "emulation" to hbmk2. + With a few differences: + - there is no interactive console + - it works only if filename with .hbs or .hrb is passed as first parameter + (which present a minor incompatibility for those using hbmk2 + to compile .hbs scripts to executables) + - the default GT environment for scripts is GTCGI. + - scripts may request interactivity with HBRUN_GTINTERACTIVE() + function call. This will switch mode to GTWIN/GTTRM/GTDOS/GTOS2 + depending on platform. Though interactive functions linked into + hbmk2 are very limited. + - only a limited set of functions and headers are available, + those which may be useful for cmdline apps. + (which means hbmk2 size didn't grow significantly after this + commit) + ; The goal is to make it possible to replace hbrun with hbmk2 + for Harbour build related scripts, and other simple user scripts. + + * utils/hbrun/hbrun.prg + * Minor cleanups. + * Using HB_PROGNAME() instead of HB_ARGV( 0 ) + 2011-02-08 14:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/hbnetio.hbp + contrib/hbnetio/hbnetio.hbx diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 7aff154c6a..672efbd74e 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -504,6 +504,14 @@ REQUEST __CLSLOCKDEF REQUEST HB_HKEEPORDER REQUEST HB_CRC32 REQUEST __HBDOC_TOSOURCE +REQUEST HB_LIBEXT +REQUEST HB_HKEYAT +REQUEST HB_HDELAT +REQUEST HB_HKEYS +REQUEST HB_FGETATTR + +/* For hbrun emulation */ +STATIC s_cDirBase_hbrun /* NOTE: Security token to protect against plugins accessing our internal structures referenced from context variable */ @@ -526,6 +534,15 @@ PROCEDURE _APPMAIN( ... ) /* Expand wildcard project specs */ + IF PCount() >= 1 + tmp := Lower( FNameExtGet( hb_PValue( 1 ) ) ) + IF tmp == ".hbs" .OR. ; + tmp == ".hrb" + hbmk2_hbrun_minimal( ... ) + QUIT + ENDIF + ENDIF + aArgsProc := {} FOR EACH tmp IN hb_AParams() DO CASE @@ -537,19 +554,6 @@ PROCEDURE _APPMAIN( ... ) FOR EACH tmp1 IN FN_Expand( SubStr( tmp, Len( "-target=" ) + 1 ), .F. ) AAdd( aArgsProc, "-target=" + tmp1 ) NEXT -#if 0 - CASE Lower( FNameExtGet( tmp ) ) == ".hbs" - hbrun_main( tmp ) - QUIT - CASE Lower( tmp ) == "-ui" - #if defined( __PLATFORM__WINCE ) - hb_gtSelect( hb_gtCreate( "GTWVT" ) ) - #elif defined( __PLATFORM__WINDOWS ) - hb_gtSelect( hb_gtCreate( "GTWIN" ) ) - #endif - hbrun_main() - QUIT -#endif OTHERWISE AAdd( aArgsProc, tmp ) ENDCASE @@ -11462,6 +11466,87 @@ STATIC FUNCTION __hb_extern_gen( hbmk, aFuncList, cOutputName ) RETURN .F. +STATIC FUNCTION hbmk_CoreHeaderFilesMinimal() + STATIC s_hHeaders := NIL + + IF s_hHeaders == NIL + s_hHeaders := { => } + + /* command to store header files in hash array */ + #command ADD HEADER TO FILE <(cFile)> => ; + #pragma __streaminclude <(cFile)>|\[ <(cFile)> \] := %s + + ADD HEADER TO s_hHeaders FILE "color.ch" + ADD HEADER TO s_hHeaders FILE "common.ch" + ADD HEADER TO s_hHeaders FILE "directry.ch" + ADD HEADER TO s_hHeaders FILE "error.ch" + ADD HEADER TO s_hHeaders FILE "fileio.ch" + ADD HEADER TO s_hHeaders FILE "hbmemory.ch" + ADD HEADER TO s_hHeaders FILE "hbver.ch" + ADD HEADER TO s_hHeaders FILE "inkey.ch" + ADD HEADER TO s_hHeaders FILE "setcurs.ch" + ADD HEADER TO s_hHeaders FILE "simpleio.ch" + + #if defined( __PLATFORM__UNIX ) + hb_HCaseMatch( s_hHeaders, .T. ) + #else + hb_HCaseMatch( s_hHeaders, .F. ) + #endif + ENDIF + + RETURN s_hHeaders + +/* Emulate a minimal hbrun */ + +PROCEDURE hbmk2_hbrun_minimal( cFile, ... ) + + IF ! Empty( cFile := FindInPath( cFile ) ) + SWITCH Lower( FNameExtGet( cFile ) ) + CASE ".hbs" + cFile := hb_compileBuf( hbmk_CoreHeaderFilesMinimal(), hb_ProgName(), "-n2", "-w", "-es2", "-q0", ; + "-I" + FNameDirGet( cFile ), "-D" + "__HBSCRIPT__HBRUN", cFile ) + IF cFile == NIL + ErrorLevel( 1 ) + EXIT + ENDIF + CASE ".hrb" + s_cDirBase_hbrun := hb_DirBase() + hb_argShift( .T. ) + hb_hrbRun( cFile, ... ) + EXIT + ENDSWITCH + ENDIF + + RETURN + +/* ------------------------------------------------------------- */ + +/* Public hbrun API */ +FUNCTION hbrun_DirBase() + RETURN s_cDirBase_hbrun + +/* Public hbrun API */ +PROCEDURE hbrun_gtInteractive() + hb_gtSelect( hb_gtCreate( hbrun_gtDefault() ) ) + RETURN + +STATIC FUNCTION hbrun_gtDefault() +#if defined( __PLATFORM__WINCE ) + RETURN "GTWVT" +#elif defined( __PLATFORM__WINDOWS ) + RETURN "GTWIN" +#elif defined( __PLATFORM__DOS ) + RETURN "GTDOS" +#elif defined( __PLATFORM__OS2 ) + RETURN "GTOS2" +#elif defined( __PLATFORM__UNIX ) .AND. ! defined( __PLATFORM__VXWORKS ) .AND. ! defined( __PLATFORM__SYMBIAN ) + RETURN "GTTRM" +#else + RETURN "GTCGI" +#endif + +/* ------------------------------------------------------------- */ + STATIC PROCEDURE convert_hbmake_to_hbp( hbmk, cSrcName, cDstName ) LOCAL cSrc := MemoRead( cSrcName ) LOCAL cDst @@ -12006,7 +12091,7 @@ STATIC PROCEDURE ShowHelp( hbmk, lLong ) { "-[no]minipo" , I_( "do (not) add Harbour version number and source file reference to .po (default: add them)" ) },; { "-rebuildpo" , I_( "recreate .po file, thus removing all obsolete entries in it" ) },; NIL,; - { "-hbx=<.ch>" , I_( "Create Harbour header (in .hbx format) with all external symbols. (EXPERIMENTAL)" ) },; + { "-hbx=<.ch>" , I_( "Create Harbour header (in .hbx format) with all external symbols." ) },; { "-autohbc=<.ch:.hbc>", I_( "<.ch> is a header file name. <.hbc> is a .hbc filename to be automatically included in case the header is found in any of the compiled sources. (EXPERIMENTAL)" ) },; NIL,; { "-deppkgname=" , I_( " is the name of the dependency. name of the package depedency. Can be specified multiple times." ) },; diff --git a/harbour/utils/hbrun/hbrun.prg b/harbour/utils/hbrun/hbrun.prg index 2b802e3d6d..8dcabbfd6a 100644 --- a/harbour/utils/hbrun/hbrun.prg +++ b/harbour/utils/hbrun/hbrun.prg @@ -82,7 +82,6 @@ REQUEST HB_GT_STD STATIC s_nRow STATIC s_nCol := 0 -STATIC s_aCompOptions := {} STATIC s_aHistory := {} STATIC s_lPreserveHistory := .T. STATIC s_lWasLoad := .F. @@ -94,7 +93,6 @@ STATIC s_cDirBase PROCEDURE _APPMAIN( cFile, ... ) LOCAL cExt LOCAL hHeaders - LOCAL lHeadersDisable := ! Empty( getenv( "HBRUN_NOHEAD" ) ) IF PCount() > 0 SWITCH Lower( cFile ) @@ -140,7 +138,7 @@ PROCEDURE _APPMAIN( cFile, ... ) cFile := hbrun_FindInPath( cFile ) IF ! Empty( cFile ) hb_FNameSplit( cFile, NIL, NIL, @cExt ) - cExt := lower( cExt ) + cExt := Lower( cExt ) SWITCH cExt CASE ".prg" CASE ".hbs" @@ -156,12 +154,12 @@ PROCEDURE _APPMAIN( cFile, ... ) EXIT CASE ".prg" CASE ".hbs" - IF ! lHeadersDisable + IF Empty( getenv( "HBRUN_NOHEAD" ) ) hHeaders := hbrun_CoreHeaderFiles() /* add core header files */ ENDIF - cFile := HB_COMPILEBUF( hHeaders, HB_ARGV( 0 ), "-n2", "-w", "-es2", "-q0", ; - s_aCompOptions, "-I" + FNameDirGet( cFile ), "-D" + "__HBSCRIPT__HBRUN", cFile ) + cFile := HB_COMPILEBUF( hHeaders, hb_ProgName(), "-n2", "-w", "-es2", "-q0", ; + "-I" + FNameDirGet( cFile ), "-D" + "__HBSCRIPT__HBRUN", cFile ) IF cFile == NIL ERRORLEVEL( 1 ) EXIT @@ -520,7 +518,7 @@ STATIC PROCEDURE hbrun_Exec( cCommand ) BEGIN SEQUENCE WITH {|oErr| hbrun_Err( oErr, cCommand ) } - cHRB := HB_COMPILEFROMBUF( cFunc, HB_ARGV( 0 ), "-n2", "-q2", s_aCompOptions ) + cHRB := HB_COMPILEFROMBUF( cFunc, hb_ProgName(), "-n2", "-q2" ) IF cHRB == NIL EVAL( ErrorBlock(), "Syntax error." ) ELSE