Commit Graph

789 Commits

Author SHA1 Message Date
Dudemanguy 8b3a54e508 dependencies: cleanup kwargs.get('static') usage
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.
2022-05-03 23:03:56 -04:00
Paolo Bonzini 3a960023d3 interpreter: new function add_project_dependencies()
This function can be used to add fundamental dependencies such as glib
to all build products in one fell swoop.  This can be useful whenever,
due to a project's coding conventions, it is not really possible to
compile any source file without including the dependency.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-03 02:00:29 -04:00
Paolo Bonzini 06b76f7c9d dependencies: extract code to get all leaf dependencies
Extract to a separate function the code that resolves dependencies
for compiler methods.  We will reuse it for add_project_dependencies().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-03 02:00:29 -04:00
Daniel Mensinger 1a80e5b35e cmake: Fix CMake LLVM dependency error (fixes #10322) 2022-05-01 23:45:08 +03:00
Jussi Pakkanen bba588d8b0
Merge pull request #10039 from eli-schwartz/wayland-protocols-subproject-files
dependencies: allow get_variable to expose files from subprojects
2022-05-01 00:01:03 +03:00
Xavier Claessens 18bec0d3e3 pkgconfig: Use EnvironmentVariables to build PKG_CONFIG_* env
The new get_env() method that returns an EnvironmentVariables object
will be needed in next commit that will pass it to CustomTarget.

This has the side effect to use the proper os specific path separator
instead of hardcoding `:`. It is the obvious right thing to do here, but
has caused issues in the past. Hopefully issues have been fixed in the
meantime. If not, better deal with fallouts than keep doing the wrong
thing forever.
2022-04-30 15:01:28 -04:00
Eli Schwartz b55349c2e9
dependencies: tighten type checking and fix cmake API violation for get_variable
dep.get_variable() only supports string values for pkg-config and
config-tool, because those interfaces use text communication, and
internal variables (from declare_dependency) operate the same way.

CMake had an oddity, where get_variable doesn't document that it allows
list values but apparently it miiiiiight work? Actually getting that
kind of result would be dangerously inconsistent though. Also, CMake
does not support lists so it's a lie. Strings that are *treated* as
lists with `;` splitting don't count...

We could do two things here:

- raise an error
- treat it as a string and return a string

It's not clear what the use case of get_variable() on a maybe-list is,
and should probably be a hard error. But that's controversial, so
instead we just return the original `;`-delimited string. It is probably
the wrong thing, but users are welcome to cope with that somehow on
their own.
2022-04-13 17:27:09 -04:00
Eli Schwartz b5a81ff634
qt dependency: adapt to the qmake command changed name
Qt now has official guidance for the symlinked names of the tools, which
is great.

Qt now officially calls the tools `fooX` instead of `foo-qtX` where the
major version of Qt is X. Which is not great, because a bit of an
unofficial standard had prior art and now needs to change, and we never
adapted.

Prefer the official name whenever looking up qmake, and in the
testsuite, specifically look only for the official name on versions of
qt which we know should have that.
2022-04-12 20:44:07 -04:00
Eli Schwartz e223136b10
qt dependency: find the correct -qtX configtool name
Fixes regression in commit c211fea513. The
original dependency lookup looked for `qmake-{self.name}`, i.e.
`qmake-qt5`, but when porting to config-tool, it got switched to
`qmake-{self.qtname}` i.e. `qmake-Qt6`, which was bogus and never
worked. As a result, if `qmake-qt5` and `qmake` both existed, and the
latter was NOT qt5, it would only try the less preferred name, and then
fail.

We need to define self.name early enough to define the configtool names,
which means we need to set it before running the configtool __init__()
even though configtool/pkgconfig would also set it to the same value.

Mark the tests as passing on two distros that were failing to detect
qmake due to this issue, and were marked for skipping because we assumed
that the CI skipping there was an expected case rather than an old
regression.
2022-04-12 20:44:07 -04:00
John Lindgren a606ce22eb Add support for Qt 6.1+
Qt 6.1 moved the location of some binaries from QT_HOST_BINS to
QT_HOST_LIBEXECS as noted in the changelog:

c515ee178f Move build tools to libexec instead of the bin dir
- Tools that are called by the build system and are unlikely to be
called by the user are now installed to the libexec directory.

https://code.qt.io/cgit/qt/qtreleasenotes.git/tree/qt/6.1.0/release-note.txt

It's possible to help the 'qt' module find the tools by adding Qt's
libexec directory to the PATH environment variable, but this manual
workaround is not ideal.

To compensate, meson now needs to look for moc, rcc, uic, etc. in
QT_HOST_LIBEXECS as well as QT_HOST_BINS.

Co-authored-by: Stefan Hajnoczi <stefanha@jammr.net>
2022-04-12 20:42:42 -04:00
Daniel Mensinger 589600cb51 cmake: Always use all compilers for LLVM (fixes #10249) 2022-04-12 18:25:38 -04:00
Eli Schwartz c9938f8f60
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-29 16:44:54 -04:00
Hemmo Nieminen ceb6e26ff1 boost: preserve compiler/linker argument order
Looks like boost dependency mixes up it's compiler and linker argument
order when it is removing duplicates (?) from those. This causes
unnecessary recompilations of everything depending on those components.

Use OrderedSet to remove the duplicates while also maintaining
consistent order for them.
2022-03-23 20:46:59 +02:00
Remi Thebault 04fca24355 Fix DUB dependencies
- fix the research of target built by DUB
 - explicitely state that DUB dynamic libraries and source libraries are not supported (yet) (mesonbuild#6581)
 - fix the build settings of recipes having sub-dependencies (mesonbuild#7560)
 - fix winlibs added from dub recipe
 - sanitization, comments, explanations...
2022-03-23 10:21:21 -07:00
Jussi Pakkanen 69ade4f4cf
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
2022-03-13 01:01:55 +02:00
Eli Schwartz c231c4bd2a
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-07 19:09:50 -05:00
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Eli Schwartz 187dc656f4
merge various TYPE_CHECKING blocks into one
A bunch of files have several T.TYPE_CHECKING blocks that each do some
things which could just as well be done once, with a single `if`
statement. Make them do so.
2022-03-07 19:01:04 -05:00
Dylan Baker ba3d9b5d16 dependencies: Dependency Sources can be StructuredSources 2022-03-07 12:33:33 -08:00
Jussi Pakkanen 219f40c1e4
Merge pull request #9743 from mensinda/cmakeGeneratorFixed
cmake: Add TARGET_ generator expression support (fixes #9305)
2022-03-07 16:12:19 +02:00
Tristan Partin 498db2764c Add modules kwarg to JNI system dep
This allows someone to link against libjvm.so and libjawt.so.
2022-03-04 13:52:21 -05:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Tristan Partin 96b2469544 Rename JDK system dep to JNI
JNI is a more apt name because it currently only supports the JNI. I
also believe that CMake uses the terminology JNI here as well.

JNI is currently the only way to interact with the JVM through native
code, but there is a project called "Project Panama" which aims to be
another way for native code to interact with the JVM.
2022-03-02 16:23:09 -05:00
Eli Schwartz b7dec69b98 cheat and evade the detection of "open()" in custom_lint
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.
2022-03-01 12:13:24 -08:00
Eli Schwartz 140d6aef04 mark a bunch of dependencies with the version they were introduced
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".
2022-03-01 12:13:24 -08:00
Eli Schwartz 23e767176e allow dependency checks to bubble up feature warnings to the interpreter
It would be too difficult and probably a layering violation to give an
interpreter handle to the inner guts of every dependency. What we can do
instead is let every dependency track:

- the Feature checks it can produce,
- the version attribute for when it was implemented

while leaving the interpreter in charge of actually emitting them.
2022-03-01 12:13:24 -08:00
Eli Schwartz 1ac6fc0595
intl dependency: include header when checking for libc builtin
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.
2022-02-17 14:48:27 -05:00
Eli Schwartz 07d9c72e17
flake8: fix wrong numbers of blank line separators 2022-02-16 18:19:13 -05:00
Eli Schwartz baecebda0e
flake8: fix typoed whitespace surrounding tokens 2022-02-16 18:19:13 -05:00
Eli Schwartz 39f61795ca
comment out broken Feature checks that fail mypy
We currently cannot make this work because inside dependency() we don't
know the current subproject. We would also like the optional but
extremely useful location node, but we don't have that either...

Convert the broken code to a FIXME for visibility.
2022-02-14 20:40:41 -05:00
apoorv569 bab651a7a0 Add wx-config-3.1 provided by mingw-w64-x86_64-wxmsw3.1
On Windows using MSYS2 MinGW installing the package `mingw-w64-x86_64-wxmsw3.1` provides `wx-config-3.1`. I have tried building my software by making this exact change and it build correctly.
2022-02-14 15:48:55 -08:00
Eli Schwartz 96df0fc69e openssl dependency: add cmake support
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.
2022-02-02 07:10:55 -08:00
Eli Schwartz 0268c25791 dependencies: add a system dependency for OpenSSL
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.
2022-02-02 07:10:55 -08:00
Andrew Krasavin b564e34221 new custom dependency lookup for libdl 2022-02-01 15:51:15 -05:00
Xavier Claessens 0185f2ed61 Fix dep.get_variable() with empty string default_value 2022-02-01 00:47:33 +02:00
Eli Schwartz 3990dc6d64 flake8: fix indentation style 2022-01-27 10:48:01 -08:00
Eli Schwartz cf3a1d31f8 fix some flake8 violations for unused imports
And one undefined T.cast name in a file that isn't yet mypy-ready
anyway.
2022-01-27 10:48:01 -08:00
Daniel Mensinger 42843c4cf6
cmake: Add TARGET_ generator expression support (fixes #9305) 2022-01-23 13:22:59 +01:00
Dylan Baker 216435b2ae dependencies: fix libraries and whole_libraries types
gnome points out that CustomTargets can be linked with, so we should
allow that.
2022-01-18 21:58:24 -05:00
Dylan Baker 6b272973e0 dependencies: don't pass kwargs from get_pkgconfig_variable
This is a layering violation, we're relying on the way the interpreter
handles keyword arguments. Instead, pass them as free variables,
destructuring in the interpreter
2022-01-18 17:53:29 -05:00
Eli Schwartz 140097faf0
port from embedded data to importlib.resources 2022-01-10 18:36:57 -05:00
Eli Schwartz 751f84405e
pyupgrade --py37-plus 2022-01-10 18:36:56 -05:00
Daniel Mensinger c5ce9744b2 Fix mypy errors 2021-12-17 14:00:28 -05:00
Christoph Reiter a2934ca9d1 intl dep: forward static to iconv if needed
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.
2021-12-12 07:15:01 -05:00
Daniel Mensinger 45c5300496 cmake: Fix old style dependency lookup with imported targets
This also includes some refactoring, since the alternaticve would
have been to duplicate the huge traceparser target code block again.

fixes #9581
2021-12-01 21:03:36 +02:00
Eli Schwartz 1e19757899 iconv dependency: try even harder to find working iconv
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
2021-11-28 18:30:01 +02:00
Eli Schwartz db1fa702f3 iconv dependency: include header when checking for libc builtin
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.
2021-11-25 11:49:18 +05:30
Dudemanguy e67c07c006 dependencies/zlib: Allow for generic OS checks
Contrary to most system method checks, zlib currently functions as a
whitelist of OSes. This isn't really needed however. The first special
case for OSes that provide zlib as part of the base OS is worth keeping.
However, the elif for windows is more than generic enough to allow any
other potential OSes to try. Just make it a simplie if/else instead.
2021-11-20 23:54:33 -05:00
Jon Turney 61ca56422b cmake: Use find_library() on bare library names in cmake dependencies
Convert bare library names to a dependency linker argument using
find_library(), rather than hardcoding the MSVC transformation.
2021-11-20 08:29:50 -08:00
Eli Schwartz 4f4259de1b hdf5 dependency: check for alternative config-tool names
Depending on whether hdf5 is compiled with parallel support, the
same config-tool program may be installed with a mysterious "p" in the
name. In this case, dependency lookup will totally fail, unless of
course you use the superior pkg-config interface in which case you get a
predictable name.

Work around this insanity by checking for both types of config-tool
name.

Fixes #9555
2021-11-17 23:07:14 +02:00