[glib/fix-gresource-export-msvc] glib-compile-resources: Fix exporting on Visual Studio
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/fix-gresource-export-msvc] glib-compile-resources: Fix exporting on Visual Studio
- Date: Thu, 30 Apr 2020 10:03:29 +0000 (UTC)
commit d308fa9fccf179d9464a5dcbba28b63bdb2c68e9
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Apr 29 19:04:36 2020 +0800
glib-compile-resources: Fix exporting on Visual Studio
Have the generated code append "__declspec(dllexport)" before "extern" if
the generated code is being built on Windows on Visual Studio-style
compilers when --internal is not being used, so that we also export the
symbols from the generated code, if needed.
On non-Windows or non-Visual Studio-style compilers, we use "extern" as
we did before.
gio/glib-compile-resources.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index 9b82ebade..052404f53 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -1061,6 +1061,9 @@ main (int argc, char **argv)
guint8 *data;
gsize data_size;
gsize i;
+ const char *export = "#if defined (G_OS_WIN32) && defined (_MSC_VER)\n"
+ "__declspec(dllexport)\n"
+ "#endif\n";
if (!g_file_get_contents (binary_target, (char **)&data,
&data_size, NULL))
@@ -1081,6 +1084,9 @@ main (int argc, char **argv)
return 1;
}
+ if (internal)
+ export = "";
+
g_fprintf (file,
"#include <gio/gio.h>\n"
"\n"
@@ -1140,30 +1146,36 @@ main (int argc, char **argv)
g_fprintf (file,
"\n"
"static GStaticResource static_resource = { %s_resource_data.data, sizeof
(%s_resource_data.data)%s, NULL, NULL, NULL };\n"
- "%s GResource *%s_get_resource (void);\n"
+ "\n"
+ "%s%s\n"
+ "GResource *%s_get_resource (void);\n"
"GResource *%s_get_resource (void)\n"
"{\n"
" return g_static_resource_get_resource (&static_resource);\n"
"}\n",
- c_name, c_name, (external_data ? "" : " - 1 /* nul terminator */"), linkage, c_name, c_name);
+ c_name, c_name, (external_data ? "" : " - 1 /* nul terminator */"),
+ export, linkage, c_name, c_name);
if (manual_register)
{
g_fprintf (file,
"\n"
- "%s void %s_unregister_resource (void);\n"
+ "%s%s\n"
+ "void %s_unregister_resource (void);\n"
"void %s_unregister_resource (void)\n"
"{\n"
" g_static_resource_fini (&static_resource);\n"
"}\n"
"\n"
- "%s void %s_register_resource (void);\n"
+ "%s%s\n"
+ "void %s_register_resource (void);\n"
"void %s_register_resource (void)\n"
"{\n"
" g_static_resource_init (&static_resource);\n"
"}\n",
- linkage, c_name, c_name, linkage, c_name, c_name);
+ export, linkage, c_name, c_name,
+ export, linkage, c_name, c_name);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]