Commit Graph

8372 Commits

Author SHA1 Message Date
Xavier Claessens 5e2a47e768 Interpreter: Using executable in run_command/configure_file is not a
bug

Fixes: #11382
2023-06-15 14:45:24 -04:00
Eli Schwartz f1a58a3ee6
remove unnecessary typing comments
Although they could be moved to annotations, the truth is that they are
unneeded because they get inherited from the parent class.
2023-06-14 23:12:09 -04:00
Eli Schwartz 0ea28fa637
convert some FeatureDeprecated for totally broken stuff, to FeatureBroken
We now warn everyone equally that totally ignored sources are bad and
should not be used.
2023-06-14 23:12:09 -04:00
Eli Schwartz f93f443a53
detect and warn on non-commutative int/bool operations
an int only accepts operations on other ints, just like other primitive
types only accept operations on values of the same type.

But due to using isinstance in baseobjects "operator_call", an int
primitive allowed operations on a bool, even though reversing the
operator and having a bool perform operations on an int, would fail with
a type error.

Really, we should fail with a type error in both directions. But for
stability reasons, make this a loud warning and break --fatal-meson-warnings
builds.
2023-06-14 23:12:09 -04:00
Eli Schwartz d558291abe
add new FeatureBroken check class for annotating features that are really broken
This is useful for totally terrible stuff that we really dislike, but
for some reason we are afraid to just use `mlog.deprecation()` and
unconditionally tell people so.

Apparently this is because it is totally absolutely vital that, when
telling people something is so broken they should never ever ever use it
no matter what, ever... we can't actually tell them that unless they
bump the minimum version of Meson, because that's our standard way of
introducing a **version number** to tell them when we first started
warning about this.

Sigh. We really want to warn people if they are doing totally broken
stuff no matter what version of Meson they support, because it's not
like fixing the thing that never worked is going to suddenly break old
versions of meson.

So. Here's some new functionality that always warns you, but also tells
you when we started warning.
2023-06-14 22:53:50 -04:00
Eli Schwartz d87d912e5d
compilers: fix detection of ifx compiler
The version output scraping for identifying strings checked for "IFORT"
in parentheses after the executable name, which is probably a mistake by
Intel. Current versions of ifx have "IFX" in parentheses there.

Detect both.

Fixes #11873
2023-06-14 01:04:55 -04:00
Eli Schwartz a6bf2c1e2c
compilers: add logging for non c_or_cpp language detection 2023-06-14 01:04:55 -04:00
Eli Schwartz aa13c46822
WIP: refactor loggable popen calls for consistency 2023-06-14 01:04:55 -04:00
Xavier Claessens c503c757f1 coredata: Fix wrong stable_version value 2023-06-13 21:14:34 -04:00
Xavier Claessens d8cb62bf2b Allow targetting Meson 1.2.0 when version is 1.1.99
When a project targets a dev version of Meson (e.g. 1.1.99) for
experimenting, this allows to use:

  project(..., meson_version: '>=1.2.0')

It avoids getting warnings when using FeatureNew for features introduced
in 1.2.0.
2023-06-13 10:32:48 -04:00
Xavier Claessens dbb857dd71
env2mfile: Take pkg-config properties from env 2023-06-12 15:08:30 -04:00
Xavier Claessens 62a5673b98
env2mfile: Take binaries from env for cross file too 2023-06-12 15:08:28 -04:00
Xavier Claessens 1ab7d3b28e
env2mfile: Not all compilers have env for flags 2023-06-12 15:08:26 -04:00
Eli Schwartz 82d0d1755d
ninja backend: fix cleandead deleting files that meson implicitly creates
Specifically, when those files can be created by a build rule with one
version of meson.build, and created as e.g. a shared_library alias
symlink in another version of meson.build, the cleandead command will
delete important files just because they don't happen to be created by
ninja itself.

Work around this by making a dummy rule that exists solely to insert the
files into the build graph to trick ninja into not deleting them.

Closes #11861
2023-06-11 18:56:54 -04:00
Karol Herbst 8284be8139 dependencies/llvm: strip default include dirs
Fixes an issue with rust.bindgen if a cmake LLVM dependency with the
system include_type is getting used as a dependency.
2023-06-08 09:49:29 -07:00
Dylan Baker f02e26877d cargo/interpreter: Implement an interpreter for Cargo TOML
This converts a Cargo TOML file into Meson AST

Co-Authored-By: Thibault Saunier <tsaunier@igalia.com>
2023-06-07 19:20:30 -07:00
Dylan Baker 4017dab484 cargo/cfg: Add a parser for the rust/cargo cfg() expressions
This uses a recursive descent parser + lexer to create an IR from cfg()
expressions, which it then converts into meson IR.
2023-06-07 19:20:30 -07:00
Dylan Baker 5e59e5a9e4 cargo/version: add a function to convert cargo versioning to meson 2023-06-07 19:20:30 -07:00
Dylan Baker b01ae087f5 cargo: Add a builder module to the cargo package
This is a helper, currently only used by cargo. It could be moved later
if there are other users.
2023-06-07 19:20:30 -07:00
Dylan Baker 71325547aa cargo/manifest: Add a file with type definitions of the cargo manifest format
Co-Authored-By: Thibault Saunier <tsaunier@igalia.com>
2023-06-07 19:20:30 -07:00
Eli Schwartz 2be09bbc92
dependencies: add more logging to configtool
When retrieving variables from the tool, log some debug output the same
way that pkg-config does.
2023-06-07 16:40:51 -04:00
Matthew Waters c6f34b8c40 dependencies/qt: add support for Qt frameworks referencing includes in include directory
e.g. QtQml with Qt 6.4.0 referencing QtQmlIntegration is one such example
2023-06-08 00:08:26 +05:30
Xavier Claessens 6c480085d5 rust: PIC is always enabled
rustc enables PIC by default and Meson currently has no way to force
disabling PIC, it can only force enable or use compiler's default.
2023-06-07 13:18:58 -04:00
Tristan Partin 58aa301acc Override find_program('meson')
This override transparently upgrades anyone using it to this better
functionality.

Fixes #8511
2023-06-06 10:07:36 -04:00
Xavier Claessens 1781a481ee pkgconfig: Add include directories from internal deps in -uninstalled.pc
Fixes: #8651
2023-06-01 18:57:40 -04:00
Xavier Claessens 26da7ec9f5 python: Use detect.find_external_dependency() for log consistency
py.find_installation().dependency() was not logging whether it is found
or not. Use find_external_dependency() for consistency.
2023-06-01 18:47:03 -04:00
Xavier Claessens 1a9f20d44a vcs_tag: Add --always to git describe
This fallbacks to short commit id in case the git repository does
not contain any annotated tag, for example before the first release of a
project.
2023-06-01 15:44:46 -04:00
Xavier Claessens 7ac6afe265 mparser: Further cleanup node definitions
- Include BaseNode position in hash methods, integer is the most
  straightforward way of differentiating nodes.
- Exclude non hashable fields from hash method.
- Avoid using default values in BaseNode that way subclasses can have
  fields wihtout default value without repeating init=False.
- Nodes that does not add fields does not need `@dataclass`.
- Make all node types hashable because they can be used for feature_key
  in FeatureCheckBase.use().
- Remove unused type annotations
2023-06-01 15:32:18 -04:00
Dylan Baker 1ed1c8e2b0 mparser: add equality operators to nodes
This makes use of dataclasses, but without a dataclass generated
initializer. This means that we get nice `__repr__` and `__eq__` methods
without having to type them by hand.

Pylance understands `dataclass(init=False)`, but mypy doesn't.
https://github.com/microsoft/pyright/issues/1753
https://github.com/python/mypy/issues/10309
2023-06-01 15:32:18 -04:00
Dylan Baker cb0b6352b5
mlog: put the module docstring at the top of the file
Where it belongs. Otherwise it isn't rendered correctly
2023-05-31 17:20:46 -04:00
Dylan Baker 11fab771b1
mlog: use StringProtocol where we said we should
Replace a long comment explaining that we need StringProtocol, with
StringProtocol
2023-05-31 17:20:46 -04:00
Dylan Baker ada2a976f0
mlog: use a hidden class for state
This is a pretty common pattern in python (the standard library uses it
a ton): A class is created, with a single private instance in the
module, and then it's methods are exposed as public API. This removes
the need for the global statement, and is generally a little easier to
reason about thanks to encapsulation.
2023-05-31 17:20:44 -04:00
Dylan Baker 1e79553c36
mlog: remove out-of-date comment
This comment is out of date, we have StringProtocol which is exactly
what we wanted, and it's part of TV_Loggable already
2023-05-31 17:19:48 -04:00
Dylan Baker 73c054ced6
mlog: remove direct calls to log_once
This was never meant to be public API, log(once=True) is for that.
2023-05-31 17:19:45 -04:00
Xavier Claessens d17e3ce6ba preprocess: Allow preprocessing any file extensions 2023-05-31 11:59:39 -04:00
Eli Schwartz 95b03f7930 avoid clearing the dependency cache unnecessarily based on wrap-mode
We actually do not and should not care about wrap-mode at all for this.
We want to cache dependency lookups whenever humanly possible, but only
use them in cases where we would anyways be using them -- which in
particular means if we said to force a subproject fallback for this dep,
we want to bypass the cache.

Currently, we handle this by always looking up the cache for all
dependencies, but clearing the cache at startup if a reconfigure means
we are changing our resolution strategy. This is bad -- we might have
many dependencies that are worth caching, and only one dependency that
should stop being cached and use a subproject instead.

The simple solution is to handle the forcefallback case when doing a
cache lookup, and not do a cache lookup at all. Now we don't have to
nuke the entire cache. In fact, if a future reconfigure changes the
forcefallback state back to not being forced, we can reuse the original
cached dependency, which is still there.

Closes #11828
2023-05-29 15:04:34 -04:00
Eli Schwartz 29ad6dd90c avoid endless reconfigure loops when a build directory is copied around
ninja's configured command for regenerating a build directory on any
action that *requires* reconfiguring, specifies the source and build
directories as they were known during initial project generation. This
means that if the build directory is no longer the *same* build
directory, we will regenerate... the original location, rather than the
location we want.

After that, ninja notices that build.ninja is still out of date, so it
goes and reconfigures again. And again. And again.

This is probably broken intentions, but endless reconfigure loops are a
kind of evil beyond all evils. There are no valid options here
whatsoever other than:
- doing what the user actually meant
- spawning a clear error message describing why meson refuses to work,
  then exiting with a fatal error

But it turns out that it's actually pretty easy to do what the user
actually meant, and reconfigure the current build directory instead of
the original one. This permanently breaks the link between the two.

Fixes #6131
2023-05-29 14:07:43 -04:00
Charles Brunet e7b9dfac98 mtest: wildcard selection
Allow the use of wildcards (e.g. *) to match test names in `meson test`.

Raise an error is given test name does not match any test.

Optimize the search by looping through the list of tests only once.
2023-05-25 13:44:13 -04:00
Xavier Claessens 11521c6db7 ProgressBar: Fix some rendering issues
- Do not hardcode terminal width of 100 chars, that breaks rendering on
  smaller terminal. It already uses current console width by default.
- Disable progress bar when downloading from msubprojects because it
  fetches multiple wraps in parallel.
- Scale unit when downloading e.g. MB/s.
- Do not display rate when it's not a download.
- Do not display time elapsed to simplify the rendering.
2023-05-25 11:06:09 -04:00
Eli Schwartz 2c806099c7
repair install_mode support for uid/gid effectively everywhere
We silently dropped all integer values to install_mode since the
original implementation of doing this in KwargInfo, in commit
596c8d4af5.

This happened because install_mode is supposed to convert False
(exactly) to None, and otherwise pass all arguments in place. But a
generator is homogeneous and attempting to do this correctly produced a
mypy error that FileMode arguments were allowed to be ints -- well of
course they are -- so that resulted in the convertor... treating ints
like False instead, to make mypy happy.

Fixes #11538
2023-05-24 19:05:06 -04:00
Eli Schwartz 1ff996ea67
remove inaccurate comment
This convertor was initially implemented doing all the things the TODO
says it doesn't yet do. The freestanding interpreter function is what
doesn't do this.
2023-05-24 19:05:06 -04:00
Eli Schwartz d3804d0579
Remove pointless install_umask validation check for None
This option can never have a value of None. There are only two sources
of values at all:

- the class instance initializer when defining BUILTIN_CORE_OPTIONS
- user-provided command-line or machine file values etc. which can only
  be meson types

We know we don't construct the Option instance with None, and users
cannot pass a None anywhere since that's not a meson type. The only
reason this was ever checked for was as an artifact during the initial
implementation of the option in commit 8651d55c6a.

At the time, a review comment was made that `-Dinstall_umask=none` was a
bad UX and "preserve" should be used instead. Before that, this option
type accepted `None` (in the BUILTIN_CORE_OPTIONS initializer) and
`'none'` (provided by users) which is odd and should have consistently
been the latter. Then inside set_value, it checked for the magic
initializer value and converted it to the real value.

After review comments and a force-push, the patch ended up using `None`
in the initializer, and `'preserve'` everywhere else, and still handling
both in set_value and converting both to a proper string.

In the very next commit in the patch series, the initializer was
migrated to use an actual umask of 022, and now `None` was entirely
impossible to get anywhere at all. But the wart of checking for it was
never removed. Remove it at long last.
2023-05-24 19:05:06 -04:00
Eli Schwartz e37394fe1d
deprecate the buildtarget.get_id() method
This has never been undocumented and there's no obvious value to having
it or using it. We're not even sure anyone ever has used it.

Closes #6061
2023-05-23 19:23:48 -04:00
Nirbheek Chauhan 22df45a319 qt: Allow specifying separate tools for qt4/5/6
Currently you can only use one of qt4, qt5, qt6 in a single project
when using a machine file because the config-tool lookup for qt only
looks at `qmake` in the machine files, instead of looking up the
binary names directly.

Allow specifying `qmake` `qmake4` `qmake5` and `qmake6`.

This is necessary for gstreamer, which can build separate qt5 and qt6
plugins that are distributed as static libraries, so the user can pick
which one to use.
2023-05-23 18:24:08 -04:00
Eli Schwartz 1f71911ae4
i18n module: check for a good enough msgfmt before permitting merge_file
The concept of merge_file intrinsically requires some GNU-specific
functionality, so let's emit a useful error message during
configuration, when we don't have that.

The relevant GNU gettext versions date back to around 2015 so *probably*
anyone has that too, but we may as well verify that while we are here.
2023-05-22 21:20:18 -04:00
Eli Schwartz af49e8010b
i18n module: be broadly supportive of portable gettext tools
There are a number of implementations for msgfmt, supporting various
options. The simplest, and most common, use case is to compile .po files
into .mo files, and this should be able to work on gettext
implementations other than the GNU one.

The problem is that we were passing some pretty portable arguments in an
unportable manner. The `-o` option-argument and its associated argument
came after the input file operand, which violates the POSIX Utility
Syntax Guidelines, and happens to not be supported by Solaris gettext.
The GNU gettext doesn't care; GNU invented GNU argument permutation.

Switch the order around so that our use respects the POSIX style.
2023-05-22 21:20:18 -04:00
Charles Brunet 8d30577a2d intro: add more details to generated files(part 2)
- add `extra_paths` to intro-tests.json to know paths needed to run a
  test on Windows;
- add `depends` to alias targets in intro-targets.json to know what
  targets does an alias point to;
- add `depends` to intro-dependencies.json to know libraries linked with
  an internal dependency;
- renamed `deps` to `dependencies` in `intro-dependencies.json` for more
  uniformity.
2023-05-22 22:12:29 +03:00
Volker Weißmann 12a2dc86ca Allow generator.process(generator.process(...))
Fixes #1141
2023-05-21 22:12:57 +03:00
Xavier Claessens c6db870fc7 rust: Add system libs used by rust std to staticlib external deps 2023-05-20 10:35:42 -04:00
Xavier Claessens 01bb756484 rust: Use Popen_safe() for sanity checks 2023-05-20 10:35:42 -04:00