Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FeatureNewKwargs('build target', '0.40.0', ['build_by_default'])
- @permittedKwargs({'sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix',
- 'export_packages', 'includes', 'dependencies', 'link_with', 'include_directories',
- 'install', 'install_dir_gir', 'install_dir_typelib', 'extra_args',
- 'packages', 'header', 'build_by_default'})
- def generate_gir(self, state, args, kwargs):
- if len(args) != 1:
- raise MesonException('Gir takes one argument')
- if kwargs.get('install_dir'):
- raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
- giscanner = self.interpreter.find_program_impl('g-ir-scanner')
- gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
- girtarget = self._unwrap_gir_target(args[0])
- self.gir_dep, pkgargs = self._get_gir_dep(state)
- ns = kwargs.pop('namespace')
- nsversion = kwargs.pop('nsversion')
- libsources = mesonlib.extract_as_list(kwargs, 'sources', pop=True)
- girfile = '%s-%s.gir' % (ns, nsversion)
- srcdir = os.path.join(state.environment.get_source_dir(), state.subdir)
- builddir = os.path.join(state.environment.get_build_dir(), state.subdir)
- depends = [girtarget]
- gir_inc_dirs = []
- lang, compiler = self._get_girtarget_lang_compiler(girtarget)
- cflags, internal_ldflags, external_ldflags = self._get_lang_compiler_flags(state, lang, compiler)
- deps = (girtarget.get_all_link_deps() + girtarget.get_external_deps() +
- extract_as_list(kwargs, 'dependencies', pop=True, unholder=True))
- typelib_includes = self._gather_typelib_includes_and_update_depends(state, deps, depends)
- # ldflags will be misinterpreted by gir scanner (showing
- # spurious dependencies) but building GStreamer fails if they
- # are not used here.
- dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes = \
- self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
- cflags += list(dep_cflags)
- internal_ldflags += list(dep_internal_ldflags)
- external_ldflags += list(dep_external_ldflags)
- inc_dirs = self._scan_inc_dirs(kwargs)
- scan_command = [giscanner]
- scan_command += pkgargs
- scan_command += ['--no-libtool']
- scan_command += ['--namespace=' + ns, '--nsversion=' + nsversion]
- scan_command += ['--warn-all']
- scan_command += ['--output', '@OUTPUT@']
- scan_command += self._scan_header(kwargs)
- scan_command += self._scan_extra_args(kwargs)
- scan_command += ['-I' + srcdir, '-I' + builddir]
- scan_command += get_include_args(girtarget.get_include_dirs())
- scan_command += ['--filelist=' + self._make_gir_filelist(state, srcdir, ns, nsversion, girtarget, libsources)]
- scan_command += self._scan_link_withs(state, depends, kwargs)
- scan_command += self._scan_include(state, depends, gir_inc_dirs, kwargs)
- scan_command += self._scan_symbol_prefix(kwargs)
- scan_command += self._scan_identifier_prefix(kwargs)
- scan_command += self._scan_export_packages(kwargs)
- scan_command += ['--cflags-begin']
- scan_command += cflags
- scan_command += state.environment.coredata.get_external_args(lang)
- scan_command += ['--cflags-end']
- scan_command += get_include_args(inc_dirs)
- scan_command += get_include_args(list(gi_includes) + gir_inc_dirs + inc_dirs, prefix='--add-include-path=')
- scan_command += self._scan_gir_target(state, girtarget)
- scan_command += self._scan_lang(state, lang)
- scan_command += list(internal_ldflags)
- scan_command += list(external_ldflags)
- scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs)
- typelib_output = '%s-%s.typelib' % (ns, nsversion)
- typelib_cmd = [gicompiler, scan_target, '--output', '@OUTPUT@']
- typelib_cmd += get_include_args(gir_inc_dirs, prefix='--includedir=')
- for incdir in typelib_includes:
- typelib_cmd += ["--includedir=" + incdir]
- typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, kwargs)
- rv = [scan_target, typelib_target]
- return ModuleReturnValue(rv, rv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement