From: <sv...@ww...> - 2006-12-12 08:26:27
|
Author: mkrose Date: 2006-12-12 00:26:20 -0800 (Tue, 12 Dec 2006) New Revision: 2032 Modified: trunk/csp/SConstruct trunk/csp/csplib/util/Export.h trunk/csp/tools/build/__init__.py trunk/csp/tools/build/autoconf.py Log: Change default symbol visibility to 'hidden' under gcc 4, which matches the default behavior of visual c++. This should eliminate one class of cross-platform errors related to missing CSPLIB_EXPORT tags. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2032 Modified: trunk/csp/SConstruct =================================================================== --- trunk/csp/SConstruct 2006-12-12 08:04:39 UTC (rev 2031) +++ trunk/csp/SConstruct 2006-12-12 08:26:20 UTC (rev 2032) @@ -136,9 +136,12 @@ env.CopyEnvironment(Split('PATH INCLUDE LIB')) def customize_linux(self, env): + gcc = build.GetGCCVersion() env.Replace(CXXFLAGS=Split('-O2 -g -W -Wall -pedantic -Wno-long-long')) env.Replace(SWIGCXXFLAGS=Split('-O2 -g')) env.Replace(ARFLAGS=Split('cr')) + if gcc and gcc[0] >= 4: + env.AppendUnique(CXXFLAGS=Split('-fvisibility=hidden')) def customize_darwin(self, env): print 'WARNING: Darwin is not yet a fully supported platform.' Modified: trunk/csp/csplib/util/Export.h =================================================================== --- trunk/csp/csplib/util/Export.h 2006-12-12 08:04:39 UTC (rev 2031) +++ trunk/csp/csplib/util/Export.h 2006-12-12 08:26:20 UTC (rev 2032) @@ -26,17 +26,21 @@ #define __CSPLIB_UTIL_EXPORT_H__ #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # ifdef SWIG - # undef __declspec - # define __declspec(x) - # endif // SWIG - # ifdef CSPLIB_EXPORTS - # define CSPLIB_EXPORT __declspec(dllexport) - # else - # define CSPLIB_EXPORT __declspec(dllimport) - # endif // CSPLIB_EXPORTS +# ifdef SWIG +# undef __declspec +# define __declspec(x) +# endif // SWIG +# ifdef CSPLIB_EXPORTS +# define CSPLIB_EXPORT __declspec(dllexport) +# else +# define CSPLIB_EXPORT __declspec(dllimport) +# endif // CSPLIB_EXPORTS #else - # define CSPLIB_EXPORT +# if defined(__GNUC__) && __GNUC__ >= 4 +# define CSPLIB_EXPORT __attribute__ ((visibility("default"))) +# else +# define CSPLIB_EXPORT +# endif #endif # if defined(_MSC_VER) && (_MSC_VER <= 1400) Modified: trunk/csp/tools/build/__init__.py =================================================================== --- trunk/csp/tools/build/__init__.py 2006-12-12 08:04:39 UTC (rev 2031) +++ trunk/csp/tools/build/__init__.py 2006-12-12 08:26:20 UTC (rev 2032) @@ -82,7 +82,7 @@ SourceGroup, Program, Generate, SharedLibrary, Command from csp.tools.build.autoconf import \ - CheckSConsVersion, CheckPythonVersion, GetPythonInclude, GetPythonLibrary + CheckSConsVersion, CheckPythonVersion, GetPythonInclude, GetPythonLibrary, GetGCCVersion from csp.tools.build.libconf import \ ExternalLibrary, PkgConfig, CommandConfig, UnixLibConfig, WindowsLibConfig, DevpackConfig Modified: trunk/csp/tools/build/autoconf.py =================================================================== --- trunk/csp/tools/build/autoconf.py 2006-12-12 08:04:39 UTC (rev 2031) +++ trunk/csp/tools/build/autoconf.py 2006-12-12 08:26:20 UTC (rev 2032) @@ -49,6 +49,12 @@ 'version %s or newer.' % (version, minimum)) sys.exit(1) +def GetGCCVersion(): + version = os.popen('gcc -dumpversion').read().strip() + try: + return map(int, version.split('.')) + except: + return None def CheckSwig(context, min_version, not_versions=[]): ok = 0 |