liblua visibility and compiler-flags
authorRobin Gareus <robin@gareus.org>
Mon, 4 Apr 2016 11:42:50 +0000 (13:42 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 4 Apr 2016 11:42:50 +0000 (13:42 +0200)
libs/lua/lua.cc
libs/lua/lua/liblua_visibility.h [new file with mode: 0644]
libs/lua/lua/luastate.h

index cc6593a13d963889b594eddb9415989839bd40bf..c86938f12648eae77412c0a96e3af6b864636e35 100644 (file)
@@ -1,16 +1,35 @@
+/* This is a C++ wrapper to compile the lua C code
+ * with settings appropriate for including it with
+ * Ardour.
+ */
+
+#include "lua/liblua_visibility.h"
+
 #if _MSC_VER
-#pragma push_macro("_CRT_SECURE_NO_WARNINGS")
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
+# pragma push_macro("_CRT_SECURE_NO_WARNINGS")
+#  ifndef _CRT_SECURE_NO_WARNINGS
+#    define _CRT_SECURE_NO_WARNINGS
+#  endif
+#elif defined(__clang__)
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wcast-qual"
+#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wcast-qual"
 #endif
 
+// forward ardour's defines to luaconf.h
 #ifdef PLATFORM_WINDOWS
-# define LUA_USE_WINDOWS
+#  define LUA_USE_WINDOWS
 #elif defined __APPLE__
-# define LUA_USE_MACOSX
+#  define LUA_USE_MACOSX
 #else
-# define LUA_USE_LINUX
+#  define LUA_USE_LINUX
+#endif
+
+// forward liblua visibility to luaconf.h
+#ifdef LIBLUA_BUILD_AS_DLL
+#define LUA_BUILD_AS_DLL
 #endif
 
 extern "C"
@@ -27,12 +46,14 @@ extern "C"
 #undef LUA_LIB
 
 // override luaconf.h symbol export
-#undef LUA_API
-#undef LUALIB_API
-#undef LUAMOD_API
-#define LUA_API                extern "C"
-#define LUALIB_API     LUA_API
-#define LUAMOD_API     LUALIB_API
+#ifdef LIBLUA_STATIC // static lib (no DLL)
+#  undef LUA_API
+#  undef LUALIB_API
+#  undef LUAMOD_API
+#  define LUA_API     extern "C"
+#  define LUALIB_API  LUA_API
+#  define LUAMOD_API  LUALIB_API
+#endif
 
 // disable support for extenal libs
 #undef LUA_DL_DLL
@@ -89,8 +110,12 @@ extern "C"
 #pragma warning (pop)
 #endif
 
-}
+} // end extern "C"
 
 #if _MSC_VER
-#pragma pop_macro("_CRT_SECURE_NO_WARNINGS")
+#  pragma pop_macro("_CRT_SECURE_NO_WARNINGS")
+#elif defined(__clang__)
+#  pragma clang diagnostic pop
+#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#  pragma GCC diagnostic pop
 #endif
diff --git a/libs/lua/lua/liblua_visibility.h b/libs/lua/lua/liblua_visibility.h
new file mode 100644 (file)
index 0000000..494f936
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef __liblua_visibility_h__
+#define __liblua_visibility_h__
+
+#if defined(COMPILER_MSVC)
+#  define LIBLUA_DLL_IMPORT __declspec(dllimport)
+#  define LIBLUA_DLL_EXPORT __declspec(dllexport)
+#  define LIBLUA_DLL_LOCAL
+#else
+#  define LIBLUA_DLL_IMPORT __attribute__ ((visibility ("default")))
+#  define LIBLUA_DLL_EXPORT __attribute__ ((visibility ("default")))
+#  define LIBLUA_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
+#endif
+
+
+#ifdef COMPILER_MSVC
+// MSVC: build liblua as DLL
+#  define LIBLUA_BUILD_AS_DLL
+#else
+// others currently use a static lib (incl. with libardour)
+#  define LIBLUA_STATIC
+#endif
+
+
+#ifdef LIBLUA_STATIC
+#  define LIBLUA_API
+#else
+// define when building the DLL (instead of using it)
+#  ifdef LIBLUA_DLL_EXPORTS
+#    define LIBLUA_API LIBLUA_DLL_EXPORT
+#  else
+#    define LIBLUA_API LIBLUA_DLL_IMPORT
+#  endif
+#endif
+
+#endif /* __liblua_visibility_h__ */
index 60fa0052ddb42ab7ed1123e2ddfbc82e87b6b2cd..88ffc93486396b5eea462e58c76aba92d0f656f0 100644 (file)
 #include <string>
 #include <sigc++/sigc++.h>
 
+#include "lua/liblua_visibility.h"
 #include "lua/lua.h"
 
-class LuaState {
+class LIBLUA_API LuaState {
 public:
        LuaState();
        LuaState(lua_State *ls);