From 7bdb1a9ea4b6c77366722438de36ae9f97b7d079 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 26 Feb 2009 09:25:29 +0000 Subject: [PATCH] 2009-02-26 10:24 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * bin/hb-mkdyn.bat + Moving .lib and .exp (if they are generated) files to LIB dir. * source/vm/maindllp.c + Added owatcom flavour of .dll name. * contrib/hbwin/win_misc.c + Added WAPI_GETLASTERROR(), WAPI_SETLASTERROR(), WAPI_SETERRORMODE(). * utils/hbmk2/hbmk2.prg + Added TODO to create temp .c files in temp location. Looks this can create a few problems (-hbcc, .ppo output location when -p is used by user). + '/o' flavour of -o option is now ignored on non-*nix systems to make sure users cannot mess up the hbmk process flow. * -o option modified to reset any previous explicit -o settings. * Some minor internal renames, comments. + Added new hbmk.cfg / .hbp option: 'shareddef='. This can change the default state of shared/static setting, so it can be used by installers or user to override default behaviour. NOTE: HB_SHARED envvar can also be used. * Changed hbmk.cfg lookup preferences to this: 1. $HOME/.harbour 2. /etc/harbour 3. /../etc/harbour 4. /../etc 5. (NOTE: I've deleted /etc as etc/harbour seems superior and we already store a .def file there. I've also deleted /usr/local/etc) --- harbour/ChangeLog | 34 +++++++++++ harbour/bin/hb-mkdyn.bat | 43 +++++++++----- harbour/contrib/hbwin/win_misc.c | 15 +++++ harbour/source/vm/maindllp.c | 2 + harbour/utils/hbmk2/hbmk2.prg | 99 ++++++++++++++++++++++---------- 5 files changed, 148 insertions(+), 45 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d9ee1fa608..b2868fb455 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,40 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-26 10:24 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * bin/hb-mkdyn.bat + + Moving .lib and .exp (if they are generated) files + to LIB dir. + + * source/vm/maindllp.c + + Added owatcom flavour of .dll name. + + * contrib/hbwin/win_misc.c + + Added WAPI_GETLASTERROR(), WAPI_SETLASTERROR(), WAPI_SETERRORMODE(). + + * utils/hbmk2/hbmk2.prg + + Added TODO to create temp .c files in temp location. + Looks this can create a few problems (-hbcc, .ppo output + location when -p is used by user). + + '/o' flavour of -o option is now ignored on non-*nix + systems to make sure users cannot mess up the hbmk process + flow. + * -o option modified to reset any previous explicit -o settings. + * Some minor internal renames, comments. + + Added new hbmk.cfg / .hbp option: 'shareddef='. This can + change the default state of shared/static setting, so it + can be used by installers or user to override default + behaviour. NOTE: HB_SHARED envvar can also be used. + * Changed hbmk.cfg lookup preferences to this: + 1. $HOME/.harbour + 2. /etc/harbour + 3. /../etc/harbour + 4. /../etc + 5. + (NOTE: I've deleted /etc as etc/harbour seems superior + and we already store a .def file there. + I've also deleted /usr/local/etc) + 2009-02-25 18:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/gtwvg.c * harbour/contrib/gtwvg/wvgcrt.prg diff --git a/harbour/bin/hb-mkdyn.bat b/harbour/bin/hb-mkdyn.bat index a95663841e..24e02a40fd 100644 --- a/harbour/bin/hb-mkdyn.bat +++ b/harbour/bin/hb-mkdyn.bat @@ -93,11 +93,16 @@ for %%f in (%HB_DLL_LIBS_MT%) do ( ) cd .. -set _DST_NAME_ST=%HB_BIN_INSTALL%\harbour-%HB_DLL_VERSION%-vc.dll -set _DST_NAME_MT=%HB_BIN_INSTALL%\harbourmt-%HB_DLL_VERSION%-vc.dll +set _DST_NAME_ST=harbour-%HB_DLL_VERSION%-vc +set _DST_NAME_MT=harbourmt-%HB_DLL_VERSION%-vc -echo Making %_DST_NAME_ST%... && link /dll /out:"%_DST_NAME_ST%" @_hboneut.txt @_hbost.txt user32.lib wsock32.lib advapi32.lib gdi32.lib > nul -echo Making %_DST_NAME_MT%... && link /dll /out:"%_DST_NAME_MT%" @_hboneut.txt @_hbomt.txt user32.lib wsock32.lib advapi32.lib gdi32.lib > nul +echo Making %_DST_NAME_ST%.dll... && link /dll /out:"%HB_BIN_INSTALL%\%_DST_NAME_ST%.dll" @_hboneut.txt @_hbost.txt user32.lib wsock32.lib advapi32.lib gdi32.lib > nul +echo Making %_DST_NAME_MT%.dll... && link /dll /out:"%HB_BIN_INSTALL%\%_DST_NAME_MT%.dll" @_hboneut.txt @_hbomt.txt user32.lib wsock32.lib advapi32.lib gdi32.lib > nul + +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.exp" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.exp" rem ; Cleanup for /F %%o in (_hbost.txt) do ( del %%o ) @@ -208,14 +213,19 @@ for %%f in (%HB_DLL_LIBS_MT%) do ( ) cd .. -set _DST_NAME_ST=%HB_BIN_INSTALL%\harbour-%HB_DLL_VERSION%-b32.dll -set _DST_NAME_MT=%HB_BIN_INSTALL%\harbourmt-%HB_DLL_VERSION%-b32.dll +set _DST_NAME_ST=harbour-%HB_DLL_VERSION%-b32 +set _DST_NAME_MT=harbourmt-%HB_DLL_VERSION%-b32 -echo. , "%_DST_NAME_ST%",, cw32mt.lib import32.lib >> _hballst.txt -echo. , "%_DST_NAME_ST%",, cw32mt.lib import32.lib >> _hballmt.txt +echo. , "%HB_BIN_INSTALL%\%_DST_NAME_ST%.dll",, cw32mt.lib import32.lib >> _hballst.txt +echo. , "%HB_BIN_INSTALL%\%_DST_NAME_ST%.dll",, cw32mt.lib import32.lib >> _hballmt.txt -echo Making %_DST_NAME_ST%... && ilink32 -Gn -C -aa -Tpd -Gi -x c0d32.obj @_hballst.txt > nul -echo Making %_DST_NAME_MT%... && ilink32 -Gn -C -aa -Tpd -Gi -x c0d32.obj @_hballmt.txt > nul +echo Making %_DST_NAME_ST%.dll... && ilink32 -Gn -C -aa -Tpd -Gi -x c0d32.obj @_hballst.txt > nul +echo Making %_DST_NAME_MT%.dll... && ilink32 -Gn -C -aa -Tpd -Gi -x c0d32.obj @_hballmt.txt > nul + +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.exp" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.exp" del _hballst.txt del _hballmt.txt @@ -258,11 +268,16 @@ copy /b /y "%HB_LIB_INSTALL%\%HB_DLL_LIBS_MT%.lib" . && wlib -b "%HB_DLL_LIBS_MT echo FILE '%HB_DLL_LIBS_ST%.lib'>> _hbsst.txt echo FILE '%HB_DLL_LIBS_MT%.lib'>> _hbsmt.txt -set _DST_NAME_ST=%HB_BIN_INSTALL%\harbour-%HB_DLL_VERSION%-ow.dll -set _DST_NAME_MT=%HB_BIN_INSTALL%\harbourmt-%HB_DLL_VERSION%-ow.dll +set _DST_NAME_ST=harbour-%HB_DLL_VERSION%-ow +set _DST_NAME_MT=harbourmt-%HB_DLL_VERSION%-ow -echo Making %_DST_NAME_ST%... && wlink SYS NT_DLL NAME %_DST_NAME_ST% OP IMPLIB @_hbsst.txt LIB user32.lib, wsock32.lib, advapi32.lib, gdi32.lib > nul -echo Making %_DST_NAME_MT%... && wlink SYS NT_DLL NAME %_DST_NAME_MT% OP IMPLIB @_hbsmt.txt LIB user32.lib, wsock32.lib, advapi32.lib, gdi32.lib > nul +echo Making %_DST_NAME_ST%.dll... && wlink SYS NT_DLL NAME '%HB_BIN_INSTALL%\%_DST_NAME_ST%.dll' OP IMPLIB @_hbsst.txt LIB user32.lib, wsock32.lib, advapi32.lib, gdi32.lib > nul +echo Making %_DST_NAME_MT%.dll... && wlink SYS NT_DLL NAME '%HB_BIN_INSTALL%\%_DST_NAME_MT%.dll' OP IMPLIB @_hbsmt.txt LIB user32.lib, wsock32.lib, advapi32.lib, gdi32.lib > nul + +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.lib" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.lib" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_ST%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_ST%.exp" +if exist "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" move "%HB_BIN_INSTALL%\%_DST_NAME_MT%.exp" "%HB_LIB_INSTALL%\%_DST_NAME_MT%.exp" del %HB_DLL_LIBS_ST%.lib del %HB_DLL_LIBS_MT%.lib diff --git a/harbour/contrib/hbwin/win_misc.c b/harbour/contrib/hbwin/win_misc.c index 621dc25387..1b5e269b6b 100644 --- a/harbour/contrib/hbwin/win_misc.c +++ b/harbour/contrib/hbwin/win_misc.c @@ -199,3 +199,18 @@ HB_FUNC( WIN_GETCOMMANDLINEPARAM ) HB_TCHAR_FREE( buffer ); } + +HB_FUNC( WAPI_GETLASTERROR ) +{ + hb_retnl( ( long ) GetLastError() ); +} + +HB_FUNC( WAPI_SETLASTERROR ) +{ + SetLastError( ( DWORD ) hb_parnl( 1 ) ); +} + +HB_FUNC( WAPI_SETERRORMODE ) +{ + hb_retni( SetErrorMode( ( UINT ) hb_parni( 1 ) ) ); +} diff --git a/harbour/source/vm/maindllp.c b/harbour/source/vm/maindllp.c index 7a35b6763e..97c5d95326 100644 --- a/harbour/source/vm/maindllp.c +++ b/harbour/source/vm/maindllp.c @@ -62,6 +62,8 @@ #define HB_DLL_NAME "harbour.dll" #if defined( __BORLANDC__ ) #define HB_DLL_NAME2 "harbour-11-b32.dll" +#elif defined( __WATCOMC__ ) +#define HB_DLL_NAME2 "harbour-11-ow.dll" #elif defined( _MSC_VER ) #define HB_DLL_NAME2 "harbour-11-vc.dll" #endif diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 8c80aa6d58..66e263a64f 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -84,7 +84,16 @@ writing, most of them has one created. Thank you. [vszakats] */ -/* TODO: Sync default c/linker switches with Harbour build systems. */ +/* TODO: Create temporary .c files with mangled names, to + avoid incidentally overwriting existing .c file with the + same name. Problems to solve: -hbcc compatibility (the + feature has to be disabled when this switch is uses). + Collision with -o harbour option isn't a problem, since + we're overriding it already fo hbmk, but we will need to + deal with "/" prefixed variant. Since we need to use -o + Harbour switch, it will be a problem also when user tries + to use -p option, .ppo files will be generated in temp dir. */ +/* TODO: Sync default c/linker switches with the ones in Harbour GNU make system. */ /* TODO: Support for more compilers/platforms. */ /* TODO: Cross compilation support. */ /* TODO: Add support for library creation. */ @@ -94,8 +103,8 @@ ANNOUNCE HB_GTSYS REQUEST HB_GT_CGI_DEFAULT -REQUEST hbm_ARCH -REQUEST hbm_COMP +REQUEST hbmk_ARCH +REQUEST hbmk_COMP THREAD STATIC t_lQuiet := .T. THREAD STATIC t_lInfo := .F. @@ -197,8 +206,8 @@ FUNCTION Main( ... ) LOCAL s_lGUI := .F. LOCAL s_lMT := .F. - LOCAL s_lSHARED := .F. - LOCAL s_lSTATICFULL := .F. + LOCAL s_lSHARED := NIL + LOCAL s_lSTATICFULL := NIL LOCAL s_lDEBUG := .F. LOCAL s_lNULRDD := .F. LOCAL s_lMAP := .F. @@ -252,6 +261,8 @@ FUNCTION Main( ... ) LOCAL cDir, cName, cExt + LOCAL lNIX := hb_Version( HB_VERSION_UNIX_COMPAT ) + LOCAL cSelfCOMP := hb_Version( HB_VERSION_BUILD_COMP ) LOCAL cSelfFlagPRG := hb_Version( HB_VERSION_FLAG_PRG ) LOCAL cSelfFlagC := hb_Version( HB_VERSION_FLAG_C ) @@ -551,13 +562,6 @@ FUNCTION Main( ... ) /* Add main Harbour library dir to lib path list */ AAddNotEmpty( s_aLIBPATH, s_cHB_LIB_INSTALL ) - /* Build with shared libs by default, if we're installed to default system locations. */ - - IF lSysLoc .AND. ( t_cARCH $ "bsd|hpux|sunos|linux" .OR. t_cARCH == "darwin" ) - s_lSHARED := .T. - s_lSTATICFULL := .F. - ENDIF - /* Process environment */ IF Lower( GetEnv( "HB_MT" ) ) == "mt" ; s_lMT := .T. ; ENDIF /* Compatibility */ @@ -630,6 +634,18 @@ FUNCTION Main( ... ) @s_lRUN,; @s_cGT ) + /* Build with shared libs by default, if we're installed to default system locations. */ + + IF s_lSHARED == NIL + IF lSysLoc .AND. ( t_cARCH $ "bsd|hpux|sunos|linux" .OR. t_cARCH == "darwin" ) + s_lSHARED := .T. + s_lSTATICFULL := .F. + ELSE + s_lSHARED := .F. + s_lSTATICFULL := .F. + ENDIF + ENDIF + /* Process command line (2nd pass) */ FOR EACH cParam IN aParams @@ -644,6 +660,11 @@ FUNCTION Main( ... ) /* Simply ignore. They were already processed in the first pass. */ + CASE ! lNIX .AND. Left( cParam, 2 ) == "/o" + + /* Swallow this switch. We don't pass it to Harbour, as it may badly + interact with hbmk. */ + CASE Lower( cParam ) == "-gui" ; s_lGUI := .T. CASE Lower( cParam ) == "-mwindows" ; s_lGUI := .T. /* Compatibility */ CASE Lower( cParam ) == "-std" ; s_lGUI := .F. @@ -711,9 +732,12 @@ FUNCTION Main( ... ) IF ! Empty( cDir ) .AND. Empty( cName ) .AND. Empty( cExt ) /* Only a dir was passed, let's store that and pick a default name later. */ s_cPROGDIR := cDir - ELSE + ELSEIF ! Empty( tmp ) s_cPROGDIR := NIL s_cPROGNAME := tmp + ELSE + s_cPROGDIR := NIL + s_cPROGNAME := NIL ENDIF CASE Left( cParam, 2 ) == "-l" .AND. ; @@ -1803,42 +1827,42 @@ STATIC FUNCTION FindInPath( cFileName ) RETURN NIL -STATIC FUNCTION ArrayJoin( array1, array2 ) - LOCAL array := AClone( array1 ) - LOCAL nLen1 := Len( array ) +STATIC FUNCTION ArrayJoin( arraySrc1, arraySrc2 ) + LOCAL arrayNew := AClone( arraySrc1 ) + LOCAL nLen1 := Len( arrayNew ) - ASize( array, nLen1 + Len( array2 ) ) + ASize( arrayNew, nLen1 + Len( arraySrc2 ) ) - RETURN ACopy( array2, array, , , nLen1 + 1 ) + RETURN ACopy( arraySrc2, arrayNew, , , nLen1 + 1 ) -STATIC FUNCTION ArrayAJoin( arrays ) - LOCAL array := AClone( arrays[ 1 ] ) +STATIC FUNCTION ArrayAJoin( arrayList ) + LOCAL array := AClone( arrayList[ 1 ] ) LOCAL tmp - LOCAL nLenArray := Len( arrays ) + LOCAL nLenArray := Len( arrayList ) LOCAL nLen LOCAL nPos := Len( array ) + 1 nLen := 0 FOR tmp := 1 TO nLenArray - nLen += Len( arrays[ tmp ] ) + nLen += Len( arrayList[ tmp ] ) NEXT ASize( array, nLen ) FOR tmp := 2 TO nLenArray - ACopy( arrays[ tmp ], array, , , nPos ) - nPos += Len( arrays[ tmp ] ) + ACopy( arrayList[ tmp ], array, , , nPos ) + nPos += Len( arrayList[ tmp ] ) NEXT RETURN array -STATIC FUNCTION AAddNotEmpty( aArray, xItem ) +STATIC FUNCTION AAddNotEmpty( array, xItem ) IF ! Empty( xItem ) - AAdd( aArray, xItem ) + AAdd( array, xItem ) ENDIF - RETURN aArray + RETURN array STATIC FUNCTION ListDirExt( arraySrc, cDirNew, cExtNew ) LOCAL array := AClone( arraySrc ) @@ -2051,7 +2075,11 @@ STATIC PROCEDURE HBP_ProcessAll( lConfigOnly,; defined( __PLATFORM__OS2 ) aCFGDirs := { hb_DirBase() } #else - aCFGDirs := { "/usr/local/etc", "/etc", hb_DirBase() } + aCFGDirs := { GetEnv( "HOME" ) + "/.harbour/",; + "/etc/harbour",; + DirAddPathSep( hb_DirBase() ) + "../etc/harbour",; + DirAddPathSep( hb_DirBase() ) + "../etc",; + hb_DirBase() } #endif FOR EACH cDir IN aCFGDirs @@ -2213,6 +2241,13 @@ STATIC PROCEDURE HBP_ProcessOne( cFileName,; CASE ValueIsF( cLine ) ; lMT := .F. ENDCASE + CASE Lower( Left( cLine, Len( "shareddef=" ) ) ) == "shareddef=" ; cLine := SubStr( cLine, Len( "shareddef=" ) + 1 ) + IF lSHARED == NIL + DO CASE + CASE ValueIsT( cLine ) ; lSHARED := .T. ; lSTATICFULL := .F. + CASE ValueIsF( cLine ) ; lSHARED := .F. ; lSTATICFULL := .F. + ENDCASE + ENDIF CASE Lower( Left( cLine, Len( "shared=" ) ) ) == "shared=" ; cLine := SubStr( cLine, Len( "shared=" ) + 1 ) DO CASE CASE ValueIsT( cLine ) ; lSHARED := .T. ; lSTATICFULL := .F. @@ -2372,7 +2407,7 @@ STATIC FUNCTION ArchCompFilter( cItem ) LOCAL xResult LOCAL cValue - LOCAL cExpr := "( hbm_ARCH() == Lower( '%1' ) .OR. hbm_COMP() == Lower( '%1' ) )" + LOCAL cExpr := "( hbmk_ARCH() == Lower( '%1' ) .OR. hbmk_COMP() == Lower( '%1' ) )" IF ( nStart := At( "{", cItem ) ) > 0 .AND. ; ( nEnd := hb_At( "}", cItem, nStart ) ) > 0 @@ -2486,10 +2521,12 @@ STATIC FUNCTION commandResult( cCommand, nResult ) RETURN cResult -FUNCTION hbm_ARCH() +/* Keep this public, it's used from macro. */ +FUNCTION hbmk_ARCH() RETURN t_cARCH -FUNCTION hbm_COMP() +/* Keep this public, it's used from macro. */ +FUNCTION hbmk_COMP() RETURN t_cCOMP STATIC PROCEDURE PauseForKey()