diff --git a/meson.build b/meson.build index 290faca5..f0574eeb 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('geary', [ 'vala', 'c' ], version: '3.32-dev', license: 'LGPL2.1+', - meson_version: '>= 0.43', + meson_version: '>= 0.47', ) gnome = import('gnome') @@ -70,8 +70,8 @@ libmath = cc.find_library('m') libnotify = dependency('libnotify', version: '>= 0.7.5') libsecret = dependency('libsecret-1', version: '>= 0.11') libsoup = dependency('libsoup-2.4', version: '>= 2.48') -libunwind_dep = dependency('libunwind', version: '>= 1.1') -libunwind_generic_dep = dependency('libunwind-generic', version: '>= 1.1') +libunwind_dep = dependency('libunwind', version: '>= 1.1', required: get_option('libunwind')) +libunwind_generic_dep = dependency('libunwind-generic', version: '>= 1.1', required: get_option('libunwind')) libxml = dependency('libxml-2.0', version: '>= 2.7.8') posix = valac.find_library('posix') webkit2gtk_web_extension = dependency('webkit2gtk-web-extension-4.0', version: '>=' + target_webkit) @@ -81,19 +81,20 @@ if not enchant.found() enchant = dependency('enchant', version: '>=1.6') endif - -# Libunwind system dependencies above ensures appropriate versions, -# but this declared depencency is what we actually build against so we -# can include the custom VAPI correctly. We need to add unwind_lib to -# the search path for these so Flatpak builds can find the C lib. -unwind_lib = libunwind_dep.get_pkgconfig_variable('libdir') -libunwind = declare_dependency( - dependencies: [ - valac.find_library('libunwind', dirs: [vapi_dir, unwind_lib]), - cc.find_library('libunwind', dirs: unwind_lib), - cc.find_library('libunwind-generic', dirs: unwind_lib) - ], - ) +if libunwind_dep.found() + # Libunwind system dependencies above ensures appropriate versions, + # but this declared depencency is what we actually build against so we + # can include the custom VAPI correctly. We need to add unwind_lib to + # the search path for these so Flatpak builds can find the C lib. + unwind_lib = libunwind_dep.get_pkgconfig_variable('libdir') + libunwind = declare_dependency( + dependencies: [ + valac.find_library('libunwind', dirs: [vapi_dir, unwind_lib]), + cc.find_library('libunwind', dirs: unwind_lib), + cc.find_library('libunwind-generic', dirs: unwind_lib) + ], + ) +endif # Optional libraries libunity = dependency('unity', version: '>= 5.12.0', required: false) diff --git a/meson_options.txt b/meson_options.txt index 234e979d..f29b0f0c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,3 +4,4 @@ option('poodle', type: 'boolean', value: true, description: 'Whether to apply th option('ref_tracking', type: 'boolean', value: false, description: 'Whether to use explicit reference tracking.') option('iso_639_xml', type: 'string', value: '', description: 'Full path to the ISO 639 XML file.') option('iso_3166_xml', type: 'string', value: '', description: 'Full path to the ISO 3166 XML file.') +option('libunwind', type: 'feature', value: 'enabled', description: 'Whether to use libunwind.') diff --git a/src/engine/meson.build b/src/engine/meson.build index f9fb1626..3f5bfad9 100644 --- a/src/engine/meson.build +++ b/src/engine/meson.build @@ -332,12 +332,15 @@ geary_engine_dependencies = [ glib, gmime, javascriptcoregtk, - libunwind, libxml, posix, sqlite ] +if libunwind_dep.found() + geary_engine_dependencies += libunwind +endif + build_dir = meson.current_build_dir() # Generate internal VAPI for unit testing. See Meson issue @@ -349,6 +352,12 @@ geary_engine_vala_options += [ '--internal-vapi=@0@/geary-engine-internal.vapi'.format(build_dir) ] +if libunwind_dep.found() + geary_engine_vala_options += [ + '-D', 'HAVE_LIBUNWIND', + ] +endif + geary_engine_lib = static_library('geary-engine', geary_engine_sources, dependencies: geary_engine_dependencies, diff --git a/src/engine/util/util-error-context.vala b/src/engine/util/util-error-context.vala index 81cfcb8b..b4f3008f 100644 --- a/src/engine/util/util-error-context.vala +++ b/src/engine/util/util-error-context.vala @@ -28,6 +28,7 @@ public class Geary.ErrorContext : BaseObject { public string name = "unknown"; +#if HAVE_LIBUNWIND internal StackFrame(Unwind.Cursor frame) { uint8 proc_name[256]; int ret = -frame.get_proc_name(proc_name); @@ -36,6 +37,7 @@ public class Geary.ErrorContext : BaseObject { this.name = (string) proc_name; } } +#endif public string to_string() { return this.name; @@ -56,6 +58,7 @@ public class Geary.ErrorContext : BaseObject { public ErrorContext(GLib.Error thrown) { this.thrown = thrown; +#if HAVE_LIBUNWIND Unwind.Context trace = Unwind.Context(); Unwind.Cursor cursor = Unwind.Cursor.local(trace); @@ -64,6 +67,7 @@ public class Geary.ErrorContext : BaseObject { while (cursor.step() != 0) { this.backtrace.add(new StackFrame(cursor)); } +#endif } /** Returns a string representation of the error type, for debugging. */