diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-04-13 18:12:43 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-01 09:51:57 -0400 |
commit | 71804e56eb3612eabc51887fe4d46961684a3ecc (patch) | |
tree | ecc5fecb9e2493db6fb60feda4c1c8d317e4b07c | |
parent | 2a7f72885ff0623a0a625efb5ffeca6299fc4cf7 (diff) | |
download | meson-71804e56eb3612eabc51887fe4d46961684a3ecc.zip meson-71804e56eb3612eabc51887fe4d46961684a3ecc.tar.gz meson-71804e56eb3612eabc51887fe4d46961684a3ecc.tar.bz2 |
wrap: Add special 'dependency_names' key in [provide] section
The value for that key must be a coma separated list of dependecy names
provided by that subproject, when no variable name is needed because the
subproject uses override_dependency().
-rw-r--r-- | docs/markdown/Wrap-dependency-system-manual.md | 22 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 14 | ||||
-rw-r--r-- | test cases/common/102 subproject subdir/meson.build | 2 | ||||
-rw-r--r-- | test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap | 4 |
4 files changed, 34 insertions, 8 deletions
diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index cb7c6d6..b927944 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -145,12 +145,15 @@ wrap-git, the repository must contain all Meson build definitions. Wrap files can define the dependencies it provides in the `[provide]` section. When a wrap file provides the dependency `foo` any call do `dependency('foo')` will automatically fallback to that subproject even if no `fallback` keyword -argument is given. Each entry in the format `dependency_name = variable_name`, +argument is given. It is recommended for subprojects to call +`meson.override_dependency('foo', foo_dep)`, dependency name can then be added into +the special `dependency_names` entry which takes coma separated list of dependency +names. For backward compatibility with subprojects that does not call +`meson.override_dependency()`, the variable name can be provided in the wrap file +with entries in the format `dependency_name = variable_name`, where `dependency_name` usually match the corresponding pkg-config name and `variable_name` is the name of a variable defined in the subproject that should -be returned for that dependency. In the case the subproject uses -`meson.override_dependency('foo', foo_dep)` the `variable_name` can be left empty -in the wrap file. +be returned for that dependency. For example `glib.wrap` provides `glib-2.0`, `gobject-2.0` and `gio-2.0`. A wrap file for glib would look like: @@ -165,6 +168,17 @@ gobject-2.0=gobject_dep gio-2.0=gio_dep ``` +Alternatively, when using a recent enough version of glib that uses +`meson.override_dependency()`: +```ini +[wrap-git] +url=https://gitlab.gnome.org/GNOME/glib.git +revision=glib-2-62 + +[provide] +dependency_names = glib-2.0, gobject-2.0, gio-2.0 +``` + With such wrap file, `dependency('glib-2.0')` will automatically fallback to use `glib.wrap` and return `glib_dep` variable from the subproject. diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 63ee349..d645c2c 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -127,7 +127,19 @@ class PackageDefinition: def parse_provide_section(self): self.provide = {self.name: None} if self.config.has_section('provide'): - self.provide.update(self.config['provide']) + for k, v in self.config['provide'].items(): + if k == 'dependency_names': + # A coma separated list of dependency names that does not + # need a variable name + names = {n.strip(): None for n in v.split(',')} + self.provide.update(names) + continue + if not v: + m = ('Empty dependency variable name for {!r} in {}. ' + 'If the subproject uses meson.override_dependency() ' + 'it can be added in the "dependency_names" special key.') + raise WrapException(m.format(k, self.basename)) + self.provide[k] = v def get(self, key: str) -> str: try: diff --git a/test cases/common/102 subproject subdir/meson.build b/test cases/common/102 subproject subdir/meson.build index bc202a3..6faff75 100644 --- a/test cases/common/102 subproject subdir/meson.build +++ b/test cases/common/102 subproject subdir/meson.build @@ -31,7 +31,7 @@ d = dependency('sub_implicit') assert(d.found(), 'Should implicitly fallback') # Verify that implicit fallback works because sub_implicit.wrap has -# `sub_implicit_provide1=` and the subproject overrides sub_implicit_provide1. +# `dependency_names=sub_implicit_provide1` and the subproject overrides sub_implicit_provide1. d = dependency('sub_implicit_provide1') assert(d.found(), 'Should implicitly fallback') diff --git a/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap b/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap index c14fff0..e668a8d 100644 --- a/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap +++ b/test cases/common/102 subproject subdir/subprojects/sub_implicit.wrap @@ -1,5 +1,5 @@ [wrap-file] [provide] -sub_implicit_provide1= -sub_implicit_provide2=sub_implicit_provide2_dep +dependency_names = sub_implicit_provide1 +sub_implicit_provide2 = sub_implicit_provide2_dep |