Commit a1377f34 authored by Thomas Moschny's avatar Thomas Moschny

Allow to opt-out from using libunwind.

parent 53b905dc
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)
......
......@@ -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.')
......@@ -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,
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment