aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-11-28 00:09:29 -0500
committerEli Schwartz <eschwartz@archlinux.org>2021-12-06 20:07:43 -0500
commitbed55a902c46ad0fb1330a19daaa9834a37d3336 (patch)
treefac2bed20c12c6ecb76fa843d44919e2fa8a86dc
parent283c65578d6bf4ec221dff4b96e42df378886637 (diff)
downloadmeson-bed55a902c46ad0fb1330a19daaa9834a37d3336.zip
meson-bed55a902c46ad0fb1330a19daaa9834a37d3336.tar.gz
meson-bed55a902c46ad0fb1330a19daaa9834a37d3336.tar.bz2
gnome module: document and fix install_dir x3, by allowing false *_gir and *_typelib
generate_gir forces building both the typelib and gir, and some people only want one or the other (probably only the typelib?) which means flagging the other as install_dir: false in the same way custom_target supports. As this always worked, albeit undocumented, make sure it keeps working. It's pretty reasonable to allow, anyway. Fixes https://github.com/mesonbuild/meson/pull/9484#issuecomment-980131791
-rw-r--r--docs/markdown/Gnome-module.md4
-rw-r--r--mesonbuild/modules/gnome.py30
-rw-r--r--test cases/frameworks/12 multiple gir/gir/meson.build3
-rw-r--r--test cases/frameworks/12 multiple gir/test.json3
4 files changed, 29 insertions, 11 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md
index 9c941d9..9091fd5 100644
--- a/docs/markdown/Gnome-module.md
+++ b/docs/markdown/Gnome-module.md
@@ -104,9 +104,9 @@ There are several keyword arguments. Many of these map directly to the
* `include_directories`: extra include paths to look for gir files
* `install`: if true, install the generated files
* `install_dir_gir`: (*Added 0.35.0*) which directory to install the
- gir file into
+ gir file into; can be false to disable installation
* `install_dir_typelib`: (*Added 0.35.0*) which directory to install
- the typelib file into
+ the typelib file into; can be false to disable installation
* `link_with`: list of libraries to link with
* `symbol_prefix`: the symbol prefix for the gir object, e.g. `gtk`,
(*Since 0.43.0*) an ordered list of multiple prefixes is allowed
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 181d728..038d179 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -801,13 +801,21 @@ class GnomeModule(ExtensionModule):
def _make_gir_target(self, state: 'ModuleState', girfile: str, scan_command: T.List[str],
generated_files: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]],
depends: T.List[build.Target], kwargs: T.Dict[str, T.Any]) -> GirTarget:
+ install = kwargs['install']
+
+ install_dir = kwargs['install_dir_gir']
+ if install_dir is None:
+ install_dir = os.path.join(state.environment.get_datadir(), 'gir-1.0')
+ elif install_dir is False:
+ install = False
+
scankwargs = {
'input': generated_files,
'output': girfile,
'command': scan_command,
'depends': depends,
- 'install': kwargs['install'],
- 'install_dir': kwargs['install_dir_gir'] or os.path.join(state.environment.get_datadir(), 'gir-1.0'),
+ 'install': install,
+ 'install_dir': install_dir,
'install_tag': 'devel',
'build_by_default': kwargs['build_by_default'],
}
@@ -817,12 +825,20 @@ class GnomeModule(ExtensionModule):
def _make_typelib_target(self, state: 'ModuleState', typelib_output: str, typelib_cmd: T.List[str],
generated_files: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]],
kwargs: T.Dict[str, T.Any]) -> TypelibTarget:
+ install = kwargs['install']
+
+ install_dir = kwargs['install_dir_typelib']
+ if install_dir is None:
+ install_dir = os.path.join(state.environment.get_libdir(), 'girepository-1.0')
+ elif install_dir is False:
+ install = False
+
typelib_kwargs = {
'input': generated_files,
'output': [typelib_output],
'command': typelib_cmd,
- 'install': kwargs['install'],
- 'install_dir': kwargs['install_dir_typelib'] or os.path.join(state.environment.get_libdir(), 'girepository-1.0'),
+ 'install': install,
+ 'install_dir': install_dir,
'install_tag': 'typelib',
'build_by_default': kwargs['build_by_default'],
}
@@ -900,8 +916,10 @@ class GnomeModule(ExtensionModule):
KwargInfo('identifier_prefix', ContainerTypeInfo(list, str), default=[], listify=True),
KwargInfo('include_directories', ContainerTypeInfo(list, (str, build.IncludeDirs)), default=[], listify=True),
KwargInfo('includes', ContainerTypeInfo(list, (str, GirTarget)), default=[], listify=True),
- KwargInfo('install_dir_gir', (str, NoneType)),
- KwargInfo('install_dir_typelib', (str, NoneType)),
+ KwargInfo('install_dir_gir', (str, bool, NoneType),
+ validator=lambda x: 'as boolean can only be false' if x is True else None),
+ KwargInfo('install_dir_typelib', (str, bool, NoneType),
+ validator=lambda x: 'as boolean can only be false' if x is True else None),
KwargInfo('link_with', ContainerTypeInfo(list, (build.SharedLibrary, build.StaticLibrary)), default=[], listify=True),
KwargInfo('namespace', str, required=True),
KwargInfo('nsversion', str, required=True),
diff --git a/test cases/frameworks/12 multiple gir/gir/meson.build b/test cases/frameworks/12 multiple gir/gir/meson.build
index 6001a09..5a52c9c 100644
--- a/test cases/frameworks/12 multiple gir/gir/meson.build
+++ b/test cases/frameworks/12 multiple gir/gir/meson.build
@@ -22,7 +22,8 @@ gnome.generate_gir(
symbol_prefix : 'meson_sub_',
identifier_prefix : 'MesonSub',
includes : ['GObject-2.0', meson_gir],
- install : true
+ install : true,
+ install_dir_gir: false,
)
message('TEST: ' + girsubproject.outdir())
diff --git a/test cases/frameworks/12 multiple gir/test.json b/test cases/frameworks/12 multiple gir/test.json
index 4ccecc8..9774402 100644
--- a/test cases/frameworks/12 multiple gir/test.json
+++ b/test cases/frameworks/12 multiple gir/test.json
@@ -6,8 +6,7 @@
{"type": "file", "platform": "cygwin", "file": "usr/lib/libgirlib.dll.a"},
{"type": "expr", "file": "usr/lib/?libgirsubproject.so"},
{"type": "file", "platform": "cygwin", "file": "usr/lib/libgirsubproject.dll.a"},
- {"type": "file", "file": "usr/share/gir-1.0/Meson-1.0.gir"},
- {"type": "file", "file": "usr/share/gir-1.0/MesonSub-1.0.gir"}
+ {"type": "file", "file": "usr/share/gir-1.0/Meson-1.0.gir"}
],
"skip_on_jobname": ["azure", "macos", "msys2"]
}