Commit Graph

12967 Commits

Author SHA1 Message Date
Eli Schwartz 28103614ef
refactor errorhandler for deduplication of logic
Mostly just move a comment around back to where it's more relevant, and
handle MESON_FORCE_TRACEBACK once instead of twice.
2022-09-22 15:24:56 -04:00
Eli Schwartz d364985365
fix regression in handling errors during reconfigure
In commit 9ed5cfda15 we refactored
startup to be a bit faster and import less. But this had the side effect
of moving out of our errorhandler. Refactor this so it can be easily
used elsewhere.
2022-09-22 15:23:39 -04:00
Christoph Reiter 3fd2459a74 CI: Add a temporary workaround for broken MSYS2 Python path separator behaviour
"MSYSTEM= python ..." no longer works because of some changes in the MSYS2 runtime

Until this is fixed in either MinGW Python or the MSYS2 runtime this should revert
things to the previous behaviour to get the CI green again.
2022-09-22 13:32:12 -04:00
Xavier Claessens f4f8a39060 Add release notes snippet for new mconf behaviour 2022-09-22 11:29:03 -04:00
Xavier Claessens d202697182 mconf: Add --no-pager option 2022-09-22 11:29:03 -04:00
Xavier Claessens b3dc99e6da mconf: Print options with colors 2022-09-22 11:29:03 -04:00
Xavier Claessens 5a98c915c5 mconf: Substract the 3 space separators between columns 2022-09-22 11:29:03 -04:00
Xavier Claessens 5d6368e562 mconf: Do not wrap choices manually
We already use textwrap.wrap() for that and it will correctly split on
spaces.
2022-09-22 11:29:03 -04:00
Xavier Claessens c8b57f1b57 mconf: There is always 4 columns 2022-09-22 11:29:03 -04:00
Xavier Claessens 59d561d4c1 mlog: Add support for pager
It is useful to redirect some outputs, such as "meson configure" to a
pager (e.h. less). This is similar to most git commands.
2022-09-22 11:29:03 -04:00
Xavier Claessens 3111ce6aae mconf: Use mlog.log() instead of print()
This will allow using colors and redirect print into a pager.
2022-09-22 11:29:03 -04:00
Xavier Claessens 31a6633e62 mdevenv: powershell <7.0 is EOL, prefer using pwsh.exe
If neither pwsh.exe nor powershell.exe works, fallback to cmd.exe. This
script could be failing because of virus scanner.
2022-09-21 18:32:51 -04:00
Xavier Claessens bb4c8c07f8 Fix cmd_or_ps.ps1 script with pwsh7
gwmi command does not exist any more and is replaced by Get-CimInstance.
See https://github.com/PowerShell/PowerShell/issues/4766.

While at it, use a do..while loop to avoid duplicated lines.

Fixes: #10820
2022-09-21 18:32:51 -04:00
Vili Väinölä 496dce0666 Fix including headers from another drive on VS backend
Include paths to different drives as absolute paths

fixes #8329
2022-09-20 18:32:36 -04:00
Eli Schwartz eb69fed2f6
python module: allow specifying the pure kwarg in the installation object
Fixes #10523
2022-09-19 21:13:37 -04:00
Dylan Baker b8e53ed5ea pylint: enable use-dict-literal 2022-09-19 20:57:52 -04:00
Dylan Baker 798b6c5624 pylint: enable use-list-literal 2022-09-19 20:57:52 -04:00
Dylan Baker 4da14918cd pylint: enable consider-using-in 2022-09-19 20:57:52 -04:00
Dylan Baker 6f7ea0cc28 pylint: enable use-sequence-for-iteration
This found a couple of places where we *don't* want to use set(), and
want to use list() instead.
2022-09-19 20:57:52 -04:00
Dylan Baker 188c552dcf pylint: enable use-maxsplit-arg
This finds a bunch of places where we can do more efficient string
splitting.
2022-09-19 20:57:52 -04:00
Dylan Baker b11cf2f371 pylint: enable consider-using-dict-items
Which found a couple of places where we could write better code.
2022-09-19 20:57:52 -04:00
Dylan Baker 6d12d7623f pylint: move from allow-list to deny-list
This makes it much easier to see what we're ignoring, as well as
allowing pylint to enforce any lints that currently pass but aren't in
the allow list automatically.
2022-09-19 20:57:52 -04:00
Eli Schwartz edc3e26369
fix odd mypy issue in unreachable code
This used to be fine, until imports were removed from this file. Now a
function annotated as T.NoReturn doesn't actually tell mypy that it
cannot return, though, so we manually do it.
2022-09-19 15:19:01 -04:00
Eli Schwartz 8277a1aba8
simplify type annotation 2022-09-19 15:19:00 -04:00
Eli Schwartz ab20eb5bbc
compilers: avoid importing compilers upfront for detect
We no longer need these upfront at all, since we now import the ones we
need for the language we are detecting, at the time of actual detection.

This avoids importing 28 files, consisting of just under 9,000 lines of
code, at interpreter startup. Now, it is only imported depending on
which languages are invoked by add_languages, which may not even be
anything. And even if we do end up importing a fair chunk of it for
C/C++ projects, spreading the import cost around the interpreter runtime
helps responsiveness.
2022-09-19 15:19:00 -04:00
Eli Schwartz cc5ef6478f
compilers: perform targeted imports for detect
Only import the ones we need for the language we are detecting, once we
actually detect that language.

This will allow finally dropping the main imports of these files in a
followup commit.
2022-09-19 15:19:00 -04:00
Eli Schwartz f6f876481f
compilers: use more direct checks for what kind of compiler we have
Instead of comparing against specific compiler classes, check the
logical compiler id or language etc.

In a couple cases, we seem to be missing a couple things by being a bit
too strict about the exact class type.
2022-09-19 15:19:00 -04:00
Eli Schwartz 775b67c5c1
compilers/detect: rename potentially conflicting name
Preparation for future commit.
2022-09-19 15:19:00 -04:00
Eli Schwartz 2b90152fe5
compilers: use consistent function signature for objc
e.g. for detect_c_or_cpp we just take the language itself as an
argument.
2022-09-19 15:19:00 -04:00
Eli Schwartz 4487a256e0
compilers: remove dead code
It doesn't matter whether the language is c or cpp, xc16 only has a C
compiler so that's what this has to be.
2022-09-19 15:19:00 -04:00
Eli Schwartz 5c4cd9162e
compilers: single-source compiler class as cls, consistently
It's the style for most, but not all, of this file.
2022-09-19 15:19:00 -04:00
Eli Schwartz 9ed5cfda15
avoid importing the entire codebase at first startup
We want to optimize out some internal codepaths used at build time by
avoiding work such as argparse. This doesn't work particularly well when
the argparse arguments are imported before then. Between them, they
indirectly import pretty much all code anywhere, and msetup alone
imports most of it.

Also make sure the regenerate internal script goes directly to msetup.
2022-09-19 15:19:00 -04:00
Eli Schwartz d3dac3cfb2
compilers: don't export every compiler as a top-level property
This is wasteful and generally unneeded, since code can just use the
compiler they detected instead of manually poking at the internals of
this subpackage.

It also avoids importing an absolute ton of code the instant one runs
`from . import compilers`
2022-09-19 15:19:00 -04:00
Eli Schwartz 5bfab845d0
compilers: directly import from subpackages
It turns out we don't generally need to proxy every compiler ever
through the top-level package. The number of times we directly poke at
one is negligible and direct imports are pretty clean.
2022-09-19 15:19:00 -04:00
Eli Schwartz 0a9048e554
compilers: don't use instance checks to determine properties
In various situations we want to figure out what type of compiler we
have, because we want to know stuff like "is it the pgi one", or "does
it use msvc style". The compiler object has this property already, via
an API specifically designed to communicate this info, but instead we
performed isinstance checks on a compiler class.

This is confusing and indirect, and has the side effect of requiring
more imports everywhere. We should do away with it.
2022-09-19 15:18:59 -04:00
Eli Schwartz 24ac3cdb9c
declare_dependency: fix regression in printing the correct error
In commit 47426f3663 we migrated to
typed_kwargs, but the validator accepted a list and checked to see if it
was a single Dependency object.

Fixes #10813
2022-09-19 01:48:44 -04:00
Daniel Carson 004575874f Warn if wrap file changes
Save off the hash of the wrap file when first configuring a subproject.
When reconfiguring a subproject, check the hash of the wrap file
against the stored hash. If they don't match then warn the user.
2022-09-18 22:48:50 -04:00
Daniel Carson 97f248db24 Move up dangling comment
The comment and some settings that appear to be related to the comment
were introduced in f21685a833 and appears
to be documenting some of the fields added in that commit. This commit
moves the comment back to the field it appears to be documenting.
2022-09-18 22:48:50 -04:00
Xavier Claessens 635cb1b873 gnome: Add some missing install_tag 2022-09-18 21:59:30 -04:00
Liam Beguin d3fd050f85 mailmap: add alias for myself
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin 020e16a2b5 completions: bash: add simple init competion
Populate the _meson-init() completion function.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin 3f86f19f95 completions: bash: define sub-commands as an array
Define subcommands as an array so that they can be reused for the
top-level sub-command completion.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin 24e97e1945 completions: bash: update meson sub-command list
Add all meson sub-commands to the autocompletion script.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin f08c788f61 completions: bash: add missing functions
Add empty functions for all commands defined in the autocompletion script.
When these functions are not defined, bash raises the following error:

       $ meson init <TAB>-bash: _meson-init: command not found

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin ebe14848e0 completions: bash: order function definitions like in help
Move _meson-introspect() to follow the command list defined at the top
of the script which follows the help message order.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Xavier Claessens 7e4188a53f devenv: Resolve executable in devenv's PATH
Fixes: #10815
2022-09-15 10:04:59 -04:00
Eli Schwartz d924586bee
docs: note the automatic creation of gitignore in build directories 2022-09-14 18:53:53 -04:00
Yang Bo 83d18d137d Use os.path.realpath for default include paths testing in -isystem.
This ensures correct removal of default include paths in -isystem
options when symbolic links are involved.

A test for this is also added.
2022-09-13 02:24:38 -04:00
Eli Schwartz 719dd0d2a0
dependencies: log the real reason for a dependency lookup failing
In the debug logs, always log if a dependency lookup raises a
DependencyException. In the `required: false` case, this information
would otherwise disappear forever, and we would just not even log that
we tried it -- it doesn't appear in "(tried x, y and z)".

In the `required: true` case, we would re-raise the first exception if
it failed to be detected. Update the raise message with the same
information we print to the debug logs, indicating which dependency and
which method was used in the failing attempt.
2022-09-12 19:16:59 -04:00
Eli Schwartz b821a03511
dependencies: use better internal representation of factory methods
functools.partial preserves information about how the method was
created, lambdas do not. Also, we just want to freeze the first argument
and forward the rest anyway.

This also lets us get rid of a mypy error that was being ignored.
2022-09-12 19:16:59 -04:00