From a2def550c586aeba4269588e79a1a308467f2582 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 29 Mar 2022 15:31:04 -0700 Subject: [PATCH] modules: move gnome targets into gnome module They're not used outside of the gnome module anyway, and they create some annoying potentials for dependency loops --- mesonbuild/backend/ninjabackend.py | 3 ++- mesonbuild/modules/__init__.py | 18 ++---------------- mesonbuild/modules/gnome.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5c77dc29f..1b5937207 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -29,6 +29,7 @@ import typing as T from . import backends from .. import modules +from ..modules import gnome from .. import environment, mesonlib from .. import build from .. import mlog @@ -1558,7 +1559,7 @@ class NinjaBackend(backends.Backend): target.install_dir[3] = os.path.join(self.environment.get_datadir(), 'gir-1.0') # Detect gresources and add --gresources arguments for each for gensrc in other_src[1].values(): - if isinstance(gensrc, modules.GResourceTarget): + if isinstance(gensrc, gnome.GResourceTarget): gres_xml, = self.get_custom_target_sources(gensrc) args += ['--gresources=' + gres_xml] extra_args = [] diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 71536c1c6..ef4b2996f 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -14,9 +14,10 @@ # This file contains the base representation for import('modname') +from __future__ import annotations import typing as T -from .. import build, mesonlib +from .. import mesonlib from ..mesonlib import relpath, HoldableObject, MachineChoice from ..interpreterbase.decorators import noKwargs, noPosargs @@ -189,18 +190,3 @@ class ModuleReturnValue: self.return_value = return_value assert isinstance(new_objects, list) self.new_objects: T.List[T.Union['TYPE_var', 'build.ExecutableSerialisation']] = new_objects - -class GResourceTarget(build.CustomTarget): - pass - -class GResourceHeaderTarget(build.CustomTarget): - pass - -class GirTarget(build.CustomTarget): - pass - -class TypelibTarget(build.CustomTarget): - pass - -class VapiTarget(build.CustomTarget): - pass diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 3d567354a..4456f36aa 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -25,7 +25,6 @@ import textwrap import typing as T from . import ExtensionModule -from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget from . import ModuleReturnValue from .. import build from .. import interpreter @@ -247,6 +246,21 @@ def annotations_validator(annotations: T.List[T.Union[str, T.List[str]]]) -> T.O return f'element {c+1} {badlist}' return None +class GResourceTarget(build.CustomTarget): + pass + +class GResourceHeaderTarget(build.CustomTarget): + pass + +class GirTarget(build.CustomTarget): + pass + +class TypelibTarget(build.CustomTarget): + pass + +class VapiTarget(build.CustomTarget): + pass + # gresource compilation is broken due to the way # the resource compiler and Ninja clash about it #