build: add -Ddeprecated=[true|false] to control deprecated symbols

Instead of using CFLAGS="-DMM_DISABLE_DEPRECATED" meson ...
which doesn't handle -Werror very well let's make it an explicit
option. Defaults to true, and autodetects previous CFLAGS
mechanism to preserve backwards compatibility.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
This commit is contained in:
Dan Williams
2026-08-29 23:29:13 -05:00
parent 306f6256f8
commit abf9babb02
3 changed files with 29 additions and 2 deletions
+26 -1
View File
@@ -144,7 +144,24 @@ if get_option('buildtype').contains('debug')
])
endif
add_project_arguments(common_args + cc_args, language: 'c')
# Look for existing -DMM_DISABLE_DEPRECATED in CFLAGS
pymodule = import('python3')
python3 = pymodule.find_python()
res = run_command(python3, '-c', 'import os; print(os.environ["CFLAGS"])')
cflags_disable_deprecated = false
if res.returncode() == 0 and res.stdout().contains('-DMM_DISABLE_DEPRECATED')
cflags_disable_deprecated = true
endif
# Handle deprecation enable/disable
if get_option('deprecated')
cc_args += cc.get_supported_arguments('-Wno-deprecated-declarations')
else
if cflags_disable_deprecated == false
cc_args += '-DMM_DISABLE_DEPRECATED'
endif
cc_args += cc.get_supported_arguments('-Wdeprecated-declarations')
endif
glib_version = '2.56'
@@ -271,6 +288,9 @@ if enable_mbim
])
mbim_glib_dep = mbim_glib_proj.get_variable('libmbim_glib_dep')
endif
# MM should never use deprecated symbols from the libmibm
cc_args += '-DMBIM_DISABLE_DEPRECATED'
endif
config_h.set('WITH_MBIM', enable_mbim)
@@ -289,6 +309,9 @@ if enable_qmi
])
qmi_glib_dep = qmi_glib_proj.get_variable('libqmi_glib_dep')
endif
# MM should never use deprecated symbols from libqmi
cc_args += '-DQMI_DISABLE_DEPRECATED'
endif
config_h.set('WITH_QMI', enable_qmi)
@@ -306,6 +329,8 @@ if enable_qrtr
endif
config_h.set('WITH_QRTR', enable_qrtr)
add_project_arguments(common_args + cc_args, language: 'c')
# Distribution version string
dist_version = get_option('dist_version')
if dist_version != ''