capture: avoid GObject in libsysprof-capture-2.a

The point of this file was to be easily usable by applications that want
to generate capture files (or proxy them). The intention here is that we
only have SpCaptureReader/SpCaptureWriter (and associated bits necessary
to support that).

This makes sure that we do not use GObject from the libsysprof-capture-2.a
while still having GType's in the libsysprof-2.so dynamic library.

We also invert the GObject macro check so that the default is to not
register a GType which increases the chances that copy/paste code does
not run into double-registering a GType if used with an application that
links against libsysprof-2. (One such example could be if Gtk uses this
code for timers, as it would break Sysprof itself).
This commit is contained in:
Christian Hergert
2018-05-21 13:52:02 -07:00
parent 5cc838fd47
commit b3bf7968ad
11 changed files with 30 additions and 21 deletions

View File

@ -13,10 +13,15 @@ capture_sources = [
'sp-capture-writer.c',
]
static_capture_sources = [
'sp-capture-reader.c',
'sp-capture-writer.c',
]
libsysprof_headers += files(capture_headers)
libsysprof_sources += files(capture_sources)
libsysprof_capture_sources += files(capture_sources)
libsysprof_capture_sources += files(static_capture_sources)
install_headers(capture_headers,
subdir: join_paths(libsysprof_header_subdir, 'capture'))

View File

@ -19,6 +19,8 @@
#ifndef SP_CAPTURE_CONDITION_H
#define SP_CAPTURE_CONDITION_H
#include <glib-object.h>
#include "capture/sp-capture-types.h"
G_BEGIN_DECLS

View File

@ -42,7 +42,7 @@ struct _SpCaptureReader
gint64 end_time;
};
#ifndef SP_DISABLE_GOBJECT
#ifdef SP_ENABLE_GOBJECT
G_DEFINE_BOXED_TYPE (SpCaptureReader, sp_capture_reader,
sp_capture_reader_ref, sp_capture_reader_unref)
#endif

View File

@ -59,7 +59,7 @@ gboolean sp_capture_reader_save_as (SpCapt
const gchar *filename,
GError **error);
#ifndef SP_DISABLE_GOBJECT
#ifdef SP_ENABLE_GOBJECT
# define SP_TYPE_CAPTURE_READER (sp_capture_reader_get_type())
GType sp_capture_reader_get_type (void);
#endif

View File

@ -21,7 +21,7 @@
#include <glib.h>
#ifndef SP_DISABLE_GOBJECT
#ifdef SP_ENABLE_GOBJECT
# include <glib-object.h>
#endif

View File

@ -97,7 +97,7 @@ struct _SpCaptureWriter
SpCaptureStat stat;
};
#ifndef SP_DISABLE_GOBJECT
#ifdef SP_ENABLE_GOBJECT
G_DEFINE_BOXED_TYPE (SpCaptureWriter, sp_capture_writer,
sp_capture_writer_ref, sp_capture_writer_unref)
#endif

View File

@ -120,7 +120,7 @@ gboolean _sp_capture_writer_set_time_range (SpCaptureWriter *
gint64 start_time,
gint64 end_time) G_GNUC_INTERNAL;
#ifndef SP_DISABLE_GOBJECT
#ifdef SP_ENABLE_GOBJECT
# define SP_TYPE_CAPTURE_WRITER (sp_capture_writer_get_type())
GType sp_capture_writer_get_type (void);
#endif