aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/utils/universal.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-29Make --vsenv a readonly builtin optionXavier Claessens1-0/+1
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-09configure_file: emit FeatureNew when a cmake-formatted file has too many tokensEli Schwartz1-7/+12
In commit 97a72a1c53e68cf53541285075b4000f7c85ccc6 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-09utils: fix annotation of pickle_loadDylan Baker1-5/+26
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-02-01simplify instantiation of builtin type using builtins instead of functionsEli Schwartz1-4/+32
2023-01-20haiku: set default prefix and library pathsX5121-1/+56
2023-01-20remove dead codeEli Schwartz1-47/+0
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: - a1a4f66e6d915c1f6aae2ead02cf5631b10c76f1 - a3856be1d50eaefe32fee5d3347d55d934d15b50 - 08224dafcba1b694fb624553e7d84deb565aae22
2023-01-03mesonlib: remove filename parameter to mlog.warningDylan Baker1-1/+1
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
2022-12-27add builtin option to install licensesEli Schwartz1-0/+1
Unless `meson.install_dependency_manifest()` is explicitly used, this will cause a default implied one to be installed.
2022-12-15delay importing ctypes unless it is actually usedEli Schwartz1-1/+1
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-11typing: fix some broken Sequence annotationsEli Schwartz1-1/+1
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-07utils: Fix pylint warning using-constant-testL. E. Segovia1-1/+1
2022-11-30pylint: enable the set_membership pluginDylan Baker1-1/+1
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-30pylint: enable use-implicit-booleaness-not-comparisonDylan Baker1-1/+1
2022-11-29pylint: enable the bad_builtin checkerDylan Baker1-2/+2
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-28utils: Popen_safe: Handle ENOEXEC to fail with an error messageMarvin Scholz1-6/+14
This is much cleaner than to show a stack trace, where it is hard to figure out what is going wrong.
2022-11-17build: use the unified pickle loader to handle more edge casesEli Schwartz1-3/+8
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-03squelch an EncodingWarning we don't care aboutEli Schwartz1-1/+1
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-10-25Fix native compilation on ARM64 WindowsGustavoLCR1-0/+37
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-09-28Move classes used by scripts to their own moduleXavier Claessens1-0/+2279
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.