[gtk+/wip/meson: 93/136] meson: modules: add printbackends



commit 30af41d8fb39faa0ccf4ae09e7dbed211f8b72e3
Author: Tim-Philipp Müller <tim centricular com>
Date:   Wed Mar 22 16:48:56 2017 +0000

    meson: modules: add printbackends
    
    The cups checks might not work properly everywhere yet,
    since they don't use cups-config and parse the output yet.

 config.h.meson                               |    3 -
 gtk/meson.build                              |    4 +
 meson.build                                  |   14 ++--
 meson_options.txt                            |    8 ++
 modules/meson.build                          |    5 +
 modules/printbackends/cloudprint/meson.build |    7 ++
 modules/printbackends/cups/meson.build       |    8 ++
 modules/printbackends/file/meson.build       |    5 +
 modules/printbackends/lpr/meson.build        |    5 +
 modules/printbackends/meson.build            |  116 ++++++++++++++++++++++++++
 modules/printbackends/papi/meson.build       |    6 ++
 11 files changed, 172 insertions(+), 9 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 122a1f3..0e8b63f 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -95,9 +95,6 @@
 /* Define to 1 if you have the `nearbyint' function. */
 #mesondefine HAVE_NEARBYINT
 
-/* Define to 1 if libpapi available */
-#mesondefine HAVE_PAPI
-
 /* Define to 1 if you have the `posix_fallocate' function. */
 #mesondefine HAVE_POSIX_FALLOCATE
 
diff --git a/gtk/meson.build b/gtk/meson.build
index 1b0cb53..85fe62a 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -628,6 +628,10 @@ if os_win32
     'gtkfilechoosernativewin32.c',
     'gtkwin32.c',
   ]
+
+  if cc.has_header_symbol('windows.h', 'IPrintDialogCallback')
+    cdata.set('HAVE_IPRINTDIALOGCALLBACK', 1)
+  endif
 endif
 
 if x11_enabled
diff --git a/meson.build b/meson.build
index 0665c6d..22877f3 100644
--- a/meson.build
+++ b/meson.build
@@ -354,20 +354,22 @@ else
   message('Vulkan support explicitly disabled')
 endif
 
-configure_file(
-  input : 'config.h.meson',
-  output: 'config.h',
-  configuration: cdata
-)
-
 subdir('gdk')
 subdir('gsk')
 subdir('gtk')
 subdir('demos')
+subdir('modules')
 subdir('tests')
 subdir('testsuite')
 subdir('examples')
 
+# config.h
+
+configure_file(
+  input : 'config.h.meson',
+  output: 'config.h',
+  configuration: cdata)
+
 # pkg-config files - bit of a mess all of this
 
 pkgconf = configuration_data()
diff --git a/meson_options.txt b/meson_options.txt
index fe71ac3..767be8f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,3 +8,11 @@ option('enable-mir-backend', type: 'boolean', value: 'false',
   description : 'Enable the Mir gdk backend (UNTESTED, NEEDS WORK)')
 option('enable-vulkan', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
   description : 'Enable support for the Vulkan graphics API')
+option('enable-test-print-backend', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'no',
+  description : 'Enable the test print backend')
+option('enable-cups-print-backend', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
+  description : 'Enable the CUPS print backend')
+option('enable-papi-print-backend', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
+  description : 'Enable the papi print backend')
+option('enable-cloudprint-print-backend', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
+  description : 'Enable the cloudprint print backend')
diff --git a/modules/meson.build b/modules/meson.build
new file mode 100644
index 0000000..b855765
--- /dev/null
+++ b/modules/meson.build
@@ -0,0 +1,5 @@
+#subdir('input')
+
+if os_unix
+  subdir('printbackends')
+endif
diff --git a/modules/printbackends/cloudprint/meson.build b/modules/printbackends/cloudprint/meson.build
new file mode 100644
index 0000000..0a575f0
--- /dev/null
+++ b/modules/printbackends/cloudprint/meson.build
@@ -0,0 +1,7 @@
+shared_module('printbackend-cloudprint',
+  'gtkprintbackendcloudprint.c',
+  'gtkprintercloudprint.c',
+  'gtkcloudprintaccount.c',
+  c_args : ['-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED'],
+  dependencies : [libgtk_dep, rest_dep, json_glib_dep],
+  install_dir : printbackends_install_dir)
diff --git a/modules/printbackends/cups/meson.build b/modules/printbackends/cups/meson.build
new file mode 100644
index 0000000..a709a9f
--- /dev/null
+++ b/modules/printbackends/cups/meson.build
@@ -0,0 +1,8 @@
+shared_module('printbackend-cups',
+  'gtkprintbackendcups.c',
+  'gtkprintercups.c',
+  'gtkcupsutils.c',
+  'gtkcupssecretsutils.c',
+  c_args : ['-DGTK_COMPILATION', '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED'],
+  dependencies : [libgtk_dep, libcups, colord_dep],
+  install_dir : printbackends_install_dir)
diff --git a/modules/printbackends/file/meson.build b/modules/printbackends/file/meson.build
new file mode 100644
index 0000000..df29254
--- /dev/null
+++ b/modules/printbackends/file/meson.build
@@ -0,0 +1,5 @@
+shared_module('printbackend-file',
+  'gtkprintbackendfile.c',
+  c_args : ['-DGTK_COMPILATION', '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED'],
+  dependencies : libgtk_dep,
+  install_dir : printbackends_install_dir)
diff --git a/modules/printbackends/lpr/meson.build b/modules/printbackends/lpr/meson.build
new file mode 100644
index 0000000..3401997
--- /dev/null
+++ b/modules/printbackends/lpr/meson.build
@@ -0,0 +1,5 @@
+shared_module('printbackend-lpr',
+  'gtkprintbackendlpr.c',
+  c_args : ['-DGTK_COMPILATION', '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED'],
+  dependencies : libgtk_dep,
+  install_dir : printbackends_install_dir)
diff --git a/modules/printbackends/meson.build b/modules/printbackends/meson.build
new file mode 100644
index 0000000..80c9469
--- /dev/null
+++ b/modules/printbackends/meson.build
@@ -0,0 +1,116 @@
+print_backends = ['file']
+
+# Checks to see if we should compile with CUPS backend for GTK+
+enable_cups = get_option('enable-cups-print-backend')
+if enable_cups != 'no'
+  want_cups = enable_cups == 'yes'
+  #cups_config = find_program('cups-config', required : want_cups)
+  #if cups_config.found()
+  # FIXME: eek, see configure.ac (we're just not going to support non-standar prefix for now)
+  #endif
+  if cc.has_header('cups/cups.h')
+    # No cc.compute_int() yet: https://github.com/mesonbuild/meson/issues/435
+    cups_major_version = 0
+    cups_minor_version = -1
+    foreach check_ver : [1,2,3]
+      if cups_major_version == 0
+        if cc.compiles('''#include <cups/cups.h>
+                          #if CUPS_VERSION_MAJOR != @0@
+                          #error "Not this version"
+                          #endif'''.format(check_ver),
+                          name : 'Check CUPS major version @0@'.format(check_ver))
+          cups_major_version = check_ver
+        endif
+      endif
+    endforeach
+    foreach check_ver : [0,1,2,3,4,5,6,7,8,9]
+      if cups_major_version > 0 and cups_minor_version == -1
+        if cc.compiles('''#include <cups/cups.h>
+                          #if CUPS_VERSION_MINOR != @0@
+                          #error "Not this version"
+                          #endif'''.format(check_ver),
+                          name : 'Check CUPS minor version @0@'.format(check_ver))
+          cups_minor_version = check_ver
+        endif
+      endif
+    endforeach
+    if cups_major_version > 0 and cups_minor_version >= 0
+      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 : want_cups)
+        if libcups.found() and cc.has_function('httpGetAuthString', dependencies : libcups)
+          cdata.set('HAVE_HTTPGETAUTHSTRING', 1)
+        endif
+
+        print_backends += ['cups']
+      elif want_cups
+        error('Need CUPS version >= 1.2')
+      endif
+    else
+      error('Could not determine CUPS version from header files.')
+    endif
+  elif want_cups
+    error('Cannot find CUPS headers in default prefix.')
+  endif
+endif
+
+# Checks to see if we should compile with PAPI backend for GTK+
+enable_papi = get_option('enable-papi-print-backend')
+if enable_papi != 'no'
+  want_papi = enable_papi == 'yes'
+  libpapi = cc.find_library('libpapi', required : false)
+  if libpapi.found() and cc.has_function('papiServiceCreate', args : '-lpapi')
+    print_backends += ['papi']
+  elif want_papi
+    error('Cannot find libpapi.')
+  endif
+endif
+
+# Checks to see if we should compile with cloudprint backend for GTK+
+enable_cloudprint = get_option('enable-cloudprint-print-backend')
+if enable_cloudprint != 'no'
+  want_cloudprint = enable_cloudprint == 'yes'
+  rest_dep = dependency('rest-0.7', required : want_cloudprint)
+  json_glib_dep = dependency('json-glib-1.0', required : want_cloudprint)
+  if rest_dep.found() and json_glib_dep.found()
+    print_backends += ['cloudprint']
+  endif
+endif
+
+if not cc.has_header('cairo-pdf.h', dependencies : cairo_dep)
+  error('Cannot find cairo-pdf.h. You must build Cairo with the pdf backend enabled.')
+endif
+
+if os_unix
+  if not cc.has_header('cairo-ps.h', dependencies : cairo_dep)
+    error('Cannot find cairo-ps.h. You must build Cairo with the postscript backend enabled.')
+  endif
+  if not cc.has_header('cairo-svg.h', dependencies : cairo_dep)
+    error('Cannot find cairo-svg.h. You must build Cairo with the svg backend enabled.')
+  endif
+endif
+
+if get_option('enable-test-print-backend') == 'yes'
+  print_backends += ['test']
+endif
+
+if not print_backends.contains('papi') and not print_backends.contains('cups')
+  print_backends += ['lpr']
+endif
+
+printbackends_subdir = 'gtk-4.0/@0@/printbackends'.format(gtk_binary_version)
+printbackends_install_dir = join_paths(get_option('libdir'), printbackends_subdir)
+
+message('Print backends: ' + ' '.join(print_backends))
+
+foreach print_backend : print_backends
+  subdir(print_backend)
+endforeach
diff --git a/modules/printbackends/papi/meson.build b/modules/printbackends/papi/meson.build
new file mode 100644
index 0000000..d64dc66
--- /dev/null
+++ b/modules/printbackends/papi/meson.build
@@ -0,0 +1,6 @@
+shared_module('printbackend-papi',
+  'gtkprinterpapi.c',
+  'gtkprintbackendpapi.c',
+  c_args : ['-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED'],
+  dependencies : [libgtk_dep, libpapi],
+  install_dir : printbackends_install_dir)


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