Ver código fonte

Fixing DLL export macros so they are properly set up when compiling with non-MSVC on Windows

BearishSun 8 anos atrás
pai
commit
f3ee875d18

+ 27 - 34
Source/BansheeCore/Include/BsCorePrerequisites.h

@@ -179,40 +179,33 @@
 /** Maximum number of devices one resource can exist at the same time. */
 /** Maximum number of devices one resource can exist at the same time. */
 #define BS_MAX_LINKED_DEVICES 4U
 #define BS_MAX_LINKED_DEVICES 4U
 
 
-// Windows Settings
-#if BS_PLATFORM == BS_PLATFORM_WIN32
-
-// If we're not including this from a client build, specify that the stuff
-// should get exported. Otherwise, import it.
-#	if defined(BS_STATIC_LIB)
-// Linux compilers don't have symbol import/export directives.
-#   	define BS_CORE_EXPORT
-#   else
-#   	if defined(BS_CORE_EXPORTS)
-#       	define BS_CORE_EXPORT __declspec( dllexport )
-#   	else
-#           if defined( __MINGW32__ )
-#               define BS_CORE_EXPORT
-#           else
-#       	    define BS_CORE_EXPORT __declspec( dllimport )
-#           endif
-#   	endif
-#	endif
-
-#endif
-
-// Linux/Apple Settings
-#if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
-
-// Enable GCC symbol visibility
-#   if defined( BS_GCC_VISIBILITY )
-#       define BS_CORE_EXPORT  __attribute__ ((visibility("default")))
-#       define BS_HIDDEN __attribute__ ((visibility("hidden")))
-#   else
-#       define BS_CORE_EXPORT
-#       define BS_HIDDEN
-#   endif
-
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_CORE_EXPORT
+#    else
+#      if defined(BS_CORE_EXPORTS)
+#        define BS_CORE_EXPORT __declspec(dllexport)
+#      else
+#        define BS_CORE_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_CORE_EXPORT
+#    else
+#      if defined(BS_CORE_EXPORTS)
+#        define BS_CORE_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_CORE_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_CORE_HIDDEN
+#else // Linux/Mac settings
+#  define BS_CORE_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_CORE_HIDDEN __attribute__ ((visibility ("hidden")))
 #endif
 #endif
 
 
 #include "BsHString.h"
 #include "BsHString.h"

+ 27 - 14
Source/BansheeEditor/Include/BsEditorPrerequisites.h

@@ -106,20 +106,33 @@
 /** @} */
 /** @} */
 /** @} */
 /** @} */
 
 
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_ED_EXPORTS
-#		define BS_ED_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_ED_EXPORT
-#       else
-#    		define BS_ED_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_ED_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_ED_EXPORT
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_ED_EXPORT
+#    else
+#      if defined(BS_ED_EXPORTS)
+#        define BS_ED_EXPORT __declspec(dllexport)
+#      else
+#        define BS_ED_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_ED_EXPORT
+#    else
+#      if defined(BS_ED_EXPORTS)
+#        define BS_ED_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_ED_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_ED_HIDDEN
+#else // Linux/Mac settings
+#  define BS_ED_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_ED_HIDDEN __attribute__ ((visibility ("hidden")))
 #endif
 #endif
 
 
 namespace bs
 namespace bs

+ 27 - 14
Source/BansheeEngine/Include/BsPrerequisites.h

@@ -90,20 +90,33 @@
 /** @} */
 /** @} */
 /** @} */
 /** @} */
 
 
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_EXPORTS
-#		define BS_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_EXPORT
-#       else
-#    		define BS_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_EXPORT
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_EXPORT
+#    else
+#      if defined(BS_EXPORTS)
+#        define BS_EXPORT __declspec(dllexport)
+#      else
+#        define BS_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_EXPORT
+#    else
+#      if defined(BS_EXPORTS)
+#        define BS_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_HIDDEN
+#else // Linux/Mac settings
+#  define BS_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_HIDDEN __attribute__ ((visibility ("hidden")))
 #endif
 #endif
 
 
 #include "BsGameObject.h"
 #include "BsGameObject.h"

+ 31 - 30
Source/BansheeUtility/Include/BsPlatformDefines.h

@@ -44,7 +44,6 @@
 #	define __PRETTY_FUNCTION__ __FUNCSIG__
 #	define __PRETTY_FUNCTION__ __FUNCSIG__
 #else
 #else
 #   pragma error "No known compiler. "
 #   pragma error "No known compiler. "
-
 #endif
 #endif
 
 
 // Finds the current platform
 // Finds the current platform
@@ -63,25 +62,37 @@
 #   define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
 #   define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
 #endif
 #endif
 
 
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_UTILITY_EXPORT
+#    else
+#      if defined(BS_UTILITY_EXPORTS)
+#        define BS_UTILITY_EXPORT __declspec(dllexport)
+#      else
+#        define BS_UTILITY_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_UTILITY_EXPORT
+#    else
+#      if defined(BS_UTILITY_EXPORTS)
+#        define BS_UTILITY_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_UTILITY_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_UTILITY_HIDDEN
+#else // Linux/Mac settings
+#  define BS_UTILITY_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_UTILITY_HIDDEN __attribute__ ((visibility ("hidden")))
+#endif
+
 // Windows Settings
 // Windows Settings
 #if BS_PLATFORM == BS_PLATFORM_WIN32
 #if BS_PLATFORM == BS_PLATFORM_WIN32
-
-// If we're not including this from a client build, specify that the stuff
-// should get exported. Otherwise, import it.
-#	if defined( BS_STATIC_LIB )
-		// Linux compilers don't have symbol import/export directives.
-#   	define BS_UTILITY_EXPORT
-#   else
-#   	if defined(BS_UTILITY_EXPORTS)
-#       	define BS_UTILITY_EXPORT __declspec( dllexport )
-#   	else
-#           if defined( __MINGW32__ )
-#               define BS_UTILITY_EXPORT
-#           else
-#       	    define BS_UTILITY_EXPORT __declspec( dllimport )
-#           endif
-#   	endif
-#	endif
 // Win32 compilers use _DEBUG for specifying debug builds.
 // Win32 compilers use _DEBUG for specifying debug builds.
 // for MinGW, we set DEBUG
 // for MinGW, we set DEBUG
 #   if defined(_DEBUG) || defined(DEBUG)
 #   if defined(_DEBUG) || defined(DEBUG)
@@ -93,19 +104,10 @@
 #	if BS_COMPILER == BS_COMPILER_INTEL
 #	if BS_COMPILER == BS_COMPILER_INTEL
 #        define BS_THREADLOCAL __declspec(thread)
 #        define BS_THREADLOCAL __declspec(thread)
 #	endif
 #	endif
+#endif
 
 
-#endif // BS_PLATFORM == BS_PLATFORM_WIN32
-
-// Linux/Apple Settings
+// Linux/Mac Settings
 #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
 #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
-
-// Enable GCC symbol visibility
-#   if defined( BS_GCC_VISIBILITY )
-#       define BS_UTILITY_EXPORT  __attribute__ ((visibility("default")))
-#   else
-#       define BS_UTILITY_EXPORT
-#   endif
-
 #   ifdef DEBUG
 #   ifdef DEBUG
 #       define BS_DEBUG_MODE 1
 #       define BS_DEBUG_MODE 1
 #   else
 #   else
@@ -115,5 +117,4 @@
 #	if BS_COMPILER == BS_COMPILER_INTEL
 #	if BS_COMPILER == BS_COMPILER_INTEL
 #        define BS_THREADLOCAL __thread
 #        define BS_THREADLOCAL __thread
 #	endif
 #	endif
-
 #endif
 #endif

+ 27 - 14
Source/SBansheeEditor/Include/BsScriptEditorPrerequisites.h

@@ -5,20 +5,33 @@
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptEnginePrerequisites.h"
 #include "BsEditorPrerequisites.h"
 #include "BsEditorPrerequisites.h"
 
 
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_SCR_BED_EXPORTS
-#		define BS_SCR_BED_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_SCR_BED_EXPORT
-#       else
-#    		define BS_SCR_BED_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_SCR_BED_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_SCR_BED_EXPORT
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_SCR_BED_EXPORT
+#    else
+#      if defined(BS_SCR_BED_EXPORTS)
+#        define BS_SCR_BED_EXPORT __declspec(dllexport)
+#      else
+#        define BS_SCR_BED_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_SCR_BED_EXPORT
+#    else
+#      if defined(BS_SCR_BED_EXPORTS)
+#        define BS_SCR_BED_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_SCR_BED_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_SCR_BED_HIDDEN
+#else // Linux/Mac settings
+#  define BS_SCR_BED_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_SCR_BED_HIDDEN __attribute__ ((visibility ("hidden")))
 #endif
 #endif
 
 
 /** @addtogroup Plugins
 /** @addtogroup Plugins

+ 27 - 14
Source/SBansheeEngine/Include/BsScriptEnginePrerequisites.h

@@ -4,20 +4,33 @@
 
 
 #include "BsMonoPrerequisites.h"
 #include "BsMonoPrerequisites.h"
 
 
-#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
-#	ifdef BS_SCR_BE_EXPORTS
-#		define BS_SCR_BE_EXPORT __declspec(dllexport)
-#	else
-#       if defined( __MINGW32__ )
-#           define BS_SCR_BE_EXPORT
-#       else
-#    		define BS_SCR_BE_EXPORT __declspec(dllimport)
-#       endif
-#	endif
-#elif defined ( BS_GCC_VISIBILITY )
-#    define BS_SCR_BE_EXPORT  __attribute__ ((visibility("default")))
-#else
-#    define BS_SCR_BE_EXPORT
+// DLL export
+#if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
+#  if BS_COMPILER == BS_COMPILER_MSVC
+#    if defined(BS_STATIC_LIB)
+#      define BS_SCR_BE_EXPORT
+#    else
+#      if defined(BS_SCR_BE_EXPORTS)
+#        define BS_SCR_BE_EXPORT __declspec(dllexport)
+#      else
+#        define BS_SCR_BE_EXPORT __declspec(dllimport)
+#      endif
+#	 endif
+#  else
+#    if defined(BS_STATIC_LIB)
+#      define BS_SCR_BE_EXPORT
+#    else
+#      if defined(BS_SCR_BE_EXPORTS)
+#        define BS_SCR_BE_EXPORT __attribute__ ((dllexport))
+#      else
+#        define BS_SCR_BE_EXPORT __attribute__ ((dllimport))
+#      endif
+#	 endif
+#  endif
+#  define BS_SCR_BE_HIDDEN
+#else // Linux/Mac settings
+#  define BS_SCR_BE_EXPORT __attribute__ ((visibility ("default")))
+#  define BS_SCR_BE_HIDDEN __attribute__ ((visibility ("hidden")))
 #endif
 #endif
 
 
 /** @addtogroup Plugins
 /** @addtogroup Plugins