The latest release of libpcap added argument validation to pcap-config,
but still doesn't support --version. The next version of libpcap will
support --version.
Add support for config-tool dependencies which expect to break on
--version, to fallback to an option that does not error out or print
version info, for sanity checking.
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).
Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
Add a MissingCompiler class returned by compiler detecting methods
intead of None - accessing such an object raises a DependencyException
Fixes#10586
Co-authored-by: duckflyer <duckflyer@gmail.com>
A bunch of SystemDependency subclasses overrode log_tried() even though
they used the same function anyway. Delete them -- they still print
the same thing either way.
By default, meson will try to look for shared libraries first before
static ones. In the meson.build itself, one can use the static keyword
to control if a static library will be tried first but there's no simple
way for an end user performing a build to switch back and forth at will.
Let's cover this usecase by adding an option that allows a user to
specify if they want dependency lookups to try static or shared
libraries first. The writer of the meson.build can manually specify the
static keyword where appropriate which will override the value of this
option.
In a couple of spots, kwargs.get('static', False) was being
unneccesarily used. In these spots, we can just use self.static instead
which is already inherited from the ExternalDependency. In additional,
the python system dependency oddly has a kwargs.get('static', False)
line which overrides the self.static in that dependency for no real
reason. Delete this line too.
It's a dumb check which doesn't know the difference between python
functions and string data. Work around this by changing the message
output to not include an opening parenthesis, and changing other similar
strings the same way for consistency.
All these dependencies are impossible to find on versions of Meson older
than the ones they got custom lookups in, because they don't provide
pkg-config files. So they should not / cannot be reasonably used on
older versions, and it is easy to say "yep, these should emit a
FeatureNew for the versions they got added in".
This header is required anyway. And the compile test for linking to libc
with the gettext symbol, can succeed when we try to use the literal
symbol name without includes, but fail later during project build,
because actually including libintl.h might redefine the function to match
a forked symbol. This happens when GNU libintl is installed as a
standalone library on systems that have a less fully-featured gettext
implementation.
So, by including the header in has_function, we can ensure that we test
against the default resolved header. In the event that the symbol which
is #define'd by the header is 'libintl_gettext', linking will fail against
libc even when a builtin gettext does exist, and we will fall back to the
intl dependency that provides -lintl (and which is needed to properly
use the default header).
Of course, even that probably won't work.
has_function(prefix: '...') is useless to check the difference between
builtins and external library functions. It has code to detect
"builtins" that misfires in some cases (previously seen with iconv_open).
Instead compile an open-coded test file that this intl dependency
implementation fully controls, that doesn't get up to imaginative edge
cases like trying to find `__builtin_gettext`.
It's the only way to be sure.
Fixes compiling against the intl dependency on e.g. Alpine Linux when the
libintl package is installed.
This is gross and looks terrible, but I'm not entirely sure how else to
do this.
And cmake is an inferior methodology, TBH, since it is effectively the
same as our own builtins. However, cmake also handles some bizarre
Windows library names whose provenance I'm not entirely sure of, in
addition to implementing the usual excessive pattern of hardcoded search
directories. So, this may be useful, at least on Windows, as a fallback.
(I am not really interested in offering feature compatibility with cmake
for a bunch of bizarre naming schemes that ***aren't the official cmake
library names***, so if cmake allows that and people really feel they
need it, all the more power to them.)
Nevertheless, I believe if it got found via our system dependency class,
it will always provide results which are just as functional as cmake.
cmake can only find openssl installations that would otherwise be
missed.
This also avoids the case where users did
```
dependency('OpenSSL', modules: [...], method: 'cmake')
```
and expected it to work, since our builtin dependency supersedes the
divergent case and didn't previously allow the cmake method. I don't
know why they would do such a thing, but who knows... it is always
possible.
On some platforms, this is provided by the base system, which
nevertheless refrains from providing the .pc files that go along with
it. As a result, it's impossible to sensibly find these dependencies.
I'm looking at you, FreeBSD...
Upstream tracking bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257659
This is also a problem on macOS, but that's unfixable (and I believe
they provide some truly ancient and out-of-support version anyway) and
you probably want to use the homebrew OpenSSL. Still, meson can now
detect these old versions and even set their version number.
In 1fb6c93947 the intl dep gained support for static linking
which also forwarded this property to the iconv sub dependency.
The refactoring in 214d03568f lost this change, which results in
iconv getting linked dynamically again.
Forward static again to fix this.
has_function(prefix: '...') is useless to check the difference between
builtins and external library functions. It has code to detect
"builtins" that misfires and reports that iconv_open is defined as a
builtin on mingw, but only if you include the header.
Instead compile an open-coded test file that this iconv dependency
implementation fully controls, that doesn't get up to imaginative edge
cases like trying to find `__builtin_iconv_open`.
Fixes commit db1fa702f3, which merely
moved the brokenness over one step to the right (by breaking mingw
instead of freebsd)
Fixes https://github.com/mesonbuild/meson/pull/9632#issuecomment-979581509
This header is required anyway. And the compile test for linking to libc
with the iconv_open symbol, can succeed when we try to use the literal
symbol name without includes, but fail later during project build,
because actually including iconv.h might redefine the function to match
a forked symbol. This happens when GNU iconv is installed as a
standalone library on systems that have a less fully-featured iconv
implementation.
So, by including the header in has_function, we ensure that we test
against the default resolved header. In the event that the symbol which
is #define'd by the header is 'libiconv_open', linking will fail against
libc even when a builtin iconv does exist, and we will fall back to the
iconv dependency that provides -liconv (and which is needed to properly
use the default header).
Fixes compiling against the iconv dependency on e.g. FreeBSD when the
libiconv port is installed.
Since intl links internally to iconv, try to pull in iconv too, but only
if we specifically ask for static libs.
If PREFER_SHARED, we have no way to tell which type we got, so do not
try handling that...
Although find_library returns the library as a list of args, has_header
returns a tuple(is_found, is_cached) which is non-empty and thus always
true. Which is confusing...
Check whether it actually got found.
Both of these are artifacts of the time before Dependency Factories,
when a dependency that could be discovered multiple ways did ugly stuff
like finding a specific dependency, then replacing it's own attributes
with that dependency's attributes. We don't have cases of that left in
the tree, so let's get rid of this code too
Checking how to aquire the *gettext family of symbols portably is
annoyingly complex, and may come from the libc, or standalone.
builtin dependency:
This detects if libintl is unneeded, because the *gettext family of
symbols is available in the libc.
system dependency:
This detects if libintl is installed as separate software, linkable via
-lintl; unfortunately, GNU gettext does not ship pkg-config files for
it.
Fixes#3929
Currently if the version returned is not a supported version, then you
get a lovely stack trace. This is not nice. This can be triggered easily
by adding gcc's `-fdirectives-only` flag, which stops the preprocessor
from doing certain macro expansions, including those used to detect
OpenMP.
Fixes#8652
with msys ncurses-config returns a unix style path (currently, though
it's been fixed upstream), which the compilers don't understand, so we
can't do that. Additionally, while the system search does work, there's
missing include directories that need to be added.
On win32 there is pdcurses, so we detect it first, because python
depends on ncursesw, so if we don't want to use ncursesw, we should make
sure pdcurses detect before ncursesw
The linker that comes with MSVC does not understand the /openmp flag.
This results in a string of
LINK : warning LNK4044: unrecognized option '/openmp'; ignored
warnings, one for each static_library linked with an executable.
Avoid this by only setting the linker openmp flag when the compiler is
not MSVC.
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.
Fixes#7082