[gtk/gtk-3-24-meson: 85/99] meson: build print backends



commit 44e471c42f6ef46536052e9b0fca4381aa1b4dff
Author: Christoph Reiter <creiter src gnome org>
Date:   Sun Mar 31 11:32:44 2019 +0200

    meson: build print backends
    
    This changes the configure option into two states:
    auto: build all that can be build (default)
    A list of backend names: build them and fail if we can't
    
    "papi" is missing because it's not in Debian and I can't test it.

 .gitlab-ci/Dockerfile             |   1 +
 .gitlab-ci/test-docker-meson.sh   |   1 +
 config.h.meson                    |   2 +
 gtk/meson.build                   |   2 -
 meson_options.txt                 |   4 +-
 modules/meson.build               |   8 +-
 modules/printbackends/Makefile.am |   3 +
 modules/printbackends/meson.build | 177 ++++++++++++++++++++++++++++++++++++++
 8 files changed, 187 insertions(+), 11 deletions(-)
---
diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile
index d9fa23d31d..8b4978eefb 100644
--- a/.gitlab-ci/Dockerfile
+++ b/.gitlab-ci/Dockerfile
@@ -49,6 +49,7 @@ RUN dnf -y install \
     python3-pip \
     python3-wheel \
     redhat-rpm-config \
+    rest-devel \
     vulkan-devel \
     wayland-devel \
     wayland-protocols-devel \
diff --git a/.gitlab-ci/test-docker-meson.sh b/.gitlab-ci/test-docker-meson.sh
index 2679417905..0cd5636170 100755
--- a/.gitlab-ci/test-docker-meson.sh
+++ b/.gitlab-ci/test-docker-meson.sh
@@ -15,6 +15,7 @@ meson \
     -Dman-pages=true \
     -Dbroadway-backend=true \
     -Dxinerama=yes \
+    -Dprint-backends="file,lpr,test,cloudprint,cups" \
     _build
 
 cd _build
diff --git a/config.h.meson b/config.h.meson
index 9fd690f966..fe5f861927 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -327,3 +327,5 @@
 #mesondefine HAVE_DEV_EVDEV_INPUT_H
 
 #mesondefine HAVE_TRUNC
+
+#mesondefine GTK_PRINT_BACKENDS
diff --git a/gtk/meson.build b/gtk/meson.build
index 06ba5cc9e3..609ebca9e2 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -5,8 +5,6 @@ subdir('inspector')
 gtk_cargs = [
   '-DGTK_COMPILATION',
   '-DG_LOG_DOMAIN="Gtk"',
-  # FIXME, support other backends
-  '-DGTK_PRINT_BACKENDS="file"',
   '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
   '-DGTK_BINARY_VERSION="@0@"'.format(gtk_binary_version),
   '-DGTK_HOST="@0@"'.format(host_machine.system()),
diff --git a/meson_options.txt b/meson_options.txt
index 683fff669a..21ca1ca2c8 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,8 +17,8 @@ option('cloudproviders', type: 'boolean', value: false,
   description : 'Enable the cloudproviders support')
 
 # Print backends
-option('print-backends', type : 'string', value : 'cups,file',
-  description : 'Build the specified print backends (comma-separated list, "all", or "none")')
+option('print-backends', type : 'string', value : 'auto',
+  description : 'Build the specified print backends (comma-separated list, any of 
"cloudprint,cups,file,lpr,papi,test" or "auto")')
 option('colord', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
   description : 'Build colord support for the CUPS printing backend')
 
diff --git a/modules/meson.build b/modules/meson.build
index e4b4b7905b..1ae93fdaf7 100644
--- a/modules/meson.build
+++ b/modules/meson.build
@@ -1,8 +1,2 @@
-# TODO
-#if os_unix
-#  subdir('printbackends')
-#else
-  print_backends = []
-#endif
-
 subdir('input')
+subdir('printbackends')
diff --git a/modules/printbackends/Makefile.am b/modules/printbackends/Makefile.am
index 7d6680dffb..f292fea851 100644
--- a/modules/printbackends/Makefile.am
+++ b/modules/printbackends/Makefile.am
@@ -20,4 +20,7 @@ endif
 
 DIST_SUBDIRS = cloudprint cups file lpr test papi
 
+EXTRA_DIST += \
+       meson.build
+
 -include $(top_srcdir)/git.mk
diff --git a/modules/printbackends/meson.build b/modules/printbackends/meson.build
new file mode 100644
index 0000000000..894572be0c
--- /dev/null
+++ b/modules/printbackends/meson.build
@@ -0,0 +1,177 @@
+# Print backend config: 'auto' means all backends we have dependencies for,
+# the specific backend names mean we should fail if dependencies are missing
+all_print_backends = [
+  'cloudprint',
+  'cups',
+  'file',
+  'lpr',
+  'papi',
+  'test',
+]
+
+auto_print_backends = []
+foreach backend: all_print_backends
+  if backend != 'test' and os_unix
+    auto_print_backends += backend
+  endif
+endforeach
+
+print_strict_deps = true
+if get_option('print-backends') == 'auto'
+  enabled_print_backends = auto_print_backends
+  print_strict_deps = false
+else
+  wanted_print_backends = get_option('print-backends').split(',')
+  enabled_print_backends = []
+  foreach backend: wanted_print_backends
+    if backend != ''
+      if not all_print_backends.contains(backend)
+        error('print backend \'@0@\' unknown'.format(backend))
+      endif
+      enabled_print_backends += backend
+    endif
+  endforeach
+endif
+
+print_backends = []
+
+if not enabled_print_backends.contains('file')
+  if os_unix
+    error('\'file\' print backed needs to be enabled')
+  endif
+else
+  print_backends += ['file']
+endif
+
+if enabled_print_backends.contains('lpr')
+  print_backends += ['lpr']
+endif
+
+if enabled_print_backends.contains('test')
+  print_backends += ['test']
+endif
+
+if enabled_print_backends.contains('papi')
+  # TODO
+  if print_strict_deps
+    error('\'papi\' backend not supported with meson yet')
+  endif
+endif
+
+if enabled_print_backends.contains('cloudprint')
+  rest_dep = dependency('rest-0.7', required : print_strict_deps)
+  json_glib_dep = dependency('json-glib-1.0', required : print_strict_deps)
+  if rest_dep.found() and json_glib_dep.found()
+    print_backends += ['cloudprint']
+  else
+    message('\'cloudprint\' backend disabled: missing dependencies')
+  endif
+endif
+
+if enabled_print_backends.contains('cups')
+  cups_error = ''
+  if cc.has_header('cups/cups.h')
+    cups_major_version = cc.compute_int('CUPS_VERSION_MAJOR', prefix : '#include <cups/cups.h>')
+    cups_minor_version = cc.compute_int('CUPS_VERSION_MINOR', prefix : '#include <cups/cups.h>')
+    message('Found CUPS version: @0@.@1@'.format(cups_major_version, cups_minor_version))
+    if cups_major_version > 1 or cups_minor_version >= 2
+      if cups_major_version > 1 or cups_minor_version >= 6
+        cdata.set('HAVE_CUPS_API_1_6', 1)
+      endif
+
+      if cc.compiles('#include <cups/http.h> \n http_t http; char *s = http.authstring;')
+        cdata.set('HAVE_HTTP_AUTHSTRING', 1,
+          description :'Define if cups http_t authstring field is accessible')
+      endif
+      libcups = cc.find_library('cups', required : true)
+      if libcups.found() and cc.has_function('httpGetAuthString', dependencies : libcups)
+        cdata.set('HAVE_HTTPGETAUTHSTRING', 1)
+      endif
+    else
+      cups_error = 'Need CUPS version >= 1.2'
+    endif
+  else
+    cups_error = 'Cannot find CUPS headers in default prefix.'
+  endif
+
+  enable_colord = get_option('colord')
+  if enable_colord != 'no'
+    want_colord = enable_colord == 'yes'
+    colord_dep = dependency('colord', version: '>= 0.1.9', required: want_colord)
+    cdata.set('HAVE_COLORD', colord_dep.found())
+  else
+    cups_colord_dep = []
+  endif
+
+  if cups_error != ''
+    if print_strict_deps
+      error(cups_error)
+    else
+      message(cups_error)
+    endif
+  else
+    print_backends += ['cups']
+  endif
+endif
+
+cdata.set_quoted('GTK_PRINT_BACKENDS', ','.join(print_backends))
+
+# Building
+
+printbackends_args = [
+  '-DGTK_COMPILATION',
+  '-DGTK_DISABLE_DEPRECATION_WARNINGS',
+  '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
+]
+printbackends_subdir = 'gtk-3.0/@0@/printbackends'.format(gtk_binary_version)
+printbackends_install_dir = join_paths(get_option('libdir'), printbackends_subdir)
+
+if print_backends.contains('file')
+  shared_module('printbackend-file',
+                'file/gtkprintbackendfile.c',
+                c_args: printbackends_args,
+                dependencies: libgtk_dep,
+                install_dir: printbackends_install_dir,
+                install : true)
+endif
+
+if print_backends.contains('lpr')
+  shared_module('printbackend-lpr',
+                'lpr/gtkprintbackendlpr.c',
+                c_args: printbackends_args,
+                dependencies: libgtk_dep,
+                install_dir: printbackends_install_dir,
+                install : true)
+endif
+
+if print_backends.contains('test')
+  shared_module('printbackend-test',
+                'test/gtkprintbackendtest.c',
+                c_args: printbackends_args,
+                dependencies: libgtk_dep,
+                install_dir: printbackends_install_dir,
+                install : true)
+endif
+
+if print_backends.contains('cloudprint')
+    shared_module('printbackend-cloudprint',
+                  'cloudprint/gtkprintbackendcloudprint.c',
+                  'cloudprint/gtkprintercloudprint.c',
+                  'cloudprint/gtkcloudprintaccount.c',
+                  c_args: printbackends_args,
+                  dependencies: [ libgtk_dep, rest_dep, json_glib_dep ],
+                  install_dir: printbackends_install_dir,
+                  install : true)
+endif
+
+if print_backends.contains('cups')
+  shared_module('printbackend-cups',
+                'cups/gtkprintbackendcups.c',
+                'cups/gtkprintercups.c',
+                'cups/gtkcupsutils.c',
+                'cups/gtkcupssecretsutils.c',
+                c_args: printbackends_args,
+                dependencies: [libgtk_dep, libcups, colord_dep],
+                install_dir: printbackends_install_dir,
+                install : true)
+endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]