diff options
Diffstat (limited to 'mesonbuild/modules/gnome.py')
-rw-r--r-- | mesonbuild/modules/gnome.py | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 5c9d3dd..bcf77b9 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -18,6 +18,7 @@ functionality such as gobject-introspection, gresources and gtk-doc''' import os import copy import subprocess +import functools from .. import build from .. import mlog @@ -41,31 +42,20 @@ from ..interpreterbase import noKwargs, permittedKwargs, FeatureNew, FeatureNewK gresource_dep_needed_version = '>= 2.51.1' native_glib_version = None -girwarning_printed = False -gdbuswarning_printed = False -gresource_warning_printed = False -_gir_has_option = {} +@functools.lru_cache(maxsize=None) def gir_has_option(intr_obj, option): - global _gir_has_option - if option in _gir_has_option: - return _gir_has_option[option] - - _gir_has_option[option] = False try: g_ir_scanner = intr_obj.find_program_impl('g-ir-scanner') # Handle overriden g-ir-scanner if isinstance(getattr(g_ir_scanner, "held_object", g_ir_scanner), interpreter.OverrideProgram): assert option in ['--extra-library', '--sources-top-dirs'] - _gir_has_option[option] = True return True opts = Popen_safe(g_ir_scanner.get_command() + ['--help'], stderr=subprocess.STDOUT)[1] - _gir_has_option[option] = option in opts + return option in opts except (MesonException, FileNotFoundError, subprocess.CalledProcessError): - pass - - return _gir_has_option[option] + return False class GnomeModule(ExtensionModule): gir_dep = None @@ -84,24 +74,20 @@ class GnomeModule(ExtensionModule): native_glib_version = '2.54' return native_glib_version + @mesonlib.run_once def __print_gresources_warning(self, state): - global gresource_warning_printed - if not gresource_warning_printed: - if not mesonlib.version_compare(self._get_native_glib_version(state), gresource_dep_needed_version): - mlog.warning('GLib compiled dependencies do not work reliably with \n' - 'the current version of GLib. See the following upstream issue:', - mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=774368')) - gresource_warning_printed = True - return [] + if not mesonlib.version_compare(self._get_native_glib_version(state), + gresource_dep_needed_version): + mlog.warning('GLib compiled dependencies do not work reliably with \n' + 'the current version of GLib. See the following upstream issue:', + mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=774368')) @staticmethod + @mesonlib.run_once def _print_gdbus_warning(): - global gdbuswarning_printed - if not gdbuswarning_printed: - mlog.warning('Code generated with gdbus_codegen() requires the root directory be added to\n' - ' include_directories of targets with GLib < 2.51.3:', - mlog.bold('https://github.com/mesonbuild/meson/issues/1387')) - gdbuswarning_printed = True + mlog.warning('Code generated with gdbus_codegen() requires the root directory be added to\n' + ' include_directories of targets with GLib < 2.51.3:', + mlog.bold('https://github.com/mesonbuild/meson/issues/1387')) @FeatureNewKwargs('gnome.compile_resources', '0.37.0', ['gresource_bundle', 'export', 'install_header']) @permittedKwargs({'source_dir', 'c_name', 'dependencies', 'export', 'gresource_bundle', 'install_header', |