diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-01-06 15:33:07 -0800 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-04-17 23:33:31 +0300 |
commit | 92487ea33db9d882929d755308853d2ed82abd0d (patch) | |
tree | 0272fa81d53e2f08b72e70e906bdc4d0df65f23e /docs/markdown | |
parent | 1952ef5ae13376084dc277de38ff3a6dafb8e595 (diff) | |
download | meson-92487ea33db9d882929d755308853d2ed82abd0d.zip meson-92487ea33db9d882929d755308853d2ed82abd0d.tar.gz meson-92487ea33db9d882929d755308853d2ed82abd0d.tar.bz2 |
Add partial_dependency method to dependencies
This adds a new method, partial_dependency to all dependencies. These
sub dependencies are copies of the original dependency, but with one or
more of the attributes replaced with an empty list. This allows creating
a sub dependency that has only cflags or drops link_arguments, for
example.
Diffstat (limited to 'docs/markdown')
-rw-r--r-- | docs/markdown/Reference-manual.md | 26 | ||||
-rw-r--r-- | docs/markdown/snippets/partial-dependencies.md | 25 |
2 files changed, 51 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 42abe75..74e7ff2 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1827,6 +1827,32 @@ an external dependency with the following methods: - `version()` is the version number as a string, for example `1.2.8` + - `partial_dependency(compile_args : false, link_args : false, links : false, + includes : false, source : false)` (*added 0.46.0) returns a new dependency + object with the same name, version, found status, type name, and methods as + the object that called it. This new object will only inherit other + attributes from its parent as controlled by keyword arguments. + + If the parent has any dependencies, those will be applied to the new + partial dependency with the same rules. So , given: + + ```meson + dep1 = declare_dependency(compiler_args : '-Werror=foo', link_with : 'libfoo') + dep2 = declare_dependency(compiler_args : '-Werror=bar', dependencies : dep1) + dep3 = dep2.partial_dependency(compile_args : true) + ``` + + dep3 will add `['-Werror=foo', '-Werror=bar']` to the compiler args of + any target it is added to, but libfoo will not be added to the link_args. + + The following arguments will add the following attributes: + + - compile_args: any arguments passed to the compiler + - link_args: any arguments passed to the linker + - links: anything passed via link_with or link_whole + - includes: any include_directories + - sources: any compiled or static sources the dependency has + ### `disabler` object A disabler object is an object that behaves in much the same way as diff --git a/docs/markdown/snippets/partial-dependencies.md b/docs/markdown/snippets/partial-dependencies.md new file mode 100644 index 0000000..8d2136a --- /dev/null +++ b/docs/markdown/snippets/partial-dependencies.md @@ -0,0 +1,25 @@ +## Added new partial_dependency method to dependencies and libraries + +It is now possible to use only part of a dependency in a target. This allows, +for example, to only use headers with convenience libraries to avoid linking +to the same library multiple times. + +```meson + +dep = dependency('xcb') + +helper = static_library( + 'helper', + ['helper1.c', 'helper2.c'], + dependencies : dep.partial_dependency(includes : true), +] + +final = shared_library( + 'final', + ['final.c'], + dependencyes : dep, +) +``` + +A partial dependency will have the same name version as the full dependency it +is derived from, as well as any values requested. |