2012-06-06 10:26 UTC+0200 Viktor Szakats (harbour syenar.net)

* src/pp/ppcore.c
    + accept and ignore '#require' PP directive

  * contrib/hbrun/hbrun.prg
  * utils/hbmk2/hbmk2.prg
    + use '#require "name"' to request modules.
      (This replaces former '//#require', '//#pragma module' and
       '*#pragma module' directives.)

  * utils/hbmk2/hbmk2.prg
    + add .hbc automatically for '#require' directives (experimental)
      ; TODO: to work also in non-incremental mode and to work
              reliably in -inc mode. To not impact performance, the
              compiler could do a callback when #require is found,
              hbmk2 could find the .hbc and extend compiler options
              dynamically.
    ! fixed finding .hbc files that were detected automatically

  * contrib/hbrun/hbrun.1
    + added my name as author
This commit is contained in:
Viktor Szakats
2012-06-06 08:29:39 +00:00
parent c6e261d74e
commit 4d96da75b6
5 changed files with 86 additions and 18 deletions

View File

@@ -16,6 +16,28 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-06-06 10:26 UTC+0200 Viktor Szakats (harbour syenar.net)
* src/pp/ppcore.c
+ accept and ignore '#require' PP directive
* contrib/hbrun/hbrun.prg
* utils/hbmk2/hbmk2.prg
+ use '#require "name"' to request modules.
(This replaces former '//#require', '//#pragma module' and
'*#pragma module' directives.)
* utils/hbmk2/hbmk2.prg
+ add .hbc automatically for '#require' directives (experimental)
; TODO: to work also in non-incremental mode and to work
reliably in -inc mode. To not impact performance, the
compiler could do a callback when #require is found,
hbmk2 could find the .hbc and extend compiler options
dynamically.
! fixed finding .hbc files that were detected automatically
* contrib/hbrun/hbrun.1
+ added my name as author
2012-06-06 04:07 UTC+0200 Viktor Szakats (harbour syenar.net)
* contrib/hbrun/hbrun.prg
* contrib/hbrun/pullext.prg
@@ -39,8 +61,8 @@
* contrib/hbrun/hbrun.prg
+ added experimental script syntax to dynamically load modules:
--- testcurl.hb
//#require "hbcurl"
? curl_version()
#require "hbcurl"
? curl_version()
---
; QUESTION: Is it possible to allow unknown #pragmas so above
comment-hack could be avoided? ATM harbour compilers

View File

@@ -31,4 +31,4 @@ startup function in executed code coming from \fB<file[.prg|.hrb]>\fP.
.SH AUTHOR
Przemyslaw Czerpak, The Harbour Project (http://harbour-project.org)
Viktor Szakats, Przemyslaw Czerpak, The Harbour Project (http://harbour-project.org)

View File

@@ -242,7 +242,7 @@ STATIC PROCEDURE LoadDynamicFromSource( aDynamic, cFileName )
LOCAL tmp
tmp := hb_cdpSelect( "EN" )
pRegex := hb_regexComp( '^(//)[[:blank:]]*#[[:blank:]]*(require)[[:blank:]]*(\".+?\"'+"|'.+?'"+')',;
pRegex := hb_regexComp( '(^|;)[[:blank:]]*#[[:blank:]]*(require)[[:blank:]]*(\".+?\"'+"|'.+?'"+')',;
.F. /* lCaseSensitive */,;
.T. /* lNewLine */ )
hb_cdpSelect( tmp )

View File

@@ -5263,6 +5263,11 @@ static void hb_pp_preprocessToken( PHB_PP_STATE pState )
else
hb_pp_error( pState, 'F', HB_PP_ERR_WRONG_FILE_NAME, NULL );
}
else if( hb_pp_tokenValueCmp( pToken, "REQUIRE", HB_PP_CMP_STD ) )
{
/* do nothing. this directive is processed by hbrun and hbmk2 to
pull in external modules. */
}
else if( hb_pp_tokenValueCmp( pToken, "STDOUT", HB_PP_CMP_DBASE ) )
{
hb_pp_disp( pState, hb_pp_tokenListStr( pToken->pNext, NULL, HB_FALSE,

View File

@@ -2126,7 +2126,7 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel )
/* search for .hbp files in macro libpaths */
IF Lower( hb_FNameExt( cParam ) ) == ".hbp" .AND. ! hbmk_hb_FileExists( cParam )
FOR EACH tmp IN hbmk[ _HBMK_aLIBPATH ]
IF "%{hb_name}" $ tmp .AND. hbmk_hb_FileExists( hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cParam, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cParam ) )
IF ( _MACRO_LATE_PREFIX + _MACRO_OPEN ) $ tmp .AND. hbmk_hb_FileExists( hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cParam, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cParam ) )
cParam := hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cParam, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cParam )
IF hbmk[ _HBMK_lInfo ]
_hbmk_OutStd( hbmk, hb_StrFormat( I_( "Found project reference on library search path: %1$s" ), cParam ) )
@@ -5061,13 +5061,6 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel )
hb_default( @hbmk[ _HBMK_nScr_Esc ], hbmk[ _HBMK_nCmd_Esc ] )
/* Delete all lib paths which contain late-evaluation macros. */
FOR EACH tmp IN hbmk[ _HBMK_aLIBPATH ] DESCEND
IF ( _MACRO_LATE_PREFIX + _MACRO_OPEN ) $ tmp
hb_ADel( hbmk[ _HBMK_aLIBPATH ], tmp:__enumIndex(), .T. )
ENDIF
NEXT
IF ! hbmk[ _HBMK_lStopAfterInit ]
IF ! Empty( hbmk[ _HBMK_cWorkDir ] )
/* NOTE: Ending path sep is important. */
@@ -5262,11 +5255,35 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel )
ENDIF
IF ! Empty( hbmk[ _HBMK_hAUTOHBCFOUND ] )
FOR EACH tmp IN hbmk[ _HBMK_hAUTOHBCFOUND ]
IF hbmk[ _HBMK_lInfo ]
_hbmk_OutStd( hbmk, hb_StrFormat( I_( "Processing (triggered by '%1$s' header): %2$s" ), tmp:__enumKey(), tmp ) )
FOR EACH cParam IN hbmk[ _HBMK_hAUTOHBCFOUND ]
IF ! Empty( cParam )
tmp1 := cParam
lFound := .F.
IF hb_FileExists( cParam )
lFound := .T.
ELSE
FOR EACH tmp IN hbmk[ _HBMK_aLIBPATH ]
IF hb_FileExists( hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cParam, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cParam ) )
cParam := hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cParam, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cParam )
lFound := .T.
EXIT
ENDIF
NEXT
ENDIF
IF lFound
cParam := hb_PathNormalize( cParam )
IF hbmk[ _HBMK_lInfo ]
_hbmk_OutStd( hbmk, hb_StrFormat( I_( "Processing (triggered by '%1$s' header): %2$s" ), cParam:__enumKey(), cParam ) )
ENDIF
HBC_ProcessOne( hbmk, cParam, 1 )
ELSE
_hbmk_OutErr( hbmk, hb_StrFormat( I_( "Warning: Cannot find %1$s" ), tmp1 ) )
ENDIF
ENDIF
HBC_ProcessOne( hbmk, tmp, 1 )
NEXT
convert_incpaths_to_options( hbmk, cOptIncMask, lCHD_Comp )
@@ -5275,6 +5292,13 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel )
l_aPRG_TO_DO := hbmk[ _HBMK_aPRG ]
ENDIF
/* Delete all lib paths which contain late-evaluation macros. */
FOR EACH tmp IN hbmk[ _HBMK_aLIBPATH ] DESCEND
IF ( _MACRO_LATE_PREFIX + _MACRO_OPEN ) $ tmp
hb_ADel( hbmk[ _HBMK_aLIBPATH ], tmp:__enumIndex(), .T. )
ENDIF
NEXT
/* Dump build information */
IF lDumpInfo
@@ -7565,6 +7589,7 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, tTimeParent, lCMode, cBin_Com
STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode )
STATIC s_pRegexInclude
STATIC s_pRegexRequire
STATIC s_hExclStd
LOCAL aDeps
@@ -7587,6 +7612,9 @@ STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode )
s_pRegexInclude := hb_regexComp( '(^|;)[[:blank:]]*#[[:blank:]]*(incl|inclu|includ|include|import)[[:blank:]]*(\".+?\"|<.+?>'+"|['`].+?'"+')',;
.F. /* lCaseSensitive */,;
.T. /* lNewLine */ )
s_pRegexRequire := hb_regexComp( '(^|;)[[:blank:]]*#[[:blank:]]*(require)[[:blank:]]*(\".+?\"'+"|'.+?'"+')',;
.F. /* lCaseSensitive */,;
.T. /* lNewLine */ )
hb_cdpSelect( tmp )
IF Empty( s_pRegexInclude )
_hbmk_OutErr( hbmk, I_( "Internal Error: Regular expression engine missing or unsupported. Check your Harbour build settings." ) )
@@ -7595,7 +7623,8 @@ STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode )
ENDIF
aDeps := {}
IF ! Empty( s_pRegexInclude )
IF ! Empty( s_pRegexInclude ) .AND. ;
! Empty( s_pRegexRequire )
cFileBody := MemoRead( cFile )
@@ -7727,6 +7756,18 @@ STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode )
AAdd( aDeps, aDep )
ENDIF
NEXT
IF ! lCMode
FOR EACH tmp IN hb_regexAll( s_pRegexRequire, cFileBody, ;
NIL /* lCaseSensitive */, ;
NIL /* lNewLine */, NIL, ;
NIL /* nGetMatch */, ;
.T. /* lOnlyMatch */ )
cHeader := ATail( tmp ) /* Last group in match marker */
cHeader := SubStr( cHeader, 2, Len( cHeader ) - 2 )
hbmk[ _HBMK_hAUTOHBCFOUND ][ "." + cHeader ] := hb_FNameExtSet( cHeader, ".hbc" )
NEXT
ENDIF
ENDIF
ENDIF
@@ -10084,7 +10125,7 @@ STATIC FUNCTION HBM_Load( hbmk, aParams, cFileName, nNestingLevel, lProcHBP )
ELSE
lFound := .F.
FOR EACH tmp IN hbmk[ _HBMK_aLIBPATH ]
IF "%{hb_name}" $ tmp .AND. hbmk_hb_FileExists( hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cHBP, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cHBP ) )
IF ( _MACRO_LATE_PREFIX + _MACRO_OPEN ) $ tmp .AND. hbmk_hb_FileExists( hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cHBP, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cHBP ) )
cHBP := hb_DirSepAdd( PathSepToSelf( MacroProc( hbmk, tmp, cHBP, _MACRO_LATE_PREFIX ) ) ) + hb_FNameNameExt( cHBP )
IF hbmk[ _HBMK_lInfo ]
_hbmk_OutStd( hbmk, hb_StrFormat( I_( "Found project reference on library search path: %1$s" ), cHBP ) )