meson.build: Conditionally build with headless support 74/26674/1
authorMarius Vlad <marius.vlad@collabora.com>
Mon, 27 Sep 2021 15:23:58 +0000 (18:23 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Mon, 27 Sep 2021 21:14:44 +0000 (00:14 +0300)
This allow to build the compositor without headless support, just in
case libweston wasn't built with it.

Bug-AGL: SPEC-4087

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ie848d842ace06b21371de6f70ad18600927f8044

meson.build
src/compositor.c

index f8e97a5..d953fe3 100644 (file)
@@ -203,17 +203,26 @@ if libweston_dep.found()
   if not meson.is_cross_build()
     if not prefix_path.contains('/usr')
       dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
+      dir_path_headless_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-headless.h')
     else
       dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
+      dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
     endif
   else
     message('Building with cross environment')
     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
+    dir_path_headless_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
   endif
 
   # do the test
   if cc.has_header(dir_path_x11_backend)
     config_h.set('HAVE_BACKEND_X11', 1)
+    message('Building with X11 backend')
+  endif
+
+  if cc.has_header(dir_path_headless_backend)
+    config_h.set('HAVE_BACKEND_HEADLESS', 1)
+    message('Building with headless backend')
   endif
 endif
 
index c8f9e60..926cb2c 100644 (file)
@@ -39,7 +39,9 @@
 
 #include <libweston/backend-drm.h>
 #include <libweston/backend-wayland.h>
+#ifdef HAVE_BACKEND_HEADLESS
 #include <libweston/backend-headless.h>
+#endif
 #ifdef HAVE_BACKEND_X11
 #include <libweston/backend-x11.h>
 #endif
@@ -1087,6 +1089,7 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[])
 }
 #endif
 
+#ifdef HAVE_BACKEND_HEADLESS
 static int
 load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
 {
@@ -1134,6 +1137,13 @@ load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
 
        return 0;
 }
+#else
+static int
+load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
+{
+       return -1;
+}
+#endif
 
 static int
 load_backend(struct ivi_compositor *ivi, const char *backend,