summaryrefslogtreecommitdiff
path: root/libmediaart
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2017-07-21 12:33:49 +0100
committerCarlos Garnacho <carlosg@gnome.org>2017-08-09 17:12:02 +0200
commit213a8c015b0d233dc32ca3b2699da71c706958a7 (patch)
tree79fee0065119184dbc1edd3d9c55fb13c1b94f5b /libmediaart
parent9c2091d67d581fed07dae8dc4b0e0541bc6be3f8 (diff)
downloadlibmediaart-213a8c015b0d233dc32ca3b2699da71c706958a7.tar.gz
Use compiler symbol visiblity features to hide internal functions
Previously we relied on libtool's -export-symbols-regex feature, but we are hoping to drop GNU Autotools and GNU Libtool in soon in favour of Meson. Meson doesn't have an equivalent feature, instead the advice is to control symbol visibility at compile time. The approach taken in this patch is based on Pango's build system. Pango tells the compiler to hide symbols by default (if possible), and then defines a _PANGO_EXTERN variable at compile time which marks a single symbol as public. In Pango's case there is then further machinary to hide symbols based on deprecation policies but I have not copied that here, instead I used _LIBMEDIAART_EXTERN directly. If a compiler doesn't support hiding symbols then the library we build makes all symbols available, which is exactly what would happen before on platforms where the libtool didn't have an implementation for -export-symbols-regex. See also: http://mesonbuild.com/FAQ.html#how-do-i-do-the-equivalent-of-libtools-exportsymbol-and-exportregex https://git.gnome.org/browse/pango/ https://git.gnome.org/browse/pango/tree/pango/pango-version-macros.h https://gcc.gnu.org/wiki/Visibility https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options (-fvisibility) https://bugzilla.gnome.org/show_bug.cgi?id=783562
Diffstat (limited to 'libmediaart')
-rw-r--r--libmediaart/Makefile.am7
-rw-r--r--libmediaart/cache.h9
-rw-r--r--libmediaart/extract.h14
-rw-r--r--libmediaart/extractgeneric.h6
-rw-r--r--libmediaart/mediaart-macros.h31
5 files changed, 64 insertions, 3 deletions
diff --git a/libmediaart/Makefile.am b/libmediaart/Makefile.am
index da5073a..a6f7bc2 100644
--- a/libmediaart/Makefile.am
+++ b/libmediaart/Makefile.am
@@ -1,6 +1,8 @@
AM_CPPFLAGS = \
$(BUILD_CFLAGS) \
- $(LIBMEDIAART_CFLAGS)
+ $(LIBMEDIAART_CFLAGS) \
+ $(LIBMEDIAART_HIDDEN_VISIBILITY_CFLAGS)
+
#
# Binaries
@@ -49,8 +51,7 @@ endif
endif
libmediaart_@LIBMEDIAART_API_VERSION@_la_LDFLAGS = \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
- -export-symbols-regex '^media_art_.*'
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libmediaart_@LIBMEDIAART_API_VERSION@_la_LIBADD = \
$(BUILD_LIBS) \
diff --git a/libmediaart/cache.h b/libmediaart/cache.h
index 2bb711c..e656011 100644
--- a/libmediaart/cache.h
+++ b/libmediaart/cache.h
@@ -23,27 +23,34 @@
#include <glib.h>
#include <gio/gio.h>
+#include "mediaart-macros.h"
+
#if !defined (__LIBMEDIAART_INSIDE__) && !defined (LIBMEDIAART_COMPILATION)
#error "Only <libmediaart/mediaart.h> must be included directly."
#endif
G_BEGIN_DECLS
+_LIBMEDIAART_EXTERN
gchar * media_art_strip_invalid_entities (const gchar *original);
+_LIBMEDIAART_EXTERN
gboolean media_art_get_path (const gchar *artist,
const gchar *title,
const gchar *prefix,
gchar **cache_path);
+_LIBMEDIAART_EXTERN
gboolean media_art_get_file (const gchar *artist,
const gchar *title,
const gchar *prefix,
GFile **cache_file);
+_LIBMEDIAART_EXTERN
gboolean media_art_remove (const gchar *artist,
const gchar *album,
GCancellable *cancellable,
GError **error);
+_LIBMEDIAART_EXTERN
void media_art_remove_async (const gchar *artist,
const gchar *album,
gint io_priority,
@@ -51,6 +58,8 @@ void media_art_remove_async (const gchar *artist,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
+
+_LIBMEDIAART_EXTERN
gboolean media_art_remove_finish (GObject *source_object,
GAsyncResult *result,
GError **error);
diff --git a/libmediaart/extract.h b/libmediaart/extract.h
index 8f6440a..460015d 100644
--- a/libmediaart/extract.h
+++ b/libmediaart/extract.h
@@ -23,6 +23,8 @@
#include <glib.h>
#include <gio/gio.h>
+#include "mediaart-macros.h"
+
#if !defined (__LIBMEDIAART_INSIDE__) && !defined (LIBMEDIAART_COMPILATION)
#error "Only <libmediaart/mediaart.h> must be included directly."
#endif
@@ -88,6 +90,7 @@ typedef enum {
} MediaArtError;
+_LIBMEDIAART_EXTERN
GQuark media_art_error_quark (void) G_GNUC_CONST;
@@ -122,9 +125,12 @@ struct _MediaArtProcessClass {
};
+_LIBMEDIAART_EXTERN
GType media_art_process_get_type (void) G_GNUC_CONST;
+_LIBMEDIAART_EXTERN
MediaArtProcess *media_art_process_new (GError **error);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_uri (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -133,6 +139,7 @@ gboolean media_art_process_uri (MediaArtProcess *process
const gchar *title,
GCancellable *cancellable,
GError **error);
+_LIBMEDIAART_EXTERN
void media_art_process_uri_async (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -143,9 +150,11 @@ void media_art_process_uri_async (MediaArtProcess *process
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_uri_finish (MediaArtProcess *process,
GAsyncResult *result,
GError **error);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_file (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -154,6 +163,7 @@ gboolean media_art_process_file (MediaArtProcess *process
const gchar *title,
GCancellable *cancellable,
GError **error);
+_LIBMEDIAART_EXTERN
void media_art_process_file_async (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -164,9 +174,11 @@ void media_art_process_file_async (MediaArtProcess *process
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_file_finish (MediaArtProcess *process,
GAsyncResult *result,
GError **error);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_buffer (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -178,6 +190,7 @@ gboolean media_art_process_buffer (MediaArtProcess *process
const gchar *title,
GCancellable *cancellable,
GError **error);
+_LIBMEDIAART_EXTERN
void media_art_process_buffer_async (MediaArtProcess *process,
MediaArtType type,
MediaArtProcessFlags flags,
@@ -191,6 +204,7 @@ void media_art_process_buffer_async (MediaArtProcess *process
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
+_LIBMEDIAART_EXTERN
gboolean media_art_process_buffer_finish (MediaArtProcess *process,
GAsyncResult *result,
GError **error);
diff --git a/libmediaart/extractgeneric.h b/libmediaart/extractgeneric.h
index 8fa114b..b08fe2c 100644
--- a/libmediaart/extractgeneric.h
+++ b/libmediaart/extractgeneric.h
@@ -25,18 +25,24 @@
#include <glib.h>
+#include "mediaart-macros.h"
+
#if !defined (__LIBMEDIAART_INSIDE__) && !defined (LIBMEDIAART_COMPILATION)
#error "Only <libmediaart/mediaart.h> must be included directly."
#endif
G_BEGIN_DECLS
+_LIBMEDIAART_EXTERN
void media_art_plugin_init (gint max_width);
+_LIBMEDIAART_EXTERN
void media_art_plugin_shutdown (void);
+_LIBMEDIAART_EXTERN
gboolean media_art_file_to_jpeg (const gchar *filename,
const gchar *target,
GError **error);
+_LIBMEDIAART_EXTERN
gboolean media_art_buffer_to_jpeg (const unsigned char *buffer,
size_t len,
const gchar *buffer_mime,
diff --git a/libmediaart/mediaart-macros.h b/libmediaart/mediaart-macros.h
new file mode 100644
index 0000000..84b6d79
--- /dev/null
+++ b/libmediaart/mediaart-macros.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017, Sam Thursfield <sam.thursfield@codethink.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __LIBMEDIAART_MACROS_H__
+#define __LIBMEDIAART_MACROS_H__
+
+#if !defined (__LIBMEDIAART_INSIDE__) && !defined (LIBMEDIAART_COMPILATION)
+#error "Only <libmediaart/mediaart.h> must be included directly."
+#endif
+
+#ifndef _LIBMEDIAART_EXTERN
+#define _LIBMEDIAART_EXTERN extern
+#endif
+
+#endif /* __LIBMEDIAART_MACROS_H__ */