Hi
>> 4.
>> Can we define a macro in .hbm like:
>> $source_folder=c:\dev_sources\vouch
>>
>> {source_folder}\vouch.prg
>> {source_folder}\b_myprg.prg
>
> You can define envvars outside hbmk2 and use them as ${ENVVAR}
> I prefer to encourage users to minimize such hard wired paths in
> these config files. You can use relative to .hbm dirs, usually it's
> much more flexible. I mean you place your .hbm file in
> C:\dev_sources\vouch
> and simply put the .prg file in there as vouch.prg, b_myprg.prg.
> You can include this .hbm file from other .hbm files or from command
> line either by absolute or relative dir and hbmk2 will find your .prg
> files. Adding such variable handling engine in hbmk2 would create a
> quite heavy layer with several complications not just for hbmk2
> development,
> but also for users, f.e. how these can be inherited, which is stronger,
> envvar or local var, exporting, importing, so basically all the burden
> what
> is present in regular script files and GNU make, and which makes them
> much more complicated to use than necessary.
>
BTW the follwoing code implements what you already have and more:
STATIC PROCEDURE HBM_Load( aParams, cFileName, /* @ */ nEmbedLevel )
LOCAL cFile
LOCAL cLine
LOCAL cParam
LOCAL cMacro := ''
LOCAL cValue := ''
LOCAL n
IF hb_FileExists( cFileName )
cFile := MemoRead( cFileName ) /* NOTE: Intentionally using MemoRead()
which handles EOF char. */
cFile := StripCommnets( cFile )
IF ! hb_osNewLine() == _EOL
cFile := StrTran( cFile, hb_osNewLine(), _EOL )
ENDIF
IF ! hb_osNewLine() == Chr( 13 ) + Chr( 10 )
cFile := StrTran( cFile, Chr( 13 ) + Chr( 10 ), _EOL )
ENDIF
FOR EACH cLine IN hb_ATokens( cFile, _EOL )
cLine := AllTrim( cLine )
IF !( Left( cLine, 1 ) == "#" )
IF Left( cLine, 1 ) == "{"
IF ( n := At( '=', cLine ) ) > 0
cMacro := AllTrim( cLine, 1, n-1 )
cValue := AllTrim( cLine, n+1 )
/* Parse cValue again along lines of generic make systems
*/
IF Left( cValue, 2 ) == "$("
cValue := SubStr( cValue, 3 )
cValue := SubStr( cValue, 1, Len( cValue ) - 1 )
IF GetEnv( cValue ) != ""
cValue := GetEnv( cValue ) /* Just to avoid one more
variable */
ENDIF
ENDIF
ENDIF
ELSE
cLine := StrTran( cLine, cMacro, cValue )
FOR EACH cParam IN hb_ATokens( cLine,, .T. )
cParam := StrStripQuote( cParam )
IF ! Empty( cParam )
DO CASE
CASE ( Len( cParam ) >= 1 .AND. Left( cParam, 1 ) ==
"@" )
IF nEmbedLevel < 3
cParam := SubStr( cParam, 2 )
IF Empty( FN_ExtGet( cParam ) )
cParam := FN_ExtSet( cParam, ".hbm" )
ENDIF
nEmbedLevel++
HBM_Load( aParams, PathProc( cParam, cFileName ),
@nEmbedLevel ) /* Load parameters from script file */
ENDIF
CASE Lower( FN_ExtGet( cParam ) ) == ".hbm"
IF nEmbedLevel < 3
nEmbedLevel++
HBM_Load( aParams, PathProc( cParam, cFileName ),
@nEmbedLevel ) /* Load parameters from script file */
ENDIF
OTHERWISE
AAdd( aParams, { cParam, cFileName,
cLine:__enumIndex() } )
ENDCASE
ENDIF
NEXT
ENDIF
ENDIF
NEXT
ELSE
OutErr( hb_StrFormat( "hbmk: Warning: File cannot be found: %1$s",
cFileName ), hb_osNewLine() )
ENDIF
RETURN
Regards
Pritpal Bedi
--
View this message in context:
http://www.nabble.com/HBMK2---Few-Changes-tp23348709p23349852.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour