Add env kwarg to gnome.generate_gir().

Fixes #384
pull/11739/head
Volker Weißmann 2 years ago committed by Eli Schwartz
parent bf44120a4f
commit 38b35eca30
  1. 3
      docs/markdown/Gnome-module.md
  2. 3
      docs/markdown/snippets/generate_gir_kwarg_env.md
  3. 5
      mesonbuild/modules/gnome.py
  4. 5
      mesonbuild/utils/core.py
  5. 4
      test cases/frameworks/7 gnome/gir/dep1/dep1.h
  6. 4
      test cases/frameworks/7 gnome/gir/dep1/dep2/dep2.h
  7. 4
      test cases/frameworks/7 gnome/gir/dep1/dep3/dep3.h
  8. 8
      test cases/frameworks/7 gnome/gir/meson-sample.h
  9. 4
      test cases/frameworks/7 gnome/gir/meson-sample2.h
  10. 3
      test cases/frameworks/7 gnome/gir/meson.build
  11. 2
      test cases/frameworks/7 gnome/meson.build

@ -92,6 +92,9 @@ There are several keyword arguments. Many of these map directly to the
* `dependencies`: deps to use during introspection scanning
* `extra_args`: command line arguments to pass to gir compiler
* `env`: (*Added 1.2.0*) environment variables to set, such as
`{'NAME1': 'value1', 'NAME2': 'value2'}` or `['NAME1=value1', 'NAME2=value2']`,
or an [[@env]] object which allows more sophisticated environment juggling.
* `export_packages`: extra packages the gir file exports
* `sources`: the list of sources to be scanned for gir data
* `nsversion`: namespace version

@ -0,0 +1,3 @@
## `gnome.generate_gir()` now supports `env` kwarg
`gnome.generate_gir()` now accepts the `env` kwarg which lets you set environment variables.

@ -32,7 +32,7 @@ from .. import mesonlib
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, SOURCES_KW, in_set_validator
from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, ENV_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
@ -982,6 +982,7 @@ class GnomeModule(ExtensionModule):
# g-ir-scanner uses Python's distutils to find the compiler, which uses 'CC'
cc_exelist = state.environment.coredata.compilers.host['c'].get_exelist()
run_env.set('CC', [quote_arg(x) for x in cc_exelist], ' ')
run_env.merge(kwargs['env'])
return GirTarget(
girfile,
@ -1026,6 +1027,7 @@ class GnomeModule(ExtensionModule):
install_dir=[install_dir],
install_tag=['typelib'],
build_by_default=kwargs['build_by_default'],
env=kwargs['env'],
)
@staticmethod
@ -1098,6 +1100,7 @@ class GnomeModule(ExtensionModule):
INSTALL_KW,
_BUILD_BY_DEFAULT.evolve(since='0.40.0'),
_EXTRA_ARGS_KW,
ENV_KW.evolve(since='1.2.0'),
KwargInfo('dependencies', ContainerTypeInfo(list, Dependency), default=[], listify=True),
KwargInfo('export_packages', ContainerTypeInfo(list, str), default=[], listify=True),
KwargInfo('fatal_warnings', bool, default=False, since='0.55.0'),

@ -99,6 +99,11 @@ class EnvironmentVariables(HoldableObject):
def get_names(self) -> T.Set[str]:
return self.varnames
def merge(self, other: EnvironmentVariables) -> None:
for method, name, values, separator in other.envvars:
self.varnames.add(name)
self.envvars.append((method, name, values, separator))
def set(self, name: str, values: T.List[str], separator: str = os.pathsep) -> None:
self.varnames.add(name)
self.envvars.append((self._set, name, values, separator))

@ -1,8 +1,8 @@
#ifndef MESON_DEP1_H
#define MESON_DEP1_H
#if !defined (MESON_TEST)
#error "MESON_TEST not defined."
#if !defined (MESON_TEST_1)
#error "MESON_TEST_1 not defined."
#endif
#include <glib-object.h>

@ -1,8 +1,8 @@
#ifndef MESON_DEP2_H
#define MESON_DEP2_H
#if !defined (MESON_TEST)
#error "MESON_TEST not defined."
#if !defined (MESON_TEST_1)
#error "MESON_TEST_1 not defined."
#endif
#include <glib-object.h>

@ -1,8 +1,8 @@
#ifndef MESON_DEP3_H
#define MESON_DEP3_H
#if !defined (MESON_TEST)
#error "MESON_TEST not defined."
#if !defined (MESON_TEST_1)
#error "MESON_TEST_1 not defined."
#endif
#include <glib-object.h>

@ -1,8 +1,12 @@
#ifndef MESON_SAMPLE_H
#define MESON_SAMPLE_H
#if !defined (MESON_TEST)
#error "MESON_TEST not defined."
#if !defined (MESON_TEST_1)
#error "MESON_TEST_1 not defined."
#endif
#if !defined (MESON_TEST_2)
#error "MESON_TEST_2 not defined."
#endif
#include <glib-object.h>

@ -1,8 +1,8 @@
#ifndef MESON_SAMPLE2_H
#define MESON_SAMPLE2_H
#if !defined (MESON_TEST)
#error "MESON_TEST not defined."
#if !defined (MESON_TEST_1)
#error "MESON_TEST_1 not defined."
#endif
#include <glib-object.h>

@ -14,6 +14,7 @@ gen_source = custom_target(
girlib = shared_library(
'gir_lib',
sources : libsources,
c_args: '-DMESON_TEST_2',
dependencies : [gobj, dep1_dep],
install : true
)
@ -28,6 +29,7 @@ girlib2 = shared_library(
girexe = executable(
'girprog',
sources : 'prog.c',
c_args: '-DMESON_TEST_2',
dependencies : [glib, gobj, gir, dep1_dep],
link_with : girlib
)
@ -37,6 +39,7 @@ fake_dep = dependency('no-way-this-exists', required: false)
gnome.generate_gir(
girlib, girlib2,
sources : [libsources, lib2sources, gen_source],
env : {'CPPFLAGS': '-DMESON_TEST_2'},
nsversion : '1.0',
namespace : 'Meson',
symbol_prefix : 'meson',

@ -23,7 +23,7 @@ endif
cc = meson.get_compiler('c')
add_global_arguments('-DMESON_TEST', language : 'c')
add_global_arguments('-DMESON_TEST_1', language : 'c')
if cc.get_id() == 'intel'
# Ignore invalid GCC pragma warnings from glib
# https://bugzilla.gnome.org/show_bug.cgi?id=776562

Loading…
Cancel
Save