summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2018-08-25 23:56:01 +0200
committerTim-Philipp Müller <tim@centricular.com>2018-09-24 08:39:37 +0100
commit57c8e0146f0e203058c95721527cf50a1dd19f72 (patch)
tree8ba1a268f920dd3fd1e8cdb9d417e78fad6da917
parent46ed0f0489896824f45694b5d8fbdfaac8de6504 (diff)
downloadgstreamer-57c8e0146f0e203058c95721527cf50a1dd19f72.tar.gz
libs: figure out right export define in configure
Add new GST_API_EXPORT in config.h and use that for GST_*_API decorators instead of GST_EXPORT. The right export define depends on the toolchain and whether we're using -fvisibility=hidden or not, so it's better to set it to the right thing directly than hard-coding a compiler whitelist in the public header. We put the export define into config.h instead of passing it via the command line to the compiler because it might contain spaces and brackets and in the autotools scenario we'd have to pass that through multiple layers of plumbing and Makefile/shell escaping and we're just not going to be *that* lucky. The export define is only used if we're compiling our lib, not by external users of the lib headers, so it's not a problem to put it into config.h Also, this means all .c files of libs need to include config.h to get the export marker defined, so fix up a few that didn't include config.h. This commit depends on a common submodule commit that makes gst-glib-gen.mak add an #include "config.h" to generated enum/marshal .c files for the autotools build. https://bugzilla.gnome.org/show_bug.cgi?id=797185
m---------common0
-rw-r--r--configure.ac8
-rw-r--r--gst/gstconfig.h.in2
-rw-r--r--libs/gst/base/base-prelude.h2
-rw-r--r--libs/gst/base/gstdataqueue.c3
-rw-r--r--libs/gst/base/gstflowcombiner.c3
-rw-r--r--libs/gst/base/gstqueuearray.c4
-rw-r--r--libs/gst/check/check-prelude.h2
-rw-r--r--libs/gst/check/gstbufferstraw.c3
-rw-r--r--libs/gst/check/gstconsistencychecker.c3
-rw-r--r--libs/gst/controller/controller-prelude.h2
-rw-r--r--libs/gst/controller/gstargbcontrolbinding.c3
-rw-r--r--libs/gst/controller/gstdirectcontrolbinding.c3
-rw-r--r--libs/gst/controller/gstinterpolationcontrolsource.c3
-rw-r--r--libs/gst/controller/gstlfocontrolsource.c3
-rw-r--r--libs/gst/controller/gsttimedvaluecontrolsource.c3
-rw-r--r--libs/gst/controller/gsttriggercontrolsource.c3
-rw-r--r--libs/gst/controller/meson.build1
-rw-r--r--libs/gst/net/gstnetaddressmeta.c3
-rw-r--r--libs/gst/net/gstnetcontrolmessagemeta.c3
-rw-r--r--libs/gst/net/net-prelude.h2
-rw-r--r--meson.build16
22 files changed, 65 insertions, 10 deletions
diff --git a/common b/common
-Subproject ed78bee437dcbe22e6eef0031d9a29d157c0461
+Subproject cd1dee06bf07f094677d0cf3eea4a2e8c2636b2
diff --git a/configure.ac b/configure.ac
index 79a2b8c8fc..93a6755145 100644
--- a/configure.ac
+++ b/configure.ac
@@ -892,7 +892,13 @@ AC_ARG_WITH([memory-alignment],
dnl Symbol visibility
VISIBILITY_CFLAGS=""
-AS_COMPILER_FLAG([-fvisibility=hidden], [VISIBILITY_CFLAGS="-fvisibility=hidden"])
+AS_COMPILER_FLAG([-fvisibility=hidden], [
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+ AC_DEFINE(GST_API_EXPORT, [extern __attribute__ ((visibility ("default")))], [public symbol export define])
+], [
+ VISIBILITY_CFLAGS=""
+ AC_DEFINE(GST_API_EXPORT, [extern], [public symbol export define])
+])
AC_SUBST(VISIBILITY_CFLAGS)
dnl Check for -Bsymbolic-functions linker flag used to avoid
diff --git a/gst/gstconfig.h.in b/gst/gstconfig.h.in
index a0f57710cd..41bbdde0eb 100644
--- a/gst/gstconfig.h.in
+++ b/gst/gstconfig.h.in
@@ -163,7 +163,7 @@
#ifndef GST_API
# ifdef BUILDING_GST
-#define GST_API GST_EXPORT
+# define GST_API GST_API_EXPORT /* from config.h */
# else
# define GST_API GST_API_IMPORT
# endif
diff --git a/libs/gst/base/base-prelude.h b/libs/gst/base/base-prelude.h
index ae98d38d19..87defde34e 100644
--- a/libs/gst/base/base-prelude.h
+++ b/libs/gst/base/base-prelude.h
@@ -26,7 +26,7 @@
#ifndef GST_BASE_API
#ifdef BUILDING_GST_BASE
-#define GST_BASE_API GST_EXPORT
+#define GST_BASE_API GST_API_EXPORT /* from config.h */
#else
#define GST_BASE_API GST_API_IMPORT
#endif
diff --git a/libs/gst/base/gstdataqueue.c b/libs/gst/base/gstdataqueue.c
index 7e4d71e1ad..d6479bb966 100644
--- a/libs/gst/base/gstdataqueue.c
+++ b/libs/gst/base/gstdataqueue.c
@@ -28,6 +28,9 @@
* also provides size-related functionality. This object should be used for
* any #GstElement that wishes to provide some sort of queueing functionality.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <gst/gst.h>
#include "string.h"
diff --git a/libs/gst/base/gstflowcombiner.c b/libs/gst/base/gstflowcombiner.c
index 831e20257c..8b64a469c7 100644
--- a/libs/gst/base/gstflowcombiner.c
+++ b/libs/gst/base/gstflowcombiner.c
@@ -60,6 +60,9 @@
*
* Since: 1.4
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <gst/gst.h>
#include "gstflowcombiner.h"
diff --git a/libs/gst/base/gstqueuearray.c b/libs/gst/base/gstqueuearray.c
index de8e0b4d85..353921c7c5 100644
--- a/libs/gst/base/gstqueuearray.c
+++ b/libs/gst/base/gstqueuearray.c
@@ -29,7 +29,9 @@
* based on an array instead of linked lists. This reduces the overhead
* caused by memory management by a large factor.
*/
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <string.h>
#include <gst/gst.h>
diff --git a/libs/gst/check/check-prelude.h b/libs/gst/check/check-prelude.h
index f7faf83fd7..0fc272598b 100644
--- a/libs/gst/check/check-prelude.h
+++ b/libs/gst/check/check-prelude.h
@@ -26,7 +26,7 @@
#ifndef GST_CHECK_API
#ifdef BUILDING_GST_CHECK
-#define GST_CHECK_API GST_EXPORT
+#define GST_CHECK_API GST_API_EXPORT /* from config.h */
#else
#define GST_CHECK_API GST_API_IMPORT
#endif
diff --git a/libs/gst/check/gstbufferstraw.c b/libs/gst/check/gstbufferstraw.c
index 93a2c37639..893ae6a4f1 100644
--- a/libs/gst/check/gstbufferstraw.c
+++ b/libs/gst/check/gstbufferstraw.c
@@ -28,6 +28,9 @@
* These macros and functions are for internal use of the unit tests found
* inside the 'check' directories of various GStreamer packages.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "gstbufferstraw.h"
diff --git a/libs/gst/check/gstconsistencychecker.c b/libs/gst/check/gstconsistencychecker.c
index cf1dbf70a0..aff1875edb 100644
--- a/libs/gst/check/gstconsistencychecker.c
+++ b/libs/gst/check/gstconsistencychecker.c
@@ -29,6 +29,9 @@
* These macros and functions are for internal use of the unit tests found
* inside the 'check' directories of various GStreamer packages.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "gstconsistencychecker.h"
diff --git a/libs/gst/controller/controller-prelude.h b/libs/gst/controller/controller-prelude.h
index c7d278cdc8..cd7f0c9196 100644
--- a/libs/gst/controller/controller-prelude.h
+++ b/libs/gst/controller/controller-prelude.h
@@ -26,7 +26,7 @@
#ifndef GST_CONTROLLER_API
#ifdef BUILDING_GST_CONTROLLER
-#define GST_CONTROLLER_API GST_EXPORT
+#define GST_CONTROLLER_API GST_API_EXPORT /* from config.h */
#else
#define GST_CONTROLLER_API GST_API_IMPORT
#endif
diff --git a/libs/gst/controller/gstargbcontrolbinding.c b/libs/gst/controller/gstargbcontrolbinding.c
index 6fe79e310c..b8014a0db9 100644
--- a/libs/gst/controller/gstargbcontrolbinding.c
+++ b/libs/gst/controller/gstargbcontrolbinding.c
@@ -29,6 +29,9 @@
* gobject properties representing a color. A control value of 0.0 will turn the
* color component off and a value of 1.0 will be the color level.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <glib-object.h>
#include <gst/gst.h>
diff --git a/libs/gst/controller/gstdirectcontrolbinding.c b/libs/gst/controller/gstdirectcontrolbinding.c
index 9e5955d1b5..bcc872e500 100644
--- a/libs/gst/controller/gstdirectcontrolbinding.c
+++ b/libs/gst/controller/gstdirectcontrolbinding.c
@@ -31,6 +31,9 @@
* will be clipped. An absolute control binding will not do any value
* transformations.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <glib-object.h>
#include <gst/gst.h>
diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c
index 77b8132591..c0b6c86c55 100644
--- a/libs/gst/controller/gstinterpolationcontrolsource.c
+++ b/libs/gst/controller/gstinterpolationcontrolsource.c
@@ -36,6 +36,9 @@
* All functions are MT-safe.
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <glib-object.h>
#include <gst/gst.h>
diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c
index 2cea4f80d5..1706efddfc 100644
--- a/libs/gst/controller/gstlfocontrolsource.c
+++ b/libs/gst/controller/gstlfocontrolsource.c
@@ -35,6 +35,9 @@
*
* All functions are MT-safe.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <float.h>
diff --git a/libs/gst/controller/gsttimedvaluecontrolsource.c b/libs/gst/controller/gsttimedvaluecontrolsource.c
index 35690f3ba1..66c82a9a34 100644
--- a/libs/gst/controller/gsttimedvaluecontrolsource.c
+++ b/libs/gst/controller/gsttimedvaluecontrolsource.c
@@ -35,6 +35,9 @@
* All functions are MT-safe.
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <glib-object.h>
#include <gst/gst.h>
diff --git a/libs/gst/controller/gsttriggercontrolsource.c b/libs/gst/controller/gsttriggercontrolsource.c
index 6415c0eb4c..0b68cf1d5a 100644
--- a/libs/gst/controller/gsttriggercontrolsource.c
+++ b/libs/gst/controller/gsttriggercontrolsource.c
@@ -36,6 +36,9 @@
*
* All functions are MT-safe.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <glib-object.h>
#include <gst/gst.h>
diff --git a/libs/gst/controller/meson.build b/libs/gst/controller/meson.build
index 93a5beccc4..e592b8193a 100644
--- a/libs/gst/controller/meson.build
+++ b/libs/gst/controller/meson.build
@@ -29,6 +29,7 @@ install_headers(gst_controller_headers, subdir : 'gstreamer-1.0/gst/controller/'
controller_enums = gnome.mkenums_simple('controller-enumtypes',
sources : controller_mkenum_headers,
header_prefix : '#include <gst/controller/controller-prelude.h>',
+ body_prefix : '#include "config.h"',
decorator : 'GST_CONTROLLER_API',
install_header : true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/controller'))
diff --git a/libs/gst/net/gstnetaddressmeta.c b/libs/gst/net/gstnetaddressmeta.c
index de98a1c2f9..262c5788fc 100644
--- a/libs/gst/net/gstnetaddressmeta.c
+++ b/libs/gst/net/gstnetaddressmeta.c
@@ -26,6 +26,9 @@
* in a #GstBuffer so that it network elements can track the to and from address
* of the buffer.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <string.h>
diff --git a/libs/gst/net/gstnetcontrolmessagemeta.c b/libs/gst/net/gstnetcontrolmessagemeta.c
index d6cc525482..4f248345aa 100644
--- a/libs/gst/net/gstnetcontrolmessagemeta.c
+++ b/libs/gst/net/gstnetcontrolmessagemeta.c
@@ -28,6 +28,9 @@
* sending and receiving ancillary data such as unix credentials (See
* #GUnixCredentialsMessage) and Unix file descriptions (See #GUnixFDMessage).
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <string.h>
diff --git a/libs/gst/net/net-prelude.h b/libs/gst/net/net-prelude.h
index e0cf2f8960..47224fe048 100644
--- a/libs/gst/net/net-prelude.h
+++ b/libs/gst/net/net-prelude.h
@@ -26,7 +26,7 @@
#ifndef GST_NET_API
#ifdef BUILDING_GST_NET
-#define GST_NET_API GST_EXPORT
+#define GST_NET_API GST_API_EXPORT /* from config.h */
#else
#define GST_NET_API GST_API_IMPORT
#endif
diff --git a/meson.build b/meson.build
index a36ce455ef..6e8b348787 100644
--- a/meson.build
+++ b/meson.build
@@ -33,6 +33,8 @@ helpers_install_dir = join_paths(libexecdir, 'gstreamer-1.0')
cc = meson.get_compiler('c')
+cdata = configuration_data()
+
# Ignore several spurious warnings for things gstreamer does very commonly
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
@@ -51,11 +53,20 @@ elif cc.has_link_argument('-Wl,-Bsymbolic-functions')
endif
# Symbol visibility
-have_visibility_hidden = cc.has_argument('-fvisibility=hidden')
-if have_visibility_hidden
+have_visibility_hidden = false
+if cc.get_id() == 'msvc'
+ export_define = '__declspec(dllexport) extern'
+elif cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')
+ export_define = 'extern __attribute__ ((visibility ("default")))'
+ have_visibility_hidden = true
+else
+ export_define = 'extern'
endif
+# Passing this through the command line would be too messy
+cdata.set('GST_API_EXPORT', export_define)
+
# Disable strict aliasing
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
@@ -85,7 +96,6 @@ if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
endif
-cdata = configuration_data()
cdata.set_quoted('GST_API_VERSION', apiversion)
cdata.set_quoted('GST_DATADIR', join_paths(prefix, get_option('datadir')))
cdata.set_quoted('LOCALEDIR', join_paths(prefix, get_option('localedir')))