Skip to content

Commit

Permalink
gnome: allow generator outputs as gdbus-codegen inputs
Browse files Browse the repository at this point in the history
GeneratedLists as sources to `gnome.gdbus_codegen` worked until
version 0.60 of Meson, but broke in 0.61 because of the conversion to
typed_pos_args and typed_kwargs.  Reinstate this by adding them to the
decorators and annotations.

Note that gdbus_codegen desugars to two custom_targets and therefore the
generator is invoked twice.  This is not optimal, but it should not be
an issue and can be changed later.

Fixes: 53a187b ("modules/gnome: use typed_pos_args for gdbus_codegen", 2021-11-01)
Fixes: ef52e60 ("modules/gnome: use typed_kwargs for gdbus_codegen", 2021-11-08)
  • Loading branch information
bonzini authored and jpakkane committed Oct 28, 2022
1 parent 2fe3271 commit 212af2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .. import mlog
from ..build import CustomTarget, CustomTargetIndex, Executable, GeneratedList, InvalidArguments
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, in_set_validator
from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, SOURCES_KW, in_set_validator
from ..interpreterbase import noPosargs, noKwargs, FeatureNew, FeatureDeprecated
from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo
from ..interpreterbase.decorators import typed_pos_args
Expand Down Expand Up @@ -1570,11 +1570,11 @@ def _get_build_args(self, c_args: T.List[str], inc_dirs: T.List[T.Union[str, bui
def gtkdoc_html_dir(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'TYPE_kwargs') -> str:
return os.path.join('share/gtk-doc/html', args[0])

@typed_pos_args('gnome.gdbus_codegen', str, optargs=[(str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex)])
@typed_pos_args('gnome.gdbus_codegen', str, optargs=[(str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)])
@typed_kwargs(
'gnome.gdbus_codegen',
_BUILD_BY_DEFAULT.evolve(since='0.40.0'),
KwargInfo('sources', ContainerTypeInfo(list, (str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex)), since='0.46.0', default=[], listify=True),
SOURCES_KW.evolve(since='0.46.0'),
KwargInfo('extra_args', ContainerTypeInfo(list, str), since='0.47.0', default=[], listify=True),
KwargInfo('interface_prefix', (str, NoneType)),
KwargInfo('namespace', (str, NoneType)),
Expand Down
8 changes: 8 additions & 0 deletions test cases/frameworks/7 gnome/gdbus/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ gdbus_src_cti = gnome.gdbus_codegen(
annotations : [],
)

gdbus_src_gen = gnome.gdbus_codegen(
'generated-gdbus-generator-src',
copyfile_gen.process('data/com.example.Sample.xml'),
interface_prefix : 'com.example.',
namespace : 'Sample',
annotations : [],
)

gdbus_exe = executable('gdbus-test', 'gdbusprog.c',
gdbus_src,
include_directories : includes,
Expand Down
3 changes: 3 additions & 0 deletions test cases/frameworks/7 gnome/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
project('gobject-introspection', 'c')

copyfile = find_program('copyfile.py')
copyfile_gen = generator(copyfile,
output: '@[email protected]',
arguments : ['@INPUT@', '@OUTPUT@'])

glib = dependency('glib-2.0', required: false)
if not glib.found()
Expand Down

0 comments on commit 212af2b

Please sign in to comment.