58 Commits

Author SHA1 Message Date
Paolo Bonzini
795e7431ff environment: move tool detection functions to a new module
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29 18:59:30 +02:00
Dylan Baker
4fa5292545 coredata: replace get_option with optstore.get_value_for
This is an old method, that is now just a wrapper around the OptionStore
method, that doesn't add any value. It's also an option related method
attached to the CoreData instead of the OptionStore, so useless and a
layering violation.
2025-03-10 14:14:25 -04:00
Jussi Pakkanen
0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Charles Brunet
d08ef2c08b move UserArrayOption.listify_value to mesonlib
This function is used at 3 different places and it does not justify it
as being a staticmethod instead of being a free function.
2024-03-15 09:23:46 -07: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
Luke Elliott
ce691f8c98 Add comments suggesting to keep shell completion scripts up-to-date near cmd line argument code 2023-11-01 00:06:19 +02:00
Dudemanguy
03a0d3ddfb mcompile: add suffix as an additional parameter
Since the previous commit allows for more scenarios with name
collisions, it makes sense to expand the compile command so that it can
also take into account suffixes. i.e. meson compile -C build foo.exe can
now work if the executable has an exe suffix along with being named foo.
2023-10-05 08:43:38 -07:00
Jussi Pakkanen
08d83a4a97 Merge pull request #10332 from xclaesse/std-opt
c_std, cpp_std: Change to a list of desired versions in preference order
2023-08-30 12:04:09 -07:00
Eli Schwartz
90ce084144 treewide: automatic rewriting of all comment-style type annotations
Performed using https://github.com/ilevkivskyi/com2ann

This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.

So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.

Repeat with:

```
com2ann mesonbuild/
```
2023-08-11 13:41:03 -04:00
Eli Schwartz
a01418db0a remove useless type annotations
These annotations all had a default initializer of the correct type, or
a parent class annotation.
2023-08-11 13:37:17 -04:00
Xavier Claessens
7600856e0a UserArrayOption: Make listify_value() a static method 2023-08-06 09:39:56 -04:00
Xavier Claessens
48c17b7ae6 UserArrayOption: Remove user_input argument
The only place it can be set to False is from optinterpreter. Better
check value there and deprecate string usage.
2023-08-06 09:39:55 -04:00
Xavier Claessens
1958ded04f mcompile: Fix target name suggestions 2023-05-05 16:47:04 -04:00
Xavier Claessens
b30cd5d2d5 Make --vsenv a readonly builtin option
We need to remember its value when reconfiguring, but the Build object
is not reused, only coredata is.

This also makes CLI more consistent by allowing `-Dvsenv=true` syntax.

Fixes: #11309
2023-03-29 09:33:41 -04:00
Charles Brunet
91b88b1a76 fix meson compile with alias target
this fixes a bug introduced by #11528
2023-03-17 02:05:23 -04:00
Xavier Claessens
72cd2a395a coredata: Do not pickle it twice
Exclude coredata from build.dat because it gets pickled separately
already.
2023-03-16 21:02:23 -04:00
Xavier Claessens
8f683eeb21 mcompile: Do not exclude targets from subprojects
When giving full path to a target there is no reason to skip targets
from subprojects, the path can start with `subprojects/`.
2023-02-24 20:03:28 -05:00
Eli Schwartz
680b5ff819 treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Dylan Baker
d5e899c768 pylint: enable the bad_builtin checker
This finds uses of deny-listed functions, which defaults to map and
filter. These functions should be replaced by comprehensions in
idiomatic python because:
    1. comprehensions are more heavily optimized and are often faster
    2. They avoid the need for lambdas in some cases, which make them
       faster
    3. you can do the equivalent in one statement rather than two, which
       is faster
    4. They're easier to read
    5. if you need a concrete instance (ie, a list) then you don't have
       to convert the iterator to a list afterwards
2022-11-29 23:26:05 -05:00
Xavier Claessens
0042095d12 mcompile: Remove useless sleep
There is no reason to wait 2s before starting the compilation command.

Fixes: #10698.
2022-09-12 13:50:11 -04:00
Alf Henrik Sauge
9ad5d0df4a Remove redundant backslash and fix white space issue 2022-08-26 17:12:40 -04:00
Eli Schwartz
28d07c31b8 mcompile: provide user visibility into what actually happens
This command is magical and I hate it. Mostly because it seems people
have no clue what it does, and what it doesn't do.

Provide informational messages to the user indicating how it works, e.g.
for debugging. Point out if we ran vsenv before shelling out to the
backend.
2022-08-12 17:07:41 +03:00
Xavier Claessens
17f5d0cffb mcompile: Print suggestions when target is ambigous
Fixes: #10221
2022-05-01 23:56:38 +03:00
Eli Schwartz
88f8a8ea15 mcompile: fix broken codepaths and restore orphaned code
In commit 928078982c a good error message
about the directory not being a valid build directory, was replaced by a
worse message.

In commit abaa980436 the error message was
replaced by a traceback when trying to load the coredata before checking
if it was a build directory.

Revert back to using the helper function with the good error message.
Reorganize code so that we check basic things first, and do less work
before detecting errors.

Fixes #9584
2022-01-26 14:49:38 -05:00
avitex
2046593825 delete PLATFORM env only if set
fixes #8721
2021-10-30 23:22:48 -04:00
Eli Schwartz
8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Xavier Claessens
abaa980436 mcompile: Load coredata first because it checks major version
Fixes: #9444
2021-10-25 19:14:01 -04:00
Xavier Claessens
928078982c Add --vsenv command line option and active VS only when needed 2021-10-10 23:15:18 +03:00
Christian Clauss
a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Mike Gilbert
41c96d50af mcompile: treat load-average as a float
`ninja -l` accepts a double. We should do the same.

Bug: https://bugs.gentoo.org/810655
2021-08-29 22:19:52 -04:00
Eli Schwartz
dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
Daniel Mensinger
3e396b3782 fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Eli Schwartz
6a0fabc647 mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz
76df995ba6 raw string literals are next to godliness
Invalid escape sequences are deprecated and will be removed from a
future version of python. Use r"" to define them so they remain
readable.
2021-03-04 17:09:00 -05:00
Eli Schwartz
c7ddde58fd mcompile: do not pass the builddir to ninja if it is the current directory
Because when you don't specify -C, this logging feels silly:

ninja: Entering directory `.
2021-02-23 19:37:04 -05:00
Eli Schwartz
691eb0250a mcompile: make sure arguments are passed in the correct order
meson compile itself doesn't permit GNU-style argument permutation, i.e.
TARGET to precede options, so why should we expect ninja to?

And indeed, ninja doesn't document support for this -- but it does
accept it anyway, which is confusing and results in people thinking it's
"supposed to" work.

However, if NINJA=samu then this is in fact enforced. samu does not
permit GNU-style argument permutation. As a result, the arguments passed
to mcompile are actively re-ordered before being passed to the
subprocess, and samu dies with a fatal error.

Fix ordering in mcompile.py and add a comment to warn future readers
that the order does, in fact, matter.
2021-02-23 19:37:03 -05:00
Antonin Décimo
39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Dylan Baker
e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Daan De Meyer
e828c670f5 Remove "Found runner: " logging message from meson compile
The ninja path is already logged as part of configure. Logging it
again every time when using meson compile is overly verbose and
doesn't add much value for the user.
2020-12-07 10:05:00 -08:00
Dylan Baker
f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Daniel Mensinger
1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Vili Väinölä
32cf7a03d2 Fix meson compile for 32-bit MSVC build
- Remove platform from env so that msbuild does not try to compile
e.g. configuration debug|x86
2020-10-02 09:09:43 +00:00
Nirbheek Chauhan
7fbdf38ce3 mcompile: Add some basic XCode support
I wrote this to convert run_tests.get_backend_commands() over to the
new meson wrappers, but that turned out to be harder than I expected,
so just splitting this out for now.
2020-09-13 20:44:30 +03:00
Daniel Mensinger
8f95efe40b typing: fixup of #7688
This bug not beeing caught in review is another reason for
adding strict typing support to meson.
2020-09-08 20:15:59 +02:00
Daniel Mensinger
23818fc5a3 typing: more fixes 2020-09-08 20:15:58 +02:00
Daniel Mensinger
c637b913c9 typing: fully annotate mcompile, minit, and msetup 2020-09-08 20:15:57 +02:00
Paolo Bonzini
492afe50a4 environment: use ExternalProgram to find ninja
This allows the NINJA environment variable to support all the Windows special
cases, especially allowing an absolute path without extension.

Based on a patch by Yonggang Luo.

Fixes: #7659
Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 15:38:12 +02:00
Nirbheek Chauhan
f4bac06bd9 mcompile: Also support -v for verbose
This matches `meson test`, and there's really no other meaning that
could be attributed to this, since you would call `meson` to get the
version, not the `compile` sub-command.
2020-08-31 22:59:57 +03:00
Igor Raits
efaa752009 mcompile: use -v instead of --verbose for ninja
The `--verbose` has been added to ninja in 1.9.0 and we pretend that we have compatibility with Ninja 1.7+.

References: bf7517505a
2020-08-30 23:36:45 +03:00
TheQwertiest
5696a5abba Added ability to specify target in meson compile 2020-06-29 19:54:38 +03:00