Skip to content

Commit

Permalink
gnome module: document and fix install_dir x3, by allowing false *_gi…
Browse files Browse the repository at this point in the history
…r 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 mesonbuild#9484 (comment)
  • Loading branch information
eli-schwartz committed Dec 1, 2021
1 parent 79c3e9c commit d58bbe6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/markdown/Gnome-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 24 additions & 6 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,21 @@ def _make_gir_filelist(self, state: 'ModuleState', srcdir: str, ns: str,
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'],
}
Expand All @@ -817,12 +825,20 @@ def _make_gir_target(self, state: 'ModuleState', girfile: str, scan_command: T.L
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'],
}
Expand Down Expand Up @@ -900,8 +916,10 @@ def _get_scanner_ldflags(ldflags: T.Iterable[str]) -> T.Iterable[str]:
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),
Expand Down
3 changes: 2 additions & 1 deletion test cases/frameworks/12 multiple gir/gir/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 1 addition & 2 deletions test cases/frameworks/12 multiple gir/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

0 comments on commit d58bbe6

Please sign in to comment.