From 588dd6c9cda54209bd2690d40e85978fc180b268 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Tue, 28 May 2019 05:11:14 +1200 Subject: [PATCH] Make libappstream and GCR3 optional. Though I'd heavily discourage dropping the latter, and I quite value the former. --- meson_options.txt | 3 +- src/Services/Prosody/misc/AppStream.vala | 9 ++++++ src/Traits/status/https.vala | 4 +++ src/meson.build | 36 +++++++++++++++--------- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index d3a81c5..2e44e5a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ -option('nofts5', type: 'boolean', value: false) +option('appstream', type: 'boolean', value: true, description: 'Use appstream to recommend compatible apps') +option('gcr', type: 'boolean', value: true, description: 'Use GCR to show certificate details, HEAVILY RECOMMENDED') diff --git a/src/Services/Prosody/misc/AppStream.vala b/src/Services/Prosody/misc/AppStream.vala index 83772f9..8dd4eaa 100644 --- a/src/Services/Prosody/misc/AppStream.vala +++ b/src/Services/Prosody/misc/AppStream.vala @@ -27,6 +27,7 @@ And given I can link to app descriptions where they can be installed via simple URLs, it looks quite trivial to write that UI in Prosody. The challenging bit is getting at the data, which is what's done here. */ namespace Odysseus.Templating.xAppStream { +#if HAVE_APPSTREAM using AppStream; public class AppStreamBuilder : TagBuilder, Object { @@ -61,6 +62,7 @@ namespace Odysseus.Templating.xAppStream { } } } + private class AppStreamTag : Template { private AppStream.Pool pool; private Variable[] vars; @@ -138,4 +140,11 @@ namespace Odysseus.Templating.xAppStream { yield renderer.exec(data, output); } } +#else + public class AppStreamBuilder : TagBuilder, Object { + public Template? build(Parser parser, WordIter args) throws SyntaxError { + return null; + } + } +#endif } diff --git a/src/Traits/status/https.vala b/src/Traits/status/https.vala index df92071..5f1ecb3 100644 --- a/src/Traits/status/https.vala +++ b/src/Traits/status/https.vala @@ -73,15 +73,18 @@ namespace Odysseus.Traits { scrolled.add(list); list.selection_mode = Gtk.SelectionMode.NONE; +#if HAVE_GCR3 // FIXME the commented out code hangs. //for (var chain = cert; chain != null; chain = cert.get_issuer()) { var gcr = new Gcr.SimpleCertificate (cert.certificate.data); list.add(build_certificate_row(gcr)); //} +#endif return ret; } +#if HAVE_GCR3 private Gtk.Widget build_certificate_row(Gcr.Certificate cert) { var ret = new Gtk.Grid(); ret.column_spacing = 10; ret.row_spacing = 10; @@ -107,4 +110,5 @@ namespace Odysseus.Traits { ret.halign = Gtk.Align.START; return ret; } +#endif } diff --git a/src/meson.build b/src/meson.build index 9441611..80c8379 100644 --- a/src/meson.build +++ b/src/meson.build @@ -83,23 +83,33 @@ endforeach c_args = ['-DGCR_API_SUBJECT_TO_CHANGE', '-include', 'config.h'] posix_dep = meson.get_compiler('vala').find_library('posix') +dependencies = [ + dependency('gtk+-3.0'), + dependency('granite'), + dependency('webkit2gtk-4.0'), + dependency('json-glib-1.0'), + dependency('gee-0.8'), + dependency('libsoup-2.4'), + dependency('sqlite3'), + posix_dep, + dependency('libxml-2.0'), +] +vala_args = [] +if get_option('appstream') + dependencies += [dependency('appstream')] + vala_args += ['--define=HAVE_APPSTREAM'] +endif +if get_option('gcr') + dependencies += [dependency('gcr-3')] + vala_args += ['--define=HAVE_GCR3'] +endif + executable('com.github.alcinnz.odysseus', source_files, c_args: c_args, link_args: ['-lm'], - dependencies: [ - dependency('gtk+-3.0'), - dependency('granite'), - dependency('webkit2gtk-4.0'), - dependency('json-glib-1.0'), - dependency('gee-0.8'), - dependency('libsoup-2.4'), - dependency('sqlite3'), - dependency('appstream'), - posix_dep, - dependency('libxml-2.0'), - dependency('gcr-3') - ], + vala_args: vala_args, + dependencies: dependencies, install: true )