diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index fb1280bc3..fa4d5cf99 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1034,10 +1034,14 @@ int dummy; valac_outputs.append(hname) # Outputted vapi file vapiname = os.path.join(self.get_target_dir(target), target.vala_vapi) - # Force valac to write the vapi file in the target build dir. + # Force valac to write the vapi and gir files in the target build dir. # Without this, it will write it inside c_out_dir args += ['--vapi', os.path.join('..', target.vala_vapi)] valac_outputs.append(vapiname) + if isinstance(target.vala_gir, str): + girname = os.path.join(self.get_target_dir(target), target.vala_gir) + args += ['--gir', os.path.join('..', target.vala_gir)] + valac_outputs.append(girname) if self.environment.coredata.get_builtin_option('werror'): args += valac.get_werror_args() for d in target.get_external_deps(): diff --git a/mesonbuild/build.py b/mesonbuild/build.py index d1746f179..42cdc5717 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -57,6 +57,7 @@ known_lib_kwargs.update({'version' : True, # Only for shared libs 'vs_module_defs' : True, # Only for shared libs 'vala_header': True, 'vala_vapi': True, + 'vala_gir' : True, 'pic' : True, # Only for static libs }) @@ -513,6 +514,7 @@ class BuildTarget(): if not isinstance(self, Executable): self.vala_header = kwargs.get('vala_header', self.name + '.h') self.vala_vapi = kwargs.get('vala_vapi', self.name + '.vapi') + self.vala_gir = kwargs.get('vala_gir', None) dlist = stringlistify(kwargs.get('d_args', [])) self.add_compiler_args('d', dlist) self.link_args = kwargs.get('link_args', []) diff --git a/test cases/vala/9 gir/foo.vala b/test cases/vala/9 gir/foo.vala new file mode 100644 index 000000000..00c48121a --- /dev/null +++ b/test cases/vala/9 gir/foo.vala @@ -0,0 +1,7 @@ +namespace Foo +{ + public int bar () + { + return 0; + } +} diff --git a/test cases/vala/9 gir/meson.build b/test cases/vala/9 gir/meson.build new file mode 100644 index 000000000..c0a8f543f --- /dev/null +++ b/test cases/vala/9 gir/meson.build @@ -0,0 +1,16 @@ +project('foo', 'c', 'vala') + +glib = dependency('glib-2.0') +gobject = dependency('gobject-2.0') +g_ir_compiler = find_program('g-ir-compiler') + +foo = shared_library('foo', 'foo.vala', + vala_gir: 'Foo-1.0.gir', + dependencies: [glib, gobject]) + +custom_target('foo-typelib', + command: [g_ir_compiler, '--output', '@OUTPUT@', '@INPUT@'], + input: meson.current_build_dir() + '/Foo-1.0.gir', + output: 'Foo-1.0.typelib', + depends: foo) +