Commit Graph

24 Commits

Author SHA1 Message Date
Eli Schwartz aa13c46822
WIP: refactor loggable popen calls for consistency 2023-06-14 01:04:55 -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 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 c39ee881a1 select the correct python_command for pyinstaller builds, even on not-Windows
Checking the executable basename sort of works, at least for Windows,
since Windows always happens to use exactly this approach. However, the
official pyinstaller documentation suggests a very different approach:

https://pyinstaller.org/en/stable/runtime-information.html

This approach is more robust since it works on any OS, and in particular
it allows me to test the PyInstaller bundle functionality on Linux, even
though we don't officially distribute it as such.
2023-04-17 11:36:55 +03:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -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
Eli Schwartz a410bbdf12 configure_file: emit FeatureNew when a cmake-formatted file has too many tokens
In commit 97a72a1c53 we started to allow
cmakedefine with 3 tokens, as cmake expects (unlike mesondefine). This
would silently start working even if the declared minimum version was
older than 0.54.1
2023-03-09 21:32:14 -08:00
Dylan Baker 7c2ac4f8fe utils: fix annotation of pickle_load
It's actually Generic, and we should use Generic annotations to get the
correct result. This means that we don't have to assert or cast the
return type, because mypy just knowns
2023-03-09 19:03:44 -05:00
Eli Schwartz c9ac73a4da
simplify instantiation of builtin type using builtins instead of functions 2023-02-01 17:01:30 -05:00
X512 3074731797 haiku: set default prefix and library paths 2023-01-20 14:57:33 -05:00
Eli Schwartz dd83d5e4a1 remove dead code
We shouldn't be hardcoding library dirs anyway. And we usually get this
from the compiler.

This function has been unused since its users were moved to use the
compiler method, in the following commits:
- a1a4f66e6d
- a3856be1d5
- 08224dafcb
2023-01-20 00:15:44 +02:00
Dylan Baker 2a64ffd1e6 mesonlib: remove filename parameter to mlog.warning
After tracing all the way down to the bottom of this (or really, adding
annotations so mypy can) it turns out that passing file would just be
ignored at the end of the mlog call stack, so it should be removed
2023-01-03 14:49:02 -05:00
Eli Schwartz 0544ffabf1
add builtin option to install licenses
Unless `meson.install_dependency_manifest()` is explicitly used, this
will cause a default implied one to be installed.
2022-12-27 20:29:46 -05:00
Eli Schwartz 2ef94a71f8
delay importing ctypes unless it is actually used
ctypes uses FFI, and surprisingly often people's Python installations
will be broken because ctypes is broken (e.g. the system libffi has been
updated and Python needs to be recompiled). That is not our fault, but
it does manifest as Meson failing to run. It turns out we aren't even
using it though. At least, pretty often.

We have two uses of ctypes, and both of them are for Windows. One of
them is already conditionally imported in the function that uses it, but
the other is imported at startup. Move this down into the invoking
function.

On non-Windows systems, it is now impossible for Meson to fail to run
when ctypes is broken, because we don't use it. Anecdotally, this issue
tends to come up on Linux systems primarily.

Fixes #11111
Closes #11112
2022-12-15 16:44:35 -05:00
Eli Schwartz e5a9272034
typing: fix some broken Sequence annotations
T.Sequence is a questionable concept. The idea is to hammer out generic,
maximally forgiving APIs that operate on protocols, which is a fancy way
of saying "I don't care if you use tuples or lists". This is rarely
needed, actually, and in exchange for this fancy behavior you get free
bugs.

Specifically, `somestr` is of type `T.Sequence[str]`, and also
`somestr[0]` is another string of type you guessed it. It's ~~turtles~~
strings all the way down.

It's worth noting that trying to code for "protocols" is a broken
concept if the contents have semantic meaning, e.g. it operates on
"the install tags of this object" rather than "an iterable that supports
efficient element access".

The other way to use T.Sequence is "I don't like that T.List is
invariant, but also I don't like that T.Tuple makes you specify exact
ordering". This sort of works. In fact it probably does work as long as
you don't allow str in your sequences, which of course everyone allows
anyway.

Use of Sequence has cute side effects, such as actually passing lists
around, knowing that you are going to get a list and knowing that you
need to pass it on as a list, and then having to re-allocate as
`list(mylist)` "because the type annotations says it could be a str or
tuple".

Except it cannot be a str, because if it is then the application is
fatally flawed and logic errors occur to disastrous end user effects,
and the type annotations:
- do not enforce their promises of annotating types
- fail to live up to "minimal runtime penalties" due to all the `list()`

Shun this broken concept, by hardening the type annotations. As it turns
out, we do not actually need any of this covariance or protocol-ism for
a list of strings! The whole attempt was a slow, buggy waste of time.
2022-12-11 18:28:39 -05:00
L. E. Segovia d490636328 utils: Fix pylint warning using-constant-test 2022-12-07 13:29:04 -05:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Dylan Baker 1502431fe9
pylint: enable use-implicit-booleaness-not-comparison 2022-11-30 07:01:22 -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
Marvin Scholz 7c48cb513a utils: Popen_safe: Handle ENOEXEC to fail with an error message
This is much cleaner than to show a stack trace, where it is hard to
figure out what is going wrong.
2022-11-28 12:09:30 -08:00
Eli Schwartz 0d3be23377 build: use the unified pickle loader to handle more edge cases
We have divergent implementations of loading a pickled *.dat file. The
Build class loader has a better error message. But the generic loader
handles TypeError and ModuleNotFoundError. Merge the implementations,
and use it for Build as well.

Fixes #11051
2022-11-17 12:56:04 -08:00
Eli Schwartz af41eb6e9b
squelch an EncodingWarning we don't care about
We would like to use the default value (the one python urged us not to
use), but without getting a warning for it. Luckily, we have the correct
value already, so we can pass it manually to avoid the complaint.
2022-11-03 15:44:41 -04:00
GustavoLCR 32bc64e632 Fix native compilation on ARM64 Windows
Move `detect_native_windows_arch()` to `mesonlib/universal.py` and
rename it to `windows_detect_native_arch()`
Use `IsWow64Process2()` to detect native architecture if available
Use native `vcvarsarm64.bat` to initialize vsenv if available
2022-10-25 14:59:06 +03:00
Xavier Claessens 2dfd952eb9 Move classes used by scripts to their own module
Those classes are used by wrapper scripts and we should not have to
import the rest of mesonlib, build.py, and all their dependencies for
that.

This renames mesonlib/ directory to utils/ and add a mesonlib.py module
that imports everything from utils/ to not have to change `import
mesonlib` everywhere. It allows to import utils.core without importing
the rest of mesonlib.
2022-09-28 19:36:13 -04:00