@@ -51,6 +51,37 @@ If the project name is too generic or ambiguous (e.g. `benchmark`),
5151consider using ` organization-project ` naming format (e.g.
5252` google-benchmark ` ).
5353
54+ ## Overriding dependencies in the submitted project
55+
56+ Ideally the project you submit should make a call to ` meson.override_dependency `
57+ for each dependency you would like to expose, with the first argument
58+ matching the pkg-config file name. This abstracts away the
59+ need to know and keep track of the variable names downstream.
60+
61+ For instance, the Apache Arrow project exposes multiple dependencies like
62+ its base ` arrow ` library, along with an ` arrow-compute ` library. The
63+ project generates ` arrow.pc ` and ` arrow-compute.pc ` files for pkg-config
64+ respectively, so internally the project also calls:
65+
66+ ``` meson
67+ arrow_dep = declare_dependency(...)
68+ meson.override_dependency('arrow', arrow_dep)
69+
70+ arrow_compute_dep = declare_dependency(...)
71+ meson.override_dependency('arrow-compute', arrow_compute_dep)
72+ ```
73+ Note that ` meson.override_dependency ` was introduced in Meson version
74+ 0.54.0. If your project supports older versions of Meson, you should
75+ add a condition to only call that function in versions where it is
76+ available:
77+
78+ ``` meson
79+ if meson.version().version_compare('>=0.54.0')
80+ meson.override_dependency('arrow', arrow_dep)
81+ meson.override_dependency('arrow-compute', arrow_compute_dep)
82+ endif
83+ ```
84+
5485## How to contribute a new wrap
5586
5687If the project already uses Meson build system, then only a wrap file
@@ -83,22 +114,41 @@ shasum -a 256 path/to/libfoo-1.0.0.tar.gz
83114
84115Next you need to add the entries that define what dependencies the
85116current project provides. This is important, as it is what makes
86- Meson's automatic dependency resolver work. It is done by adding a
87- ` provide ` entry at the end of the ` upstream.wrap ` file. Using the Ogg
88- library as an example, this is what it would look like:
117+ Meson's automatic dependency resolver work.
118+
119+ Assuming the project that you are creating
120+ a wrap file for has called ` meson.override_dependency ` , then you
121+ can declare those overridden dependencies in the ` provide ` section
122+ of the wrap file:
123+
124+ ``` ini
125+ [provide]
126+ dependency_names = arrow, arrow_compute
127+ ```
128+
129+ In the case that you do not control the upstream Meson configuration
130+ and it does not already make a call to ` meson.override_dependency ` ,
131+ then you can still expose dependency variables in the wrap file, using
132+ a syntax like:
89133
90134``` ini
91135[provide]
92- ogg = ogg_dep
136+ arrow = arrow_dep
137+ arrow_compute = arrow_compute_dep
93138```
94139
95- The ` ogg ` part on the left refers to the dependency name, which should
96- be the same as its Pkg-Config name. ` ogg_dep ` on the right refers to
97- the variable in the build definitions that provides the dependency.
98- Most commonly it holds the result of a ` declare_dependency ` call. If a
99- variable of that name is not defined, Meson will exit with a hard
100- error. For further details see [ the main Wrap
101- manual] ( Wrap-dependency-system-manual.md ) .
140+ The ` arrow ` and ` arrow_compute ` parts on the left refer to the dependency
141+ names, which should be the same as their Pkg-Config name. ` arrow_dep ` and
142+ ` arrow_compute_dep ` on the right refer to the variables in the build
143+ definition that provide the dependencies. Most commonly, they hold the
144+ result of a ` declare_dependency ` call. If a variable of that name is
145+ not defined, Meson will exit with a hard error. For further details see
146+ [ the main Wrap manual] ( Wrap-dependency-system-manual.md ) .
147+
148+ However, it is strongly advised in such cases to request that the upstream
149+ repository use ` meson.override_dependency ` for its next release, so that
150+ the variable names chosen in the upstream configuration file can be
151+ decoupled from the wrap file contents.
102152
103153Now you can create the build files, if the upstream project does not
104154contain any, and work on them until the project builds correctly.
0 commit comments