[gimp] Enforce libbacktrace tests. Add missing dep in app



commit c20a8b732cd4d2b908208f82eaad27dbe2e47b08
Author: Salamandar <felix piedallu me>
Date:   Wed Sep 11 18:02:15 2019 +0000

    Enforce libbacktrace tests. Add missing dep in app

 app/meson.build | 12 +++++++++++-
 meson.build     | 38 +++++++++++++++++++++++++++++++++-----
 2 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/app/meson.build b/app/meson.build
index 1a387eea3e..f397a55943 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -108,7 +108,17 @@ app_gui_links = [
 ]
 
 app_deps = [
-  gio, gtk3, pangocairo, pangoft2, gegl, lcms, gexiv2, drmingw, rpc, dbghelp,
+  dbghelp,
+  drmingw,
+  gegl,
+  gexiv2,
+  gio,
+  gtk3,
+  lcms,
+  libbacktrace,
+  pangocairo,
+  pangoft2,
+  rpc,
 ]
 
 # Executables
diff --git a/meson.build b/meson.build
index 3a1d3fd454..96edd6806b 100644
--- a/meson.build
+++ b/meson.build
@@ -445,10 +445,39 @@ endif
 
 ## Check for libbacktrace
 
-libbacktrace = ( get_option('libbacktrace')
-  ? cc.find_library('backtrace', has_headers: 'backtrace.h', required: false)
-  : no_dep
-)
+if get_option('libbacktrace')
+  libbacktrace = cc.find_library('backtrace', required: false)
+
+  if libbacktrace.found()
+    libbacktrace_run = cc.run('''
+        #include <stddef.h>
+        #include <backtrace.h>
+        #include <backtrace-supported.h>
+
+        #if ! BACKTRACE_SUPPORTED
+        #   error ! BACKTRACE_SUPPORTED
+        #endif
+
+        int main() {
+          (void) backtrace_create_state (NULL, 0, NULL, NULL);
+          return 0;
+        }
+      ''',
+      dependencies: libbacktrace,
+    )
+
+    if not(libbacktrace_run.compiled() and libbacktrace_run.returncode() == 0)
+      warning(
+        'libbacktrace was found, but the test compilation failed.\n' +
+        'You can find more info in meson-logs/meson-logs.txt.'
+      )
+      libbacktrace = no_dep
+    endif
+
+  endif
+else
+  libbacktrace = no_dep
+endif
 conf.set('HAVE_LIBBACKTRACE', libbacktrace.found())
 
 ## Check for libunwind
@@ -1079,7 +1108,6 @@ conf.set10('ENABLE_MP', get_option('enable-multiproc'))
 # Check for available functions
 foreach fn : [
     { 'm': 'HAVE_ALLOCA',                   'v': 'alloca', },
-    { 'm': 'HAVE_BACKTRACE',                'v': 'backtrace', },
     { 'm': 'HAVE_DCGETTEXT',                'v': 'dcgettext', },
     { 'm': 'HAVE_DIFFTIME',                 'v': 'difftime', },
     { 'm': 'HAVE_FINITE',                   'v': 'finite', },


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