From abfa7251041eff86326235fccf09984f403d53d1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 6 Aug 2010 13:16:35 +0000 Subject: [PATCH] 2010-08-06 15:15 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * ChangeLog * include/harbour.hbx * src/rtl/Makefile + src/rtl/libname.prg + tests/libname.prg + Added HB_LIBNAME( [, ] ) -> Serves to convert a raw dynlib name, f.e. "hbct" to OS specific notation, by adding platform specific extension, lib name prefix and optional directory * utils/hbmk2/hbmk2.prg ! Fixed dynlib prefix for symbian --- harbour/ChangeLog | 16 +++++- harbour/include/harbour.hbx | 1 + harbour/src/rtl/Makefile | 1 + harbour/src/rtl/libname.prg | 94 +++++++++++++++++++++++++++++++++++ harbour/tests/libname.prg | 29 +++++++++++ harbour/utils/hbmk2/hbmk2.prg | 6 ++- 6 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 harbour/src/rtl/libname.prg create mode 100644 harbour/tests/libname.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6fa3e647b8..40f618f0a4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2010-08-06 15:15 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * ChangeLog + * include/harbour.hbx + * src/rtl/Makefile + + src/rtl/libname.prg + + tests/libname.prg + + Added HB_LIBNAME( [, ] ) -> + Serves to convert a raw dynlib name, f.e. "hbct" to OS specific + notation, by adding platform specific extension, lib name prefix and + optional directory + + * utils/hbmk2/hbmk2.prg + ! Fixed dynlib prefix for symbian + 2010-08-06 14:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg * contrib/hbqt/qtgui/hbqtgui.hbc @@ -2057,7 +2071,7 @@ DYNAMIC CHARADD PROCEDURE Main() - LOCAL l := hb_libLoad( "hbct.dll" ) + LOCAL l := hb_libLoad( hb_libName( "hbct" ) ) IF ! Empty( l ) QOUT( CHARADD( "abc", Chr( 1 ) ) ) ENDIF diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index 076a910688..20d1ac651c 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -608,6 +608,7 @@ DYNAMIC HB_LIBERROR DYNAMIC HB_LIBFREE DYNAMIC HB_LIBGETFUNSYM DYNAMIC HB_LIBLOAD +DYNAMIC HB_LIBNAME DYNAMIC HB_MACROBLOCK DYNAMIC HB_MATHERBLOCK DYNAMIC HB_MATHERMODE diff --git a/harbour/src/rtl/Makefile b/harbour/src/rtl/Makefile index c41c3036bf..e9e87fffa8 100644 --- a/harbour/src/rtl/Makefile +++ b/harbour/src/rtl/Makefile @@ -227,6 +227,7 @@ PRG_SOURCES := \ hbi18n2.prg \ hbini.prg \ input.prg \ + libname.prg \ listbox.prg \ memoedit.prg \ memvarbl.prg \ diff --git a/harbour/src/rtl/libname.prg b/harbour/src/rtl/libname.prg new file mode 100644 index 0000000000..10cf458b9e --- /dev/null +++ b/harbour/src/rtl/libname.prg @@ -0,0 +1,94 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * HB_LIBNAME() + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +FUNCTION hb_LibName( cLibName, cLibDir ) + LOCAL cDir, cName, cExt + + LOCAL cLibPrefix + LOCAL cLibExt + + IF hb_isString( cLibName ) + + #if defined( __PLATFORM__WINDOWS ) .OR. ; + defined( __PLATFORM__OS2 ) .OR. ; + defined( __PLATFORM__SYMBIAN ) + cLibExt := ".dll" + #elif defined( __PLATFORM__DOS ) + cLibExt := "" + #elif defined( __PLATFORM__DARWIN ) + cLibExt := ".dylib" + #elif defined( __PLATFORM__HPUX ) + cLibExt := ".sl" + #else + cLibExt := ".so" + #endif + + #if ! defined( __PLATFORM__UNIX ) .OR. ; + defined( __PLATFORM__SYMBIAN ) + cLibPrefix := "" + #else + cLibPrefix := "lib" + #endif + + hb_FNameSplit( cLibName, @cDir, @cName, @cExt ) + + IF Empty( cDir ) .AND. hb_isString( cLibDir ) + cDir := cLibDir + ENDIF + IF Empty( cExt ) + cExt := cLibExt + ENDIF + + RETURN hb_FNameMerge( cDir, cLibPrefix + cName, cExt ) + ENDIF + + RETURN "" diff --git a/harbour/tests/libname.prg b/harbour/tests/libname.prg new file mode 100644 index 0000000000..ac42c7aa7f --- /dev/null +++ b/harbour/tests/libname.prg @@ -0,0 +1,29 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + */ + +#include "simpleio.ch" + +PROCEDURE Main() + + ? hb_LibName( NIL ) + ? hb_LibName( "" ) + ? hb_LibName( "name" ) + ? hb_LibName( "name.ext" ) + ? hb_LibName( "name." ) + ? hb_LibName( "name.ext", NIL ) + ? hb_LibName( "dir\name.ext", NIL ) + ? hb_LibName( "name.ext", "mydir" ) + ? hb_LibName( "dir\name.ext", "mydir" ) + ? hb_LibName( "name.ext", "mydir\" ) + ? hb_LibName( "dir\name.ext", "mydir\" ) + + RETURN diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 77245e1480..0f3c4ff6d1 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -1244,7 +1244,11 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) OTHERWISE aCOMPSUP := { "gcc" } ENDCASE - cDynLibNamePrefix := "lib" + IF hbmk[ _HBMK_cPLAT ] == "symbian" + cDynLibNamePrefix := "" + ELSE + cDynLibNamePrefix := "lib" + ENDIF DO CASE CASE hbmk[ _HBMK_cPLAT ] == "vxworks" l_aLIBHBGT := {}