main: Use GResource to share introspection XML data
So the same file is used to generate the docs and export the D-Bus object.
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
BUILT_SOURCES = \
|
||||||
|
iio-sensor-proxy-resources.c \
|
||||||
|
iio-sensor-proxy-resources.h
|
||||||
|
|
||||||
|
resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/iio-sensor-proxy.gresource.xml)
|
||||||
|
iio-sensor-proxy-resources.c: iio-sensor-proxy.gresource.xml $(resource_files)
|
||||||
|
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name iio_sensor_proxy $<
|
||||||
|
iio-sensor-proxy-resources.h: iio-sensor-proxy.gresource.xml $(resource_files)
|
||||||
|
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name iio_sensor_proxy $<
|
||||||
|
|
||||||
sbin_PROGRAMS = iio-sensor-proxy
|
sbin_PROGRAMS = iio-sensor-proxy
|
||||||
|
|
||||||
iio_sensor_proxy_SOURCES = \
|
iio_sensor_proxy_SOURCES = \
|
||||||
@@ -13,7 +23,8 @@ iio_sensor_proxy_SOURCES = \
|
|||||||
drv-hwmon-light.c \
|
drv-hwmon-light.c \
|
||||||
drv-iio-buffer-light.c \
|
drv-iio-buffer-light.c \
|
||||||
iio-buffer-utils.h \
|
iio-buffer-utils.h \
|
||||||
iio-buffer-utils.c
|
iio-buffer-utils.c \
|
||||||
|
$(BUILT_SOURCES)
|
||||||
|
|
||||||
iio_sensor_proxy_CPPFLAGS = \
|
iio_sensor_proxy_CPPFLAGS = \
|
||||||
$(IIO_SENSOR_PROXY_CFLAGS) \
|
$(IIO_SENSOR_PROXY_CFLAGS) \
|
||||||
@@ -41,4 +52,7 @@ monitor_sensor_CPPFLAGS = \
|
|||||||
$(WARN_CFLAGS)
|
$(WARN_CFLAGS)
|
||||||
monitor_sensor_LDADD = $(IIO_SENSOR_PROXY_LIBS)
|
monitor_sensor_LDADD = $(IIO_SENSOR_PROXY_LIBS)
|
||||||
|
|
||||||
EXTRA_DIST = test-orientation.c
|
EXTRA_DIST = \
|
||||||
|
test-orientation.c \
|
||||||
|
$(resource_files) \
|
||||||
|
iio-sensor-proxy.gresource.xml
|
||||||
|
@@ -47,26 +47,11 @@
|
|||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
#include "orientation.h"
|
#include "orientation.h"
|
||||||
|
|
||||||
|
#include "iio-sensor-proxy-resources.h"
|
||||||
|
|
||||||
#define SENSOR_PROXY_DBUS_NAME "net.hadess.SensorProxy"
|
#define SENSOR_PROXY_DBUS_NAME "net.hadess.SensorProxy"
|
||||||
#define SENSOR_PROXY_DBUS_PATH "/net/hadess/SensorProxy"
|
#define SENSOR_PROXY_DBUS_PATH "/net/hadess/SensorProxy"
|
||||||
|
|
||||||
static const gchar introspection_xml[] =
|
|
||||||
"<node>"
|
|
||||||
" <interface name='net.hadess.SensorProxy'>"
|
|
||||||
" <method name='Claim'>"
|
|
||||||
" <arg type='s' name='driver-type' direction='in'/>"
|
|
||||||
" </method>"
|
|
||||||
" <method name='Release'>"
|
|
||||||
" <arg type='s' name='driver-type' direction='in'/>"
|
|
||||||
" </method>"
|
|
||||||
" <property name='HasAccelerometer' type='b' access='read'/>"
|
|
||||||
" <property name='AccelerometerOrientation' type='s' access='read'/>"
|
|
||||||
" <property name='HasAmbientLight' type='b' access='read'/>"
|
|
||||||
" <property name='LightLevelUnit' type='s' access='read'/>"
|
|
||||||
" <property name='LightLevel' type='d' access='read'/>"
|
|
||||||
" </interface>"
|
|
||||||
"</node>";
|
|
||||||
|
|
||||||
#define NUM_SENSOR_TYPES DRIVER_TYPE_LIGHT + 1
|
#define NUM_SENSOR_TYPES DRIVER_TYPE_LIGHT + 1
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -484,7 +469,13 @@ name_acquired_handler (GDBusConnection *connection,
|
|||||||
static gboolean
|
static gboolean
|
||||||
setup_dbus (SensorData *data)
|
setup_dbus (SensorData *data)
|
||||||
{
|
{
|
||||||
data->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
|
GBytes *bytes;
|
||||||
|
|
||||||
|
bytes = g_resources_lookup_data ("/net/hadess/SensorProxy/net.hadess.SensorProxy.xml",
|
||||||
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||||
|
NULL);
|
||||||
|
data->introspection_data = g_dbus_node_info_new_for_xml (g_bytes_get_data (bytes, NULL), NULL);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
g_assert (data->introspection_data != NULL);
|
g_assert (data->introspection_data != NULL);
|
||||||
|
|
||||||
data->name_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
|
data->name_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
|
||||||
|
Reference in New Issue
Block a user