File c47a7ea6289187857a38e0118bd8528cab9171c9.patch of Package libnice

From c47a7ea6289187857a38e0118bd8528cab9171c9 Mon Sep 17 00:00:00 2001
From: Jeffery Wilson <jeff@jeffalwilson.com>
Date: Thu, 27 Jun 2024 13:14:32 -0400
Subject: [PATCH] meson: Add glib debug, assert and check options

Adds `glib_debug`, `glib_assert`, and `glib_checks` options so that glib
can inherit their value. Furthermore, with
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1165
libnice will inherit these values from GStreamer.
---
 meson.build       | 22 ++++++++++++++++++++++
 meson_options.txt |  9 +++++++++
 tests/meson.build |  7 ++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 39d943df..51abfe0b 100644
--- a/meson.build
+++ b/meson.build
@@ -85,6 +85,28 @@ add_project_arguments('-D_GNU_SOURCE',
   '-DNICE_VERSION_NANO=' + version_nano,
   language: 'c')
 
+# Same logic as in GLib.
+glib_debug = get_option('glib_debug')
+disable_cast_checks = glib_debug.disabled() or (
+  glib_debug.auto() and (not get_option('debug') or get_option('optimization') not in [ '0', 'g' ]))
+if disable_cast_checks
+  message('Disabling GLib cast checks')
+  add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
+  disable_cast_checks = true
+endif
+
+disable_glib_asserts = not get_option('glib_assert')
+if disable_glib_asserts
+  message('Disabling GLib asserts')
+  add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
+endif
+
+disable_glib_checks = not get_option('glib_checks')
+if disable_glib_checks
+  message('Disabling GLib checks')
+  add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
+endif
+
 cdata = configuration_data()
 
 cdata.set_quoted('PACKAGE_STRING', meson.project_name())
diff --git a/meson_options.txt b/meson_options.txt
index cd980cb5..a720d742 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,6 +7,15 @@ option('ignored-network-interface-prefix', type: 'array', value: ['docker', 'vet
 option('crypto-library', type: 'combo', choices : ['auto', 'gnutls', 'openssl'], value : 'auto')
 
 # Common feature options
+option('glib_debug', type : 'feature', value : 'auto', yield : true,
+  description : 'Enable GLib debug infrastructure (see docs/macros.txt)',
+)
+option('glib_assert', type : 'boolean', value : true, yield : true,
+  description : 'Enable GLib assertion (see docs/macros.txt)',
+)
+option('glib_checks', type : 'boolean', value : true, yield : true,
+  description : 'Enable GLib checks such as API guards (see docs/macros.txt)',
+)
 option('examples', type : 'feature', value : 'auto', yield : true,
   description: 'Build examples')
 option('tests', type : 'feature', value : 'auto', yield : true,
diff --git a/tests/meson.build b/tests/meson.build
index f1495509..c66ffbde 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -76,9 +76,14 @@ if gst_dep.found() and not static_build
   gst_check = dependency('gstreamer-check-1.0', required: get_option('gstreamer'),
                          fallback : ['gstreamer', 'gst_check_dep'])
   if gst_check.found()
+    test_defines = [
+      '-DG_LOG_DOMAIN="libnice-tests"',
+      '-UG_DISABLE_ASSERT',
+      '-UG_DISABLE_CAST_CHECKS',
+    ]
     exe = executable('nice-test-gstreamer',
       'test-gstreamer.c', extra_src,
-      c_args: '-DG_LOG_DOMAIN="libnice-tests"',
+      c_args: test_defines,
       include_directories: nice_incs,
       dependencies: [nice_deps, gst_check, libm],
       link_with: libnice,
-- 
GitLab

openSUSE Build Service is sponsored by