[RFC weston 1/5] libweston: Initial dummy library

Quentin Glidic sardemff7+wayland at sardemff7.net
Tue Feb 9 15:14:40 UTC 2016


From: Quentin Glidic <sardemff7+git at sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 Makefile.am              | 13 ++++++++++++-
 lib/libweston-internal.h | 14 ++++++++++++++
 lib/libweston.c          | 29 +++++++++++++++++++++++++++++
 lib/libweston.h          | 17 +++++++++++++++++
 src/compositor.c         |  7 +++++++
 src/compositor.h         |  1 +
 src/main.c               |  6 ++++++
 7 files changed, 86 insertions(+), 1 deletion(-)
 create mode 100644 lib/libweston-internal.h
 create mode 100644 lib/libweston.c
 create mode 100644 lib/libweston.h

diff --git a/Makefile.am b/Makefile.am
index 623621d..1cfe154 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,6 +42,7 @@ all-local : weston.ini ivi-shell/weston.ini
 AM_CFLAGS = $(GCC_CFLAGS)
 
 AM_CPPFLAGS = 					\
+	-I$(top_srcdir)/lib			\
 	-I$(top_srcdir)/src			\
 	-I$(top_builddir)/src			\
 	-I$(top_builddir)/clients		\
@@ -65,7 +66,7 @@ weston_LDFLAGS = -export-dynamic
 weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
 weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
 weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-	$(DLOPEN_LIBS) -lm -lrt libshared.la
+	$(DLOPEN_LIBS) -lm -lrt libshared.la libweston.la
 
 weston_SOURCES =					\
 	src/git-version.h				\
@@ -97,6 +98,16 @@ weston_SOURCES =					\
 	shared/platform.h				\
 	src/weston-egl-ext.h
 
+noinst_LTLIBRARIES += libweston.la
+
+libweston_la_SOURCES = \
+	lib/libweston.h \
+	lib/libweston.c \
+	$(NULL)
+libweston_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
+libweston_la_LDFLAGS = \
+	-version-info 0:0:0
+
 if SYSTEMD_NOTIFY_SUPPORT
 module_LTLIBRARIES += systemd-notify.la
 systemd_notify_la_LDFLAGS = -module -avoid-version
diff --git a/lib/libweston-internal.h b/lib/libweston-internal.h
new file mode 100644
index 0000000..2e1b7c3
--- /dev/null
+++ b/lib/libweston-internal.h
@@ -0,0 +1,14 @@
+
+#ifndef _LIBWESTON_INTERNAL_H_
+#define _LIBWESTON_INTERNAL_H_
+
+#include <wayland-util.h>
+#include "libweston.h"
+
+int libweston_backend_init(struct libweston_context *context);
+
+struct libweston_context {
+	struct weston_compositor *compositor;
+};
+
+#endif /* _LIBWESTON_INTERNAL_H_ */
diff --git a/lib/libweston.c b/lib/libweston.c
new file mode 100644
index 0000000..801d137
--- /dev/null
+++ b/lib/libweston.c
@@ -0,0 +1,29 @@
+#include "shared/zalloc.h"
+
+#include "libweston-internal.h"
+
+WL_EXPORT struct libweston_context *
+libweston_init(struct weston_compositor *compositor)
+{
+	struct libweston_context *context;
+
+	context = zalloc(sizeof(struct libweston_context));
+	if ( context == NULL )
+		return NULL;
+
+	context->compositor = compositor;
+
+	return context;
+}
+
+WL_EXPORT void
+libweston_uninit(struct libweston_context *context)
+{
+	free(context);
+}
+
+WL_EXPORT int
+libweston_load_backend(struct libweston_context *context, enum libweston_backend preffered)
+{
+	return -1;
+}
diff --git a/lib/libweston.h b/lib/libweston.h
new file mode 100644
index 0000000..ca98df1
--- /dev/null
+++ b/lib/libweston.h
@@ -0,0 +1,17 @@
+
+#ifndef _LIBWESTON_H_
+#define _LIBWESTON_H_
+
+#include "compositor.h"
+
+struct libweston_context;
+
+struct libweston_context *libweston_init(struct weston_compositor *compositor);
+void libweston_uninit(struct libweston_context *context);
+
+enum libweston_backend {
+	LIBWESTON_BACKEND_NONE = 0,
+};
+int libweston_load_backend(struct libweston_context *context, enum libweston_backend preffered);
+
+#endif /* _LIBWESTON_H_ */
diff --git a/src/compositor.c b/src/compositor.c
index 98efb4c..56eefc4 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -54,6 +54,7 @@
 #include "timeline.h"
 
 #include "compositor.h"
+#include "libweston.h"
 #include "scaler-server-protocol.h"
 #include "presentation_timing-server-protocol.h"
 #include "shared/helpers.h"
@@ -4720,6 +4721,10 @@ weston_compositor_create(struct wl_display *display, void *user_data)
 	if (!ec)
 		return NULL;
 
+	ec->libweston = libweston_init(ec);
+	if (!ec->libweston)
+		goto fail;
+
 	ec->wl_display = display;
 	ec->user_data = user_data;
 	wl_signal_init(&ec->destroy_signal);
@@ -5021,6 +5026,8 @@ weston_compositor_destroy(struct weston_compositor *compositor)
 
 	if (compositor->backend)
 		compositor->backend->destroy(compositor);
+	if (compositor->libweston)
+		libweston_uninit(compositor->libweston);
 	free(compositor);
 }
 
diff --git a/src/compositor.h b/src/compositor.h
index 58ae94b..10dd641 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -704,6 +704,7 @@ struct weston_backend {
 struct weston_compositor {
 	struct wl_signal destroy_signal;
 
+	struct libweston_context *libweston;
 	struct wl_display *wl_display;
 	struct weston_shell_interface shell_interface;
 	struct weston_config *config;
diff --git a/src/main.c b/src/main.c
index 1850fa6..922e46e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
 #include <libunwind.h>
 #endif
 
+#include "libweston.h"
 #include "compositor.h"
 #include "../shared/os-compatibility.h"
 #include "../shared/helpers.h"
@@ -657,6 +658,11 @@ static int
 load_backend(struct weston_compositor *compositor, const char *backend,
 	     int *argc, char **argv, struct weston_config *config)
 {
+	enum libweston_backend libweston_backend = LIBWESTON_BACKEND_NONE;
+
+	if (libweston_load_backend(compositor->libweston, libweston_backend) == 0)
+		return 0;
+
 #if 0
 	if (strstr(backend, "drm-backend.so"))
 		return load_drm_backend(compositor, backend, argc, argv, config);
-- 
2.6.4



More information about the wayland-devel mailing list