From abf9babb02b031111ebe3e5bb08931dfe75d8229 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 29 Aug 2026 23:27:29 -0500 Subject: [PATCH] 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 --- .gitlab-ci.yml | 2 +- meson.build | 27 ++++++++++++++++++++++++++- meson_options.txt | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 531351f5..06d06bd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -208,7 +208,7 @@ build-no-deprecated: - export BUILD_QRTR=false - export BUILD_QMI=false - *prepare_deps - - CFLAGS="-DMM_DISABLE_DEPRECATED" meson setup build --prefix=/usr -Dwerror=true -Dgtk_doc=false -Dqmi=false -Dqrtr=false -Dmbim=false + - meson setup build --prefix=/usr -Dwerror=true -Dgtk_doc=false -Dqmi=false -Dqrtr=false -Dmbim=false -Ddeprecated=false - ninja -C build - ninja -C build test - ninja -C build install diff --git a/meson.build b/meson.build index 3cf29e80..9b8ab2d1 100644 --- a/meson.build +++ b/meson.build @@ -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 != '' diff --git a/meson_options.txt b/meson_options.txt index 6fbc0666..1aa0a45e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -17,6 +17,8 @@ option('systemd_journal', type: 'boolean', value: true, description: 'enable sys option('polkit', type: 'combo', choices: ['strict', 'permissive', 'no'], value: 'strict', description: 'User auth-polkit configuration option.') +option('deprecated', type: 'boolean', value: true, description: 'build with deprecated symbols') + option('at_command_via_dbus', type: 'boolean', value: false, description: 'enable at commands via d-bus') option('builtin_plugins', type: 'boolean', value: false, description: 'integrate all built plugins within the daemon binary')