From a0bab8110bccf267f7c8c03fd0acd7f4d1c0fcd5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 5 Aug 2010 05:59:30 +0000 Subject: [PATCH] 2010-08-05 07:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * config/hbextern.hbs + Added HB_REBUILD_EXTERN support for msvc, pocc, watcom and bcc compilers. * contrib/make.hbs * config/postinst.hbs ! Fixed to convert input file for extern generation to native format. --- harbour/ChangeLog | 9 +++++++ harbour/config/hbextern.hbs | 47 ++++++++++++++++++++++++++++++++----- harbour/config/postinst.hbs | 3 ++- harbour/contrib/make.hbs | 3 ++- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1dc42f661e..320be5edac 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2010-08-05 07:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * config/hbextern.hbs + + Added HB_REBUILD_EXTERN support for msvc, pocc, watcom and bcc + compilers. + + * contrib/make.hbs + * config/postinst.hbs + ! Fixed to convert input file for extern generation to native format. + 2010-08-05 01:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added ${hb_dynsuffix} macro which returns a dynlib suffix diff --git a/harbour/config/hbextern.hbs b/harbour/config/hbextern.hbs index 4dff511707..c8e62c7a3c 100644 --- a/harbour/config/hbextern.hbs +++ b/harbour/config/hbextern.hbs @@ -37,29 +37,64 @@ #define _HB_SELF_SUFFIX "__" STATIC FUNCTION __hb_extern_get_list( cInputName ) + LOCAL aExtern := NIL + LOCAL cStdOut + LOCAL cTempFile LOCAL hRegex LOCAL aResult - LOCAL aExtern LOCAL tmp - IF GetEnv( "HB_COMPILER" ) $ "gcc|mingw|mingw64|cygwin" + LOCAL cCommand + LOCAL cRegex + + DO CASE + CASE "|" + GetEnv( "HB_COMPILER" ) $ "|gcc|mingw|mingw64|cygwin|djgpp" + cCommand := "nm -g" + iif( GetEnv( "HB_PLATFORM" ) == "darwin", "", " --defined-only -C" ) + " {I}" + cRegex := "[[:blank:]]HB_FUN_(.*)[[:space:]]" + CASE "|" + GetEnv( "HB_COMPILER" ) $ "|msvc|msvc64|pocc|pocc64" + IF "|" + GetEnv( "HB_COMPILER" ) $ "|msvc|msvc64" + cCommand := "dumpbin -symbols {I}" + ELSE + cCommand := "podump -symbols {I}" + ENDIF + cRegex := "SECT[0-9A-Z][0-9A-Z ].*[Ee]xternal.*_?HB_FUN_(.*)[[:space:]]" + CASE GetEnv( "HB_COMPILER" ) == "watcom" + cCommand := "wlib {I}" + cRegex := "[[:space:]]_?HB_FUN_([A-Z0-9_]*)[[:space:]]" + CASE GetEnv( "HB_COMPILER" ) == "bcc" + cCommand := "tlib {I}, {T}" + cRegex := "[[:space:]]_?HB_FUN_([A-Z0-9_]*)" + ENDCASE + + IF ! Empty( cCommand ) .AND. ; + ! Empty( cRegex ) IF hb_FileExists( cInputName ) - IF hb_processRun( "nm -g --defined-only -C " + cInputName,, @cStdOut ) == 0 - IF ! Empty( hRegex := hb_regexComp( "[[:blank:]]HB_FUN_(.*)[[:space:]]", .T., .T. ) ) + cCommand := StrTran( cCommand, "{I}", cInputName ) + IF "{T}" $ cCommand + FClose( hb_FTempCreateEx( @cTempFile,,, ".tmp" ) ) + cCommand := StrTran( cCommand, "{T}", cTempFile ) + ENDIF + IF hb_processRun( cCommand,, @cStdOut ) == 0 + IF ! Empty( cTempFile ) + cStdOut := MemoRead( cTempFile ) + ENDIF + IF ! Empty( hRegex := hb_regexComp( cRegex, .T., .T. ) ) aResult := hb_regexAll( hRegex, StrTran( cStdOut, Chr( 13 ) ),,,,, .T. ) aExtern := {} FOR EACH tmp IN aResult AAdd( aExtern, tmp[ 2 ] ) NEXT ASort( aExtern,,, {| tmp, tmp1 | tmp < tmp1 } ) - RETURN aExtern ENDIF ENDIF + IF ! Empty( cTempFile ) + FErase( cTempFile ) + ENDIF ENDIF ENDIF - RETURN NIL + RETURN aExtern STATIC PROCEDURE __hb_extern_get_neg_list( cInputName, /* @ */ aInclude, /* @ */ aExclude ) LOCAL cFile diff --git a/harbour/config/postinst.hbs b/harbour/config/postinst.hbs index d847755787..5d95c78b8c 100644 --- a/harbour/config/postinst.hbs +++ b/harbour/config/postinst.hbs @@ -543,7 +543,8 @@ STATIC FUNCTION mk_extern_core() IF GetEnv( "HB_REBUILD_EXTERN" ) == "yes" .AND. ; ! Empty( GetEnv( "HB_DYNLIB_ST" ) ) - IF ( aExtern := __hb_extern_get_list( GetEnv( "HB_DYNLIB_DIR" ) + hb_ps() + GetEnv( "HB_DYNLIB_ST" ) + GetEnv( "HB_DYNLIB_EXT" ) ) ) != NIL + /* TOFIX: Use list of libs instead of dynamic lib */ + IF ( aExtern := __hb_extern_get_list( PathToSelf( GetEnv( "HB_DYNLIB_DIR" ) ) + hb_ps() + GetEnv( "HB_DYNLIB_ST" ) + GetEnv( "HB_DYNLIB_EXT" ) ) ) != NIL OutStd( "! Generating core extern headers..." + hb_eol() ) diff --git a/harbour/contrib/make.hbs b/harbour/contrib/make.hbs index 1a659e6830..33a7dce224 100755 --- a/harbour/contrib/make.hbs +++ b/harbour/contrib/make.hbs @@ -440,7 +440,8 @@ STATIC PROCEDURE build_projects( nAction, hProjectList, hProjectReqList, cOption /* Create EXTERN list */ IF lPrimary .AND. hProjectList[ cProject ][ "cType" ] $ "hblib|hbdyn" - mk_extern_lib( hProjectList[ cProject ][ "cOutputName" ], FNameExtSet( PathSepToSelf( cProjectPath ), ".hbx" ) ) + mk_extern_lib( PathSepToSelf( hProjectList[ cProject ][ "cOutputName" ] ),; + FNameExtSet( PathSepToSelf( cProjectPath ), ".hbx" ) ) ENDIF ENDIF NEXT