New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document or improve empty dependency objects #2324
Comments
See: #1753 |
Yuck. Also, this isn't a general solution. Dependency objects support other methods (get_pkgconfig_variable(), type_name(), version()) and attempts to use those methods on an empty list will fail similarly. Dependency objects might also learn additional methods in the future. From a consistency point of view, having this be a dependency object, rather than have lists sometimes behave a bit like a dependency object, seems preferable... |
I notice that buried in the documentation for executable() is the sentence:
I'd suggest removing this. |
Those won't work on not-found dependencies, so you always have to wrap them inside a
Later in the PR, we talk about how having a
Why? This works just fine for lists of dependencies. |
Document the dependency('', required:false) usage. Add dependency() as a shorthand for that. Fixes mesonbuild#2324
Document the dependency('', required:false) usage. Add dependency() as a shorthand for that. Avoid emitting 'Dependency found: NO' in either case. Fixes mesonbuild#2324
Are you sure?
The documentation explicitly mentions that calling get_pkgconfig_variable() on a non-pkgconfig dependency is an error (and indeed it does cause an NotImplementedError exception), but doesn't exclude this usage . |
This tells people to write: if some_condition
dep = []
else
dep = dependency('some_dependency')
endif
executable(..., dependencies: dep, ...) This is not the best way to handle this, because this is just a |
Document the dependency('', required:false) usage. Add dependency() as a shorthand for that. Avoid emitting 'Dependency found: NO' in either case. Fixes mesonbuild#2324 v2: Don't accidentally permit dependency('', 'foo', 'bar', 'baz', required:false) Set type_name() to 'not-found'
Document the dependency('', required:false) usage. Add dependency() as a shorthand for that. Avoid emitting 'Dependency found: NO' in either case. Fixes mesonbuild#2324 v2: Don't accidentally permit dependency('', 'foo', 'bar', 'baz', required:false) Set type_name() to 'not-found'
It's ok to use an empty list for dependencies:, but it's not ok to try to use the found() method of it. See also mesonbuild/meson#2324
It's ok to use an empty list for dependencies:, but it's not ok to try to use the found() method of it. See also mesonbuild/meson#2324
That works right now because the underlying implementation is a PkgConfigDependency. When #2512 lands, Relatedly, another use-case for a 'disabled dependency' is platform-specific internal dependencies such as |
@nirbheek, I've had this thought that really the get_configtool_variable/get_pkgconfig_variable situation could be improved via a generic mechanism, something like: I really like the idea of the empty dependency, it would allow the mesa build to be simplified as we have several optional dependencies and a lot of platform specific dependencies, and replacing checks like |
Closed by #2615 |
An example extracted from xserver meson.build, where we had [] assigned to variable used for a dependency, to represent a null value
This fails (in some configurations) with
Arrays do not have a method called 'found'
.One can write:
to get a dependency object for which found() is always false if the option is disabled, but this is undocumented, and has the side-effect of
during configuration
The text was updated successfully, but these errors were encountered: