From 56c9e95b04b51def7443a514e5021fa7b70fe8c8 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 4 Apr 2020 17:39:39 -0400 Subject: Implicit dependency fallback when a subproject wrap or dir exists --- docs/markdown/Reference-manual.md | 4 +++- docs/markdown/snippets/implicit_fallback.md | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 docs/markdown/snippets/implicit_fallback.md (limited to 'docs') diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index dad8c12..293e41f 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -456,7 +456,9 @@ arguments: *(since 0.54.0)* `'subproj_dep'` argument can be omitted in the case the subproject used `meson.override_dependency('dependency_name', subproj_dep)`. In that case, the `fallback` keyword argument can be a single string instead - of a list of 2 strings. + of a list of 2 strings. *Since 0.55.0* the `fallback` keyword argument can be + omitted when there is a wrap file or a directory with the same `dependency_name`, + and subproject used `meson.override_dependency('dependency_name', subproj_dep)`. - `language` *(since 0.42.0)*: defines what language-specific dependency to find if it's available for multiple languages. - `method`: defines the way the dependency is detected, the default is diff --git a/docs/markdown/snippets/implicit_fallback.md b/docs/markdown/snippets/implicit_fallback.md new file mode 100644 index 0000000..87003d0 --- /dev/null +++ b/docs/markdown/snippets/implicit_fallback.md @@ -0,0 +1,9 @@ +## Implicit dependency fallback + +`dependency('foo')` now automatically fallback if the dependency is not found on +the system but a subproject wrap file or directory exists with the same name. + +That means that simply adding `subprojects/foo.wrap` is enough to add fallback +to any `dependency('foo')` call. It is however requires that the subproject call +`meson.override_dependency('foo', foo_dep)` to specify which dependency object +should be used for `foo`. -- cgit v1.1 From 2a7f72885ff0623a0a625efb5ffeca6299fc4cf7 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 4 Apr 2020 23:56:33 -0400 Subject: wrap: Add 'provide' section --- docs/markdown/Reference-manual.md | 4 +++- docs/markdown/Wrap-dependency-system-manual.md | 32 +++++++++++++++++++++++++- docs/markdown/snippets/implicit_fallback.md | 7 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 293e41f..9bca74b 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -458,7 +458,9 @@ arguments: In that case, the `fallback` keyword argument can be a single string instead of a list of 2 strings. *Since 0.55.0* the `fallback` keyword argument can be omitted when there is a wrap file or a directory with the same `dependency_name`, - and subproject used `meson.override_dependency('dependency_name', subproj_dep)`. + and subproject registered the dependency using + `meson.override_dependency('dependency_name', subproj_dep)`, or when the wrap + file has `dependency_name` in its `[provide]` section. - `language` *(since 0.42.0)*: defines what language-specific dependency to find if it's available for multiple languages. - `method`: defines the way the dependency is detected, the default is diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index e59a6be..cb7c6d6 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -105,7 +105,7 @@ of downloading the file, even if `--wrap-mode` option is set to valid value (such as a git tag) for the VCS's `checkout` command, or (for git) `head` to track upstream's default branch. Required. -## Specific to wrap-git +### Specific to wrap-git - `depth` - shallowly clone the repository to X number of commits. Note that git always allow shallowly cloning branches, but in order to clone commit ids shallowly, the server must support @@ -138,6 +138,36 @@ put them somewhere where you can download them. Meson build patches are only supported for wrap-file mode. When using wrap-git, the repository must contain all Meson build definitions. +## `provide` section + +*Since *0.55.0* + +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`, +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. + +For example `glib.wrap` provides `glib-2.0`, `gobject-2.0` and `gio-2.0`. A wrap +file for glib would look like: +```ini +[wrap-git] +url=https://gitlab.gnome.org/GNOME/glib.git +revision=glib-2-62 + +[provide] +glib-2.0=glib_dep +gobject-2.0=gobject_dep +gio-2.0=gio_dep +``` + +With such wrap file, `dependency('glib-2.0')` will automatically fallback to use +`glib.wrap` and return `glib_dep` variable from the subproject. + ## Using wrapped projects Wraps provide a convenient way of obtaining a project into your subproject directory. diff --git a/docs/markdown/snippets/implicit_fallback.md b/docs/markdown/snippets/implicit_fallback.md index 87003d0..bad1c71 100644 --- a/docs/markdown/snippets/implicit_fallback.md +++ b/docs/markdown/snippets/implicit_fallback.md @@ -7,3 +7,10 @@ That means that simply adding `subprojects/foo.wrap` is enough to add fallback to any `dependency('foo')` call. It is however requires that the subproject call `meson.override_dependency('foo', foo_dep)` to specify which dependency object should be used for `foo`. + +## Wrap file `provide` section + +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. See [Wrap documentation](Wrap-dependency-system-manual.md#provide_section). -- cgit v1.1 From 71804e56eb3612eabc51887fe4d46961684a3ecc Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 13 Apr 2020 18:12:43 -0400 Subject: 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(). --- docs/markdown/Wrap-dependency-system-manual.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'docs') 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. -- cgit v1.1 From f08eed37cb69ba0d793c0f1d086eaef7f25c2ea3 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 20 Apr 2020 19:14:49 -0400 Subject: find_program: Fallback if a wrap file provide the program name We don't need the legacy variable name system as for dependency() fallbacks because meson.override_find_program() is largely used already, so we can just rely on it. --- docs/markdown/Wrap-dependency-system-manual.md | 13 +++++++++++++ docs/markdown/snippets/implicit_fallback.md | 5 +++++ 2 files changed, 18 insertions(+) (limited to 'docs') diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index b927944..dd8595b 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -71,6 +71,7 @@ revision = head - `directory` - name of the subproject root directory, defaults to the name of the wrap. Since *0.55.0* those can be used in all wrap types, they were previously reserved to `wrap-file`: + - `patch_url` - download url to retrieve an optional overlay archive - `patch_fallback_url` - fallback URL to be used when download from `patch_url` fails *Since: 0.55.0* - `patch_filename` - filename of the downloaded overlay archive @@ -182,6 +183,18 @@ 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. +Programs can also be provided by wrap files, with the `program_names` key: +```ini +[wrap-git] +... + +[provide] +program_names = myprog, otherprog +``` + +With such wrap file, `find_program('myprog')` will automatically fallback to use +the subproject, assuming it uses `meson.override_find_program('myprog')`. + ## Using wrapped projects Wraps provide a convenient way of obtaining a project into your subproject directory. diff --git a/docs/markdown/snippets/implicit_fallback.md b/docs/markdown/snippets/implicit_fallback.md index bad1c71..3d5a833 100644 --- a/docs/markdown/snippets/implicit_fallback.md +++ b/docs/markdown/snippets/implicit_fallback.md @@ -14,3 +14,8 @@ 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. See [Wrap documentation](Wrap-dependency-system-manual.md#provide_section). + +## `find_program()` fallback + +When a program cannot be found on the system but a wrap file has its name in the +`[provide]` section, that subproject will be used as fallback. -- cgit v1.1 From fba796cf1312715b8b97dcb80a4b5c200332b2e8 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 29 May 2020 11:36:06 -0400 Subject: Fix typo: coma->comma --- docs/markdown/Wrap-dependency-system-manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index dd8595b..c96c73a 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -148,7 +148,7 @@ 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. 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 +the special `dependency_names` entry which takes comma 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`, -- cgit v1.1 From 95c3fee47d75ef493865b3ffbcea7989ef246287 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 12 Jun 2020 11:57:25 -0400 Subject: wrap: Update doc to give dependency_names example first --- docs/markdown/Wrap-dependency-system-manual.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index c96c73a..0ff304d 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -156,28 +156,28 @@ 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. -For example `glib.wrap` provides `glib-2.0`, `gobject-2.0` and `gio-2.0`. A wrap -file for glib would look like: +For example when using a recent enough version of glib that uses +`meson.override_dependency()` to override `glib-2.0`, `gobject-2.0` and `gio-2.0`, +a wrap file would look like: ```ini [wrap-git] url=https://gitlab.gnome.org/GNOME/glib.git revision=glib-2-62 [provide] -glib-2.0=glib_dep -gobject-2.0=gobject_dep -gio-2.0=gio_dep +dependency_names = glib-2.0, gobject-2.0, gio-2.0 ``` -Alternatively, when using a recent enough version of glib that uses -`meson.override_dependency()`: +With older version of glib dependency variable names need to be specified: ```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 +glib-2.0=glib_dep +gobject-2.0=gobject_dep +gio-2.0=gio_dep ``` With such wrap file, `dependency('glib-2.0')` will automatically fallback to use -- cgit v1.1