[jsonrpc-glib] abi: set visibility rules to hidden by default
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jsonrpc-glib] abi: set visibility rules to hidden by default
- Date: Mon, 12 Feb 2018 00:37:35 +0000 (UTC)
commit 5d776c0d30afe4cefcee31c0531152790f7c2770
Author: Christian Hergert <chergert redhat com>
Date: Sun Feb 11 16:37:20 2018 -0800
abi: set visibility rules to hidden by default
This enforces our visibility rules to match our export macros.
meson.build | 31 +++++++++++++++++++++++--------
src/jsonrpc-client.c | 2 ++
src/jsonrpc-client.h | 1 +
src/jsonrpc-input-stream.c | 2 ++
src/jsonrpc-input-stream.h | 1 +
src/jsonrpc-message.c | 2 ++
src/jsonrpc-output-stream.c | 2 ++
src/jsonrpc-output-stream.h | 1 +
src/jsonrpc-server.c | 2 ++
src/jsonrpc-server.h | 1 +
src/meson.build | 1 +
11 files changed, 38 insertions(+), 8 deletions(-)
---
diff --git a/meson.build b/meson.build
index c224e61..1ff3c10 100644
--- a/meson.build
+++ b/meson.build
@@ -30,11 +30,6 @@ config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', 'libjsonrpc_glib')
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
-configure_file(
- output: 'config.h',
- configuration: config_h,
-)
-
add_project_arguments([
'-DHAVE_CONFIG_H',
'-I' + meson.build_root(),
@@ -87,9 +82,29 @@ foreach arg: test_c_args
global_c_args += arg
endif
endforeach
-add_project_arguments(
- global_c_args,
- language: 'c'
+
+add_project_arguments(global_c_args, language: 'c')
+
+# Detect and set symbol visibility
+hidden_visibility_args = []
+if get_option('default_library') != 'static'
+ if host_machine.system() == 'windows'
+ config_h.set('DLL_EXPORT', true)
+ if cc.get_id() == 'msvc'
+ config_h.set('_JSONRPC_EXTERN', '__declspec(dllexport) extern')
+ elif cc.has_argument('-fvisibility=hidden')
+ config_h.set('_JSONRPC_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
+ hidden_visibility_args = ['-fvisibility=hidden']
+ endif
+ elif cc.has_argument('-fvisibility=hidden')
+ config_h.set('_JSONRPC_EXTERN', '__attribute__((visibility("default"))) extern')
+ hidden_visibility_args = ['-fvisibility=hidden']
+ endif
+endif
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
)
# Setup various paths that subdirectory meson.build files need
diff --git a/src/jsonrpc-client.c b/src/jsonrpc-client.c
index a3c6618..2868f80 100644
--- a/src/jsonrpc-client.c
+++ b/src/jsonrpc-client.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "jsonrpc-client"
+#include "config.h"
+
/**
* SECTION:jsonrpc-client
* @title: JsonrpcClient
diff --git a/src/jsonrpc-client.h b/src/jsonrpc-client.h
index 09ad121..55e9a90 100644
--- a/src/jsonrpc-client.h
+++ b/src/jsonrpc-client.h
@@ -37,6 +37,7 @@ typedef enum
JSONRPC_CLIENT_ERROR_INTERNAL_ERROR = -32603,
} JsonrpcClientError;
+JSONRPC_AVAILABLE_IN_3_26
G_DECLARE_DERIVABLE_TYPE (JsonrpcClient, jsonrpc_client, JSONRPC, CLIENT, GObject)
struct _JsonrpcClientClass
diff --git a/src/jsonrpc-input-stream.c b/src/jsonrpc-input-stream.c
index 5ce3d61..b828985 100644
--- a/src/jsonrpc-input-stream.c
+++ b/src/jsonrpc-input-stream.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "jsonrpc-input-stream"
+#include "config.h"
+
#include <errno.h>
#include <json-glib/json-glib.h>
#include <string.h>
diff --git a/src/jsonrpc-input-stream.h b/src/jsonrpc-input-stream.h
index d69fb38..8bd93b1 100644
--- a/src/jsonrpc-input-stream.h
+++ b/src/jsonrpc-input-stream.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
#define JSONRPC_TYPE_INPUT_STREAM (jsonrpc_input_stream_get_type())
+JSONRPC_AVAILABLE_IN_3_26
G_DECLARE_DERIVABLE_TYPE (JsonrpcInputStream, jsonrpc_input_stream, JSONRPC, INPUT_STREAM, GDataInputStream)
struct _JsonrpcInputStreamClass
diff --git a/src/jsonrpc-message.c b/src/jsonrpc-message.c
index 5d3f0b1..eb705bb 100644
--- a/src/jsonrpc-message.c
+++ b/src/jsonrpc-message.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "jsonrpc-message"
+#include "config.h"
+
#include <string.h>
#include "jsonrpc-message.h"
diff --git a/src/jsonrpc-output-stream.c b/src/jsonrpc-output-stream.c
index c7a9d77..e43c1a9 100644
--- a/src/jsonrpc-output-stream.c
+++ b/src/jsonrpc-output-stream.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "jsonrpc-output-stream"
+#include "config.h"
+
#include <string.h>
#include "jsonrpc-output-stream.h"
diff --git a/src/jsonrpc-output-stream.h b/src/jsonrpc-output-stream.h
index 9de2d93..cf8f2ef 100644
--- a/src/jsonrpc-output-stream.h
+++ b/src/jsonrpc-output-stream.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
#define JSONRPC_TYPE_OUTPUT_STREAM (jsonrpc_output_stream_get_type())
+JSONRPC_AVAILABLE_IN_3_26
G_DECLARE_DERIVABLE_TYPE (JsonrpcOutputStream, jsonrpc_output_stream, JSONRPC, OUTPUT_STREAM,
GDataOutputStream)
struct _JsonrpcOutputStreamClass
diff --git a/src/jsonrpc-server.c b/src/jsonrpc-server.c
index 51f732a..e3c9dc3 100644
--- a/src/jsonrpc-server.c
+++ b/src/jsonrpc-server.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "jsonrpc-server"
+#include "config.h"
+
#include <stdlib.h>
#include "jsonrpc-input-stream.h"
diff --git a/src/jsonrpc-server.h b/src/jsonrpc-server.h
index 323c643..ff4de07 100644
--- a/src/jsonrpc-server.h
+++ b/src/jsonrpc-server.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
#define JSONRPC_TYPE_SERVER (jsonrpc_server_get_type())
+JSONRPC_AVAILABLE_IN_3_26
G_DECLARE_DERIVABLE_TYPE (JsonrpcServer, jsonrpc_server, JSONRPC, SERVER, GObject)
struct _JsonrpcServerClass
diff --git a/src/meson.build b/src/meson.build
index d81debb..8f1161c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -52,6 +52,7 @@ libjsonrpc_glib = library(
'jsonrpc-glib-' + apiversion,
libjsonrpc_glib_sources,
+ c_args: hidden_visibility_args,
dependencies: libjsonrpc_glib_deps,
soversion: soversion,
version: libversion,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]