modules/gnome: Correctly handle generated sources for generate_gir

We need to pass any generated sources down the CustomTarget
inititalizers so that they will generate a dependency correctly,
otherwise we get race conditions.
pull/8807/head
Dylan Baker 4 years ago committed by Xavier Claessens
parent 45af5d9d72
commit f1e053fa44
  1. 18
      mesonbuild/modules/gnome.py
  2. 18
      test cases/frameworks/7 gnome/gir/copy.py
  3. 10
      test cases/frameworks/7 gnome/gir/meson.build

@ -35,6 +35,7 @@ from ..mesonlib import (
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
from ..interpreterbase import noPosargs, noKwargs, permittedKwargs, FeatureNew, FeatureNewKwargs, FeatureDeprecatedKwargs
from ..programs import ExternalProgram, OverrideProgram
from ..build import CustomTarget, CustomTargetIndex, GeneratedList
if T.TYPE_CHECKING:
from ..compilers import Compiler
@ -709,8 +710,9 @@ class GnomeModule(ExtensionModule):
return gir_filelist_filename
def _make_gir_target(self, state, girfile, scan_command, depends, kwargs):
scankwargs = {'output': girfile,
def _make_gir_target(self, state, girfile, scan_command, generated_files, depends, kwargs):
scankwargs = {'input': generated_files,
'output': girfile,
'command': scan_command,
'depends': depends}
@ -724,8 +726,9 @@ class GnomeModule(ExtensionModule):
return GirTarget(girfile, state.subdir, state.subproject, scankwargs)
def _make_typelib_target(self, state, typelib_output, typelib_cmd, kwargs):
def _make_typelib_target(self, state, typelib_output, typelib_cmd, generated_files, kwargs):
typelib_kwargs = {
'input': generated_files,
'output': typelib_output,
'command': typelib_cmd,
}
@ -801,7 +804,7 @@ class GnomeModule(ExtensionModule):
'export_packages', 'includes', 'dependencies', 'link_with', 'include_directories',
'install', 'install_dir_gir', 'install_dir_typelib', 'extra_args',
'packages', 'header', 'build_by_default', 'fatal_warnings'})
def generate_gir(self, state, args, kwargs):
def generate_gir(self, state, args, kwargs: T.Dict[str, T.Any]):
if not args:
raise MesonException('generate_gir takes at least one argument')
if kwargs.get('install_dir'):
@ -881,7 +884,9 @@ class GnomeModule(ExtensionModule):
if fatal_warnings:
scan_command.append('--warn-error')
scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs)
generated_files = [unholder(f) for f in libsources if isinstance(unholder(f), (GeneratedList, CustomTarget, CustomTargetIndex))]
scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs)
typelib_output = f'{ns}-{nsversion}.typelib'
typelib_cmd = [gicompiler, scan_target, '--output', '@OUTPUT@']
@ -890,7 +895,8 @@ class GnomeModule(ExtensionModule):
for incdir in typelib_includes:
typelib_cmd += ["--includedir=" + incdir]
typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, kwargs)
typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, generated_files, kwargs)
self._devenv_append('GI_TYPELIB_PATH', os.path.join(state.environment.get_build_dir(), state.subdir))
rv = [scan_target, typelib_target]

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2021 Intel Corproation
import argparse
import shutil
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('src')
parser.add_argument('dest')
args = parser.parse_args()
shutil.copy(args.src, args.dest)
if __name__ == "__main__":
main()

@ -3,6 +3,14 @@ subdir('dep1')
libsources = ['meson-sample.c', 'meson-sample.h']
lib2sources = ['meson-sample2.c', 'meson-sample2.h']
gen_source = custom_target(
'meson_smaple3.h',
input : 'meson-sample.h',
output : 'meson-sample3.h',
command : [find_program('copy.py'), '@INPUT@', '@OUTPUT@'],
build_by_default : false, # this will force a race condition if one exists
)
girlib = shared_library(
'gir_lib',
sources : libsources,
@ -28,7 +36,7 @@ fake_dep = dependency('no-way-this-exists', required: false)
gnome.generate_gir(
girlib, girlib2,
sources : libsources + lib2sources,
sources : [libsources, lib2sources, gen_source],
nsversion : '1.0',
namespace : 'Meson',
symbol_prefix : 'meson',

Loading…
Cancel
Save