From 1c6e0d342a31dc8999695d20286fa810c0fb7cfc Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 7 Feb 2011 09:56:13 +0000 Subject: [PATCH] 2011-02-07 10:54 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg ! Do not add .hbx file to input file list if the file doesn't exist. This is to resolve the chicken-egg problem when initially creating the .hbx file for a new project. ! Never use .hbx filename for forming the output name and deciding about startup module. * utils/hbmk2/hbmk2.prg * config/postinst.hbs + Do not add duplicates to extern list. (it may have only happened if renaming sources and building without clean) --- harbour/ChangeLog | 14 +++++++++++ harbour/config/postinst.hbs | 26 ++++++++++++-------- harbour/utils/hbmk2/hbmk2.prg | 46 +++++++++++++++++++++-------------- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6e5c802533..ac2755a72b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-07 10:54 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + ! Do not add .hbx file to input file list if the file doesn't + exist. This is to resolve the chicken-egg problem when + initially creating the .hbx file for a new project. + ! Never use .hbx filename for forming the output name + and deciding about startup module. + + * utils/hbmk2/hbmk2.prg + * config/postinst.hbs + + Do not add duplicates to extern list. + (it may have only happened if renaming sources and + building without clean) + 2011-02-07 10:19 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmxml/hbmxml.hbx * contrib/hbexpat/hbexpat.hbx diff --git a/harbour/config/postinst.hbs b/harbour/config/postinst.hbs index ddbfcec5e2..673db90e3a 100644 --- a/harbour/config/postinst.hbs +++ b/harbour/config/postinst.hbs @@ -44,7 +44,7 @@ PROCEDURE Main( ... ) Empty( GetEnvC( "HB_COMPILER" ) ) .OR. ; Empty( GetEnvC( "HB_HOST_BIN_DIR" ) ) - OutStd( "! Error: This program has to be called from the GNU Make process." + hb_eol() ) + OutStd( "! Error: This script has to be called from the GNU Make process." + hb_eol() ) ErrorLevel( 1 ) RETURN ENDIF @@ -603,10 +603,11 @@ STATIC FUNCTION GetEnvC( cEnvVar ) STATIC FUNCTION __hb_extern_get_list( cInputName ) LOCAL aExtern := NIL + LOCAL hExtern LOCAL cStdOut, cStdErr LOCAL cTempFile - LOCAL hRegex + LOCAL pRegex LOCAL aResult LOCAL tmp @@ -642,11 +643,16 @@ STATIC FUNCTION __hb_extern_get_list( cInputName ) IF ! Empty( cTempFile ) cStdOut := MemoRead( cTempFile ) ENDIF - IF ! Empty( hRegex := hb_regexComp( cRegex, .T., .T. ) ) - aResult := hb_regexAll( hRegex, StrTran( cStdOut, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( cRegex, .T., .T. ) ) + aResult := hb_regexAll( pRegex, StrTran( cStdOut, Chr( 13 ) ),,,,, .T. ) aExtern := {} + hExtern := { => } FOR EACH tmp IN aResult - AAdd( aExtern, tmp[ 2 ] ) + tmp[ 2 ] := hb_asciiUpper( tmp[ 2 ] ) + IF !( tmp[ 2 ] $ hExtern ) + AAdd( aExtern, tmp[ 2 ] ) + hExtern[ tmp[ 2 ] ] := NIL + ENDIF NEXT ASort( aExtern,,, {| tmp, tmp1 | tmp < tmp1 } ) ENDIF @@ -661,20 +667,20 @@ STATIC FUNCTION __hb_extern_get_list( cInputName ) STATIC PROCEDURE __hb_extern_get_exception_list( cInputName, /* @ */ aInclude, /* @ */ aExclude ) LOCAL cFile - LOCAL hRegex + LOCAL pRegex LOCAL tmp aInclude := {} aExclude := {} IF ! Empty( cFile := MemoRead( cInputName ) ) - IF ! Empty( hRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_INCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) - FOR EACH tmp IN hb_regexAll( hRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_INCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) + FOR EACH tmp IN hb_regexAll( pRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) AAdd( aInclude, Upper( tmp[ 2 ] ) ) NEXT ENDIF - IF ! Empty( hRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_EXCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) - FOR EACH tmp IN hb_regexAll( hRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_EXCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) + FOR EACH tmp IN hb_regexAll( pRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) AAdd( aExclude, Upper( tmp[ 2 ] ) ) NEXT ENDIF diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index cc0e968dac..7aff154c6a 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -2896,7 +2896,11 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) IF Empty( FNameExtGet( cParam ) ) cParam := FNameExtSet( cParam, ".prg" ) ELSEIF FNameExtGet( cParamL ) == ".hbx" - AAddNew( hbmk[ _HBMK_aOPTPRG ], "-D__HBEXTREQ__" ) + IF hb_FileExists( cParam ) + AAddNew( hbmk[ _HBMK_aOPTPRG ], "-D__HBEXTREQ__" ) + AAdd( hbmk[ _HBMK_aPRG ], cParam ) + ENDIF + LOOP ENDIF AAdd( hbmk[ _HBMK_aPRG ], cParam ) DEFAULT hbmk[ _HBMK_cFIRST ] TO cParam @@ -6821,7 +6825,7 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, tTimeParent, lCMode, cBin_Com LOCAL cDependency LOCAL aCommand - STATIC s_hRegexInclude := NIL + STATIC s_pRegexInclude := NIL STATIC s_hExclStd := NIL IF hbmk[ _HBMK_nHEAD ] == _HEAD_OFF @@ -6951,7 +6955,7 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, tTimeParent, lCMode, cBin_Com #define _HBMK_HEADER_LEN_ 2 STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode ) - STATIC s_hRegexInclude + STATIC s_pRegexInclude STATIC s_hExclStd LOCAL aDeps @@ -6965,23 +6969,23 @@ STATIC FUNCTION s_getIncludedFiles( hbmk, cFile, cParentDir, lCMode ) http://en.wikipedia.org/wiki/PCRE http://www.pcre.org/pcre.txt */ - IF s_hRegexInclude == NIL - s_hRegexInclude := hb_regexComp( '^[[:blank:]]*#[[:blank:]]*(include|import)[[:blank:]]*(\".+?\"|<.+?>'+"|'.+?'|`.+?'"+')',; + IF s_pRegexInclude == NIL + s_pRegexInclude := hb_regexComp( '^[[:blank:]]*#[[:blank:]]*(include|import)[[:blank:]]*(\".+?\"|<.+?>'+"|'.+?'|`.+?'"+')',; .F. /* lCaseSensitive */,; .T. /* lNewLine */ ) - IF Empty( s_hRegexInclude ) + IF Empty( s_pRegexInclude ) hbmk_OutErr( hbmk, I_( "Internal Error: Regular expression engine missing or unsupported. Please check your Harbour build settings." ) ) - s_hRegexInclude := {} /* To show the error only once by setting to non-NIL empty value */ + s_pRegexInclude := 0 /* To show the error only once by setting to non-NIL empty value */ ENDIF ENDIF aDeps := {} - IF ! Empty( s_hRegexInclude ) + IF ! Empty( s_pRegexInclude ) cFileBody := MemoRead( cFile ) IF ! Empty( cFileBody ) - FOR EACH tmp IN hb_regexAll( s_hRegexInclude, cFileBody, ; + FOR EACH tmp IN hb_regexAll( s_pRegexInclude, cFileBody, ; NIL /* lCaseSensitive */, ; NIL /* lNewLine */, NIL, ; NIL /* nGetMatch */, ; @@ -11278,10 +11282,11 @@ STATIC FUNCTION mk_extern( hbmk, cInputName, cBin_LibHBX, cOpt_LibHBX, cLibHBX_R STATIC FUNCTION __hb_extern_get_list( hbmk, cInputName, cBin_LibHBX, cOpt_LibHBX, cLibHBX_Regex ) LOCAL aExtern := NIL + LOCAL hExtern LOCAL cStdOut, cStdErr LOCAL cTempFile - LOCAL hRegex + LOCAL pRegex LOCAL aResult LOCAL tmp @@ -11300,11 +11305,16 @@ STATIC FUNCTION __hb_extern_get_list( hbmk, cInputName, cBin_LibHBX, cOpt_LibHBX IF ! Empty( cTempFile ) cStdOut := MemoRead( cTempFile ) ENDIF - IF ! Empty( hRegex := hb_regexComp( cLibHBX_Regex, .T., .T. ) ) - aResult := hb_regexAll( hRegex, StrTran( cStdOut, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( cLibHBX_Regex, .T., .T. ) ) + aResult := hb_regexAll( pRegex, StrTran( cStdOut, Chr( 13 ) ),,,,, .T. ) aExtern := {} + hExtern := { => } FOR EACH tmp IN aResult - AAdd( aExtern, tmp[ 2 ] ) + tmp[ 2 ] := hb_asciiUpper( tmp[ 2 ] ) + IF !( tmp[ 2 ] $ hExtern ) + AAdd( aExtern, tmp[ 2 ] ) + hExtern[ tmp[ 2 ] ] := NIL + ENDIF NEXT ASort( aExtern,,, {| tmp, tmp1 | tmp < tmp1 } ) ENDIF @@ -11326,20 +11336,20 @@ STATIC FUNCTION __hb_extern_get_list( hbmk, cInputName, cBin_LibHBX, cOpt_LibHBX STATIC PROCEDURE __hb_extern_get_exception_list( cInputName, /* @ */ aInclude, /* @ */ aExclude ) LOCAL cFile - LOCAL hRegex + LOCAL pRegex LOCAL tmp aInclude := {} aExclude := {} IF ! Empty( cFile := MemoRead( cInputName ) ) - IF ! Empty( hRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_INCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) - FOR EACH tmp IN hb_regexAll( hRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_INCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) + FOR EACH tmp IN hb_regexAll( pRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) AAdd( aInclude, Upper( tmp[ 2 ] ) ) NEXT ENDIF - IF ! Empty( hRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_EXCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) - FOR EACH tmp IN hb_regexAll( hRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) + IF ! Empty( pRegex := hb_regexComp( "[[:space:]]" + _HB_FUNC_EXCLUDE_ + "[[:space:]]([a-zA-z0-9_].[^ \t\n\r]*)", .T., .T. ) ) + FOR EACH tmp IN hb_regexAll( pRegex, StrTran( cFile, Chr( 13 ) ),,,,, .T. ) AAdd( aExclude, Upper( tmp[ 2 ] ) ) NEXT ENDIF