testsuite: Fix builder test on Windows/MSVC

Visual Studio does not support things like -Wl,export-dynamic, so we
need to export those symbols by using __declspec(dllexport).  So, we
decorate these with macros which we define accordingly for this purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=785210
This commit is contained in:
Chun-wei Fan 2017-08-01 16:57:11 +08:00
parent 0332dbca94
commit 60297b9fc7
2 changed files with 24 additions and 12 deletions

View File

@ -25,15 +25,21 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#ifdef G_OS_WIN32
# define _BUILDER_TEST_EXPORT __declspec(dllexport)
#else
# define _BUILDER_TEST_EXPORT
#endif
/* exported for GtkBuilder */ /* exported for GtkBuilder */
void signal_normal (GtkWindow *window, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_normal (GtkWindow *window, GParamSpec *spec);
void signal_after (GtkWindow *window, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_after (GtkWindow *window, GParamSpec *spec);
void signal_object (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_object (GtkButton *button, GParamSpec *spec);
void signal_object_after (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_object_after (GtkButton *button, GParamSpec *spec);
void signal_first (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_first (GtkButton *button, GParamSpec *spec);
void signal_second (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_second (GtkButton *button, GParamSpec *spec);
void signal_extra (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_extra (GtkButton *button, GParamSpec *spec);
void signal_extra2 (GtkButton *button, GParamSpec *spec); _BUILDER_TEST_EXPORT void signal_extra2 (GtkButton *button, GParamSpec *spec);
static GtkBuilder * static GtkBuilder *
@ -2335,13 +2341,13 @@ test_level_bar (void)
static GObject *external_object = NULL, *external_object_swapped = NULL; static GObject *external_object = NULL, *external_object_swapped = NULL;
void _BUILDER_TEST_EXPORT void
on_button_clicked (GtkButton *button, GObject *data) on_button_clicked (GtkButton *button, GObject *data)
{ {
external_object = data; external_object = data;
} }
void _BUILDER_TEST_EXPORT void
on_button_clicked_swapped (GObject *data, GtkButton *button) on_button_clicked_swapped (GObject *data, GtkButton *button)
{ {
external_object_swapped = data; external_object_swapped = data;
@ -2559,7 +2565,7 @@ test_template ()
g_assert (GTK_IS_LABEL (my_gtk_grid->priv->label)); g_assert (GTK_IS_LABEL (my_gtk_grid->priv->label));
} }
void _BUILDER_TEST_EXPORT void
on_cellrenderertoggle1_toggled (GtkCellRendererToggle *cell) on_cellrenderertoggle1_toggled (GtkCellRendererToggle *cell)
{ {
} }

View File

@ -1,9 +1,15 @@
gtk_tests_export_dynamic_ldflag = []
if cc.get_id() != 'msvc'
gtk_tests_export_dynamic_ldflag = ['-Wl,--export-dynamic']
endif
tests = [ tests = [
['accel'], ['accel'],
['accessible'], ['accessible'],
['adjustment'], ['adjustment'],
['bitmask', ['../../gtk/gtkallocatedbitmask.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']], ['bitmask', ['../../gtk/gtkallocatedbitmask.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
['builder', [], [], ['-Wl,--export-dynamic']], ['builder', [], [], gtk_tests_export_dynamic_ldflag],
['builderparser'], ['builderparser'],
['cellarea'], ['cellarea'],
['check-icon-names'], ['check-icon-names'],