Commit Graph

632 Commits

Author SHA1 Message Date
Charles Brunet f9479787a0 fix reconfigure subproject base options 2024-03-10 13:09:32 -07:00
Charles Brunet 76f6874e48 Fix base and compiler options not reconfigurable.
Fixes #12920.
2024-03-01 12:09:22 -08:00
Xavier Claessens 114e032e6a cargo: Expose features as Meson boolean options 2024-02-26 10:03:52 -05:00
Xavier Claessens 5654f03450 interpreter: Dependency variables can be empty string
There is no reason to forbid empty variables, PkgConfigCLI.variable()
even has code specifically for handling that case.
2024-02-26 10:03:51 -05:00
Charles Brunet 11f2e07071 Allow using CustomTarget as test executable
Fixes #6567
2024-02-24 09:08:20 -08:00
Charles Brunet 138e0fe984 env.unset method 2024-02-23 21:11:56 +02:00
Dylan Baker e7f20efc8b modules/rust: allow setting a version constraint on bindgen
This allows us to ensure that the bindgen we're using is suitable for
our purpose.
2024-02-23 09:48:32 -08:00
Dylan Baker 95b3b9f710 coredata: use a Protocol for shared options between setup configure and dist
These are all passed around interchangably inside Meson, so use a shared
protocol for them.
2024-02-23 08:47:01 -08:00
Tristan Partin b08d531c02 Document that alias_target accepts run_tgts since 0.60.0
This was implemented in dc51740e2c,
but was not added to the documentation or marked as a new feature.
2024-02-09 11:56:13 -05:00
Charles Brunet d7bf365acd Fix compiler.preprocess compile_args not used
As described in
https://github.com/mesonbuild/meson/issues/12715#issuecomment-1883448780,
the compiler.preprocess function ignores compile_args. This should fix
it in both ninja and visualstudio backends.
2024-01-25 11:06:56 -08:00
Dylan Baker adc8d6bae4 interpreter: replace mock keyword argument with unittest.mock
Python provides some nifty tools for mocking, without relying on
altering running code. We should use these to simplify the actual run
paths and move the complicated logic into tests.
2024-01-25 10:01:50 -08:00
Eli Schwartz 5e76e2a7ff
Add missing FeatureNew for meson.add_dist_script
Per the docs, it is available since 0.48.0. Notify about this at runtime
too.

Fixes #12773
2024-01-25 00:33:40 -05:00
Stas Sergeev 92f638e1f9 compiler.preprocess: add depends kwarg
This patch adds 'depends' keyword to compiler.preprocess().
It allows to execute other targets before doing the preprocessing.
Test-case is added to demonstrate that functionality: it
generates the header before preprocessing the C source that
uses that generated header.

Thanks to @bruchar1 for getting this patch to work.
2024-01-17 13:37:36 -08:00
Dylan Baker 730cce09bd
interpreter: Also check for msvc style /fsanitize 2023-12-20 14:17:09 -05:00
Dylan Baker 8db1ca1766
interpreter: Don't warn on -fsanitze-*
We really only want to warn on `-fsanitize=foo` or `-fsanitize foo`, but
not things like `-fsanitize-recover=...`

Fixes #9822
Fixes #7192
2023-12-20 14:17:09 -05:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
Eli Schwartz caa38dad45 fix broken type annotation imports being ignored
If an annotation could not be resolved, it's classified as a "missing
import" and our configuration ignored it:

```
Skipping analyzing "mesonbuild.backends": module is installed, but missing library stubs or py.typed marker
```

As far as mypy is concerned, this library may or may not exist, but it
doesn't have any typing information at all (may need to be installed
first).

We ignored this because of our docs/ and tools/ thirdparty dependencies,
but we really should not. It is trivial to install them, and then
enforce that this "just works".

By enforcing it, we also make sure typos get caught.
2023-11-26 17:12:52 -05:00
Xavier Claessens 85e4ee5b54 File: Add full_path() method
This is needed now that str.format() is not allowing it any more. It is
also more consistent with other objects that have that method as well,
such as build targets.

Fixes: #12406
2023-11-24 22:15:14 +02:00
Eli Schwartz 398c4b2287
dependencies: allow get_variable to define multiple pkgconfig defines
It was previously impossible to do this:

```
dep.get_pkgconfig_variable(
    'foo',
    define_variable: ['prefix', '/usr', 'datadir', '/usr/share'],
)
```

since get_pkgconfig_variable mandated exactly two (if any) arguments.

However, you could do this:
```
dep.get_variable(
    'foo',
    pkgconfig_define: ['prefix', '/usr', 'datadir', '/usr/share'],
)
```

It would silently do the wrong thing, by defining "prefix" as
`/usr=datadir=/usr/share`, which might not "matter" if only datadir was
used in the "foo" variable as the unmodified value might be adequate.

The actual intention of anyone writing such a meson.build is that they
aren't sure whether the .pc file uses ${prefix} or ${datadir} (or which
one gets used, might have changed between versions of that .pc file,
even).

A recent refactor made this into a hard error, which broke some projects
that were doing this and inadvertently depending on some .pc file that
only used the second variable. (This was "fine" since the result was
essentially meaningful, and even resulted in behavior identical to the
intended behavior if both projects were installed into the same prefix
-- in which case there's nothing to remap.)

Re-allow this. There are two ways we could re-allow this:
- ignore it with a warning
- add a new feature to allow actually doing this

Since the use case which triggered this bug actually has a pretty good
reason to want to do this, it makes sense to add the new feature.

Fixes https://bugs.gentoo.org/916576
Fixes https://github.com/containers/bubblewrap/issues/609
2023-11-14 14:59:12 -05:00
Dylan Baker f8e87134a4 type_checking: simplify error message for object validation 2023-11-14 00:36:51 +02:00
Dylan Baker 7e1aed0abc type_checking: fix typo 2023-11-14 00:36:51 +02:00
Eli Schwartz cddf2e9d87 fix another regression in converting build_target kwargs to typed_kwargs
This time we have a case where people are passing non-objects by using
them as str | File, which we never warned about and silently accepted.
If it was passed via custom_target outputs we *would* error out,
interestingly enough. At the backend layer, we just pass them directly
to the linker... which is valid, if we misdetected what's a valid linker
input or people just used funny names. In particular, the mingw
toolchain allows passing a *.def file directly, and some people are
doing that.

If we do want to allow this, we should do it consistently. For now, just
follow the current theme of what's expected, but do so by warning
instead of fatally erroring, for cases where users were able to do it in
the past.
2023-11-13 23:43:42 +02:00
Eli Schwartz 76e6340f4b fix regression in converting build_target kwargs to typed_kwargs
We haven't actually verified that these kwargs are equal to what we had
before, and should probably revert the entire series. But I have
multiple reports in the wild of projects that no longer build because of
`install: [true, false, get_option('foobar')]` which was always
incorrect and always equal to just dropping values all over the floor
and treating it the same as "bool(value) == True".

Special case this particular typed kwarg and allow it with a sternly
worded warning that it was always wrong and should never ever ever be
done.

Fixes: https://bugs.gentoo.org/917118
Fixes: http://qa-logs.debian.net/2023/11/11/rhythmbox_3.4.7-1_unstable_meson-exp.log

Thanks to the Gentoo Tinderbox project, and Lucas Nussbaum of the Debian
project.
2023-11-12 20:39:49 +02:00
Eli Schwartz 01368ffb29
simd module: fix regression that broke using only some simd variants
Regression in commit a3d287c553.

When a given kwarg is not specified, we want to not generate it as a
simd variant. Since the default for buildtarget sources is `[]` it
resulted in building a static library with no sources, and a warning
stating that this was buggy and will eventually be removed.

Fix this by teaching buildtarget sources to allow None, and defaulting
to it specifically for the simd module. We can check this and then skip
processing entirely.

Fixes #12438
2023-10-28 21:58:54 -04:00
Dudemanguy e9e098b73e build: improve the warning for executables with the same name
adb1a360b9 added the feature and also the
usual meson-style warning to users that might be using the feature but
were not targeting a new enough meson version. Well unfortunately the
warning both doesn't actually work (it didn't take different directories
into account) and is also really slow because it creates an O(N^2) loop
for checking this.

Instead, rework this by adding an additional set that stores a tuple
containing the target name and its subdirectory. We only add this tuple
if the target is an executable since it is the only time it will be
relevant. After that, simply check if the name + subdir combination
already exists in the set along with the target being executable. If so,
then we execute FeatureNew which may possibly warn. This is a simply
O(1) lookup which is way faster. Fixes #12404.
2023-10-25 23:43:40 +03:00
Dylan Baker e419184a9b interpreter: use typed_kwargs for build_target.objects 2023-10-17 08:09:06 -07:00
Dylan Baker d5bdcf1145 interpreter: use typed_kwargs for build_target.resources 2023-10-17 08:09:06 -07:00
Dylan Baker 1abdd9dd61 interpreter: use typed_kwargs for build_target.name_suffix 2023-10-17 08:09:06 -07:00
Dylan Baker 9f80a069ec interpreter: use typed_kwargs for build_target.name_prefix 2023-10-17 08:09:06 -07:00
Dylan Baker 4386419a86 interpreter: use typed_kwargs for build_target.link_depends 2023-10-17 08:09:06 -07:00
Dylan Baker d38bf5fbb0 interpreter: use typed_kwargs for build_target.gnu_symbol_visibility 2023-10-17 08:09:06 -07:00
Dylan Baker 0f23dc5b03 interpreter: use typed_kwargs for build_target.link_language 2023-10-17 08:09:06 -07:00
Dylan Baker e06ae90677 interpreter: use typed_kwargs for build_target.install_rpath 2023-10-17 08:09:06 -07:00
Dylan Baker b02d23206a interpreter: use typed_kwargs for build_target.build_rpath 2023-10-17 08:09:06 -07:00
Dylan Baker a3444d31db interpreter: use typed_kwargs for build_target.implicit_include_directories 2023-10-17 08:09:06 -07:00
Dylan Baker ca32ffc157 interpreter: use typed_kwargs for build_target.extra_files 2023-10-17 08:09:06 -07:00
Dylan Baker 357abf51c5 interpreter: use typed_kwargs for build_target.native 2023-10-17 08:09:06 -07:00
Dylan Baker 2fc8729078 interpreter: use typed_kwargs for build_target.install_mode 2023-10-17 08:09:06 -07:00
Dylan Baker bae2e13b39 interpreter: use typed_kwargs for build_target.install 2023-10-17 08:09:06 -07:00
Dylan Baker 507d8bf4d7 interpreter: use typed_kwargs for build_target.build_by_default
This allows a little bit of cleanup in the build layer, since there is
code now that would always be true and we shouldn't do that.
2023-10-17 08:09:06 -07:00
Dylan Baker 7c101413d0 interpreter: use typed_kwargs for build_target.d_unittest 2023-10-16 13:28:32 -07:00
Dylan Baker 2048d1333e interpreter: use typed_kwargs for build_target.d_module_versions 2023-10-16 13:28:32 -07:00
Dylan Baker 9b1efa37fd interpreter: use typed_kwargs for build_target.d_import_dirs 2023-10-16 13:28:32 -07:00
Dylan Baker 19beb070e8 interpreter: use typed_kwargs for build_target.d_debug 2023-10-16 13:28:32 -07:00
Xavier Claessens dc329f0f04 interpreter: Add support for cargo subproject 2023-10-09 21:13:58 -04:00
Dylan Baker 013536fcb4 interpreter: add <lang>_(static|shared)_args
Which allow passing arguments specifically to the static or shared
libraries.

For design, this is all handled in the interpreter, by the build layer
the arguments are combined into the existing fields. This limits changes
required in the mid and backend layers
2023-10-09 17:33:48 -04:00
Dylan Baker e24f430512 interpreter: extend annotations around build_both_libraries
This allows for even more accurate type information
2023-10-09 17:33:48 -04:00
Dylan Baker 835b23efb4 interpreter: deprecated language args that don't apply to targets
`java_args` is only valid for `jar()` (and `build_target()`, but that's
deprecated), while all other language args are invalid for `jar()`. This
deprecates all of those arguments, that shouldn't be allowed, and
provides useful error messages. As an advantage, this avoids generating
useless `java_static_args` and `java_shared_args`.

In order to get useful error messages for both build_target and
executable + *library, we need to separate LIBRARY and BUILD_TARGET a
bit.
2023-10-09 17:33:48 -04:00
Dylan Baker 523a27c6f0 build: Use typed_kwargs for language args
This also moves the repacking into the interpreter, making the build
implementation simpler and removing a layering violation. This also
makes use a defaultdict to remove the need to call `.get()`
2023-10-09 17:33:48 -04:00
Dylan Baker cbca191948 interpreter: Handle BuildTarget.vala_args as Files in the interpreter
Way back in Meson 0.25, support was added to `vala_args` for Files.
Strangely, this was never added to any other language, though it's been
discussed before. For type safety, it makes more sense to handle this in
the interpreter level, and pass only strings into the build IR.

This is accomplished by adding a `depend_files` field to the
`BuildTarget` class (which is not exposed to the user), and adding the
depend files into that field, while converting the arguments to relative
string paths. This ensures both the proper build dependencies happen, as
well as that the arguments are always strings.
2023-10-09 17:33:48 -04:00