summaryrefslogtreecommitdiff
path: root/mesonbuild/utils
AgeCommit message (Collapse)Author
2024-04-15compilers: fix crash when compiler check returns None outputEli Schwartz
Popen_safe_logged has a small inefficiency. It evaluates the stripped version of stdout/stderr before checking if it exists, for logging purposes. This would sometimes crash, if it was None instead of ''. Fixes #12979
2024-03-20mesonlib: Fix bug in relpath return values found by mypyNirbheek Chauhan
2024-03-15move UserArrayOption.listify_value to mesonlibCharles Brunet
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-02-23env.unset methodCharles Brunet
2024-02-12correct type signature of Popen_safe to follow stdlib subprocessEli Schwartz
The standard library accepts None defaults for some kwargs and we should too.
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
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-02Only convert boolean values for cmake formatsJan200101
This caused a regression with mesondefine where `conf_data.set("FOO", true)` turned into `#define FOO 1` instead of `#define FOO`
2023-10-20fix the repr for OrderedSet to actually execute correctlyEli Schwartz
Old: ``` OrderedSet("'foo'", "'bar'", "'baz'") ``` New: ``` OrderedSet(['foo', 'bar', 'baz']) ``` The old one looked nasty *and* was totally non-functional.
2023-09-18pkgconfig: Cache the implementation instanceXavier Claessens
2023-09-09Add macro_name option to configure_fileNicholas Vinson
Allow macro_name to be speficied as a parameter to configure_file(). This allows C macro-style include guards to be added to configure_file()'s output when a template file is not given. This change simplifies the creation of configure files that define macros with dynamic names and want the C-style include guards.
2023-09-07Rename OptionOverrideProxy to OptionsView and move to coredataXavier Claessens
Coredata is where all option handling is done so it makes sense there. It is a view on a list of options for a given subproject and with optional overrides. This change prepare for using that view in a more generic way in the future.
2023-08-31add json output format to configure fileCharles Brunet
2023-08-24Suggest using --reconfigure only when not already using itXavier Claessens
2023-08-18consistently use Literal annotation from typing_extensionsEli Schwartz
This is our standard annotation policy, and makes mypy safe under python 3.7
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz
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-10Popen_safe_logged: Also log exceptionsXavier Claessens
Popen can raise OSError when program is not found, or PermissionError if not executable, etc.
2023-08-08correct cmakedefine behaviorJan200101
- allow defines with leading whitespace - always do replacement for cmakedefine - output boolean value for cmakedefine01 - correct unittests for cmakedefine - add cmakedefine specific unittests
2023-08-08tests: fix test_vsenv_option with Python 3.11+ on WindowsChristoph Reiter
meson tests enable PYTHONWARNDEFAULTENCODING by default and make EncodingWarning fatal too. Starting with Python 3.11 CPython not only warns if no encoding is passed to open() but also to things like subprocess.check_output(). This made the call in vsenv.py fail and in turn made test_vsenv_option fail. check_output() here calls a .bat file which in turn calls vcvars. I don't know what the encoding is supposed to be used there, so just be explicit with the locale encoding to silence the warning.
2023-08-03MachineChoice: Implement __str__ for easier debugXavier Claessens
2023-08-03ExecutableSerialisation: capture and feed are optional stringsXavier Claessens
capture is the optional filename stdout is redirected to. feed is the optional filename stdin reads from.
2023-07-19fix implicit_reexport issues and enforce them going forwardEli Schwartz
This detects cases where module A imports a function from B, and C imports that same function from A instead of B. It's not part of the API contract of A, and causes innocent refactoring to break things.
2023-07-17Merge pull request #11976 from tristan957/cleanupsJussi Pakkanen
Some various type related cleanups
2023-07-13macos: map arm64e to aarch64, map "whole" architecture stringsAndres Freund
Some macos libraries use arm64e instead of arm64 as architecture. Due to the string replace approach taken so far, we'd end up with aarch64e as architecture, which the rest of meson doesn't know. Move architecture mapping to map whole architecture names and add arm64e -> aarch64 mapping. This change doesn't touch the case for armv7[s], where we add arm, rather than replace armv7[s], but it's certainly not in line with the other mappings. Fixes: #9493 Co-authored-by: Tristan Partin <tristan@partin.io>
2023-07-12Remove do_conf_str(encoding:)Tristan Partin
It wasn't being used.
2023-07-12Use underscore for variables that we don't referenceTristan Partin
This pleases pyright/pylance and is a pattern that we use in other portions of the code.
2023-07-12Use more specific typesTristan Partin
Added type arguments where needed.
2023-07-12Match the method signatures of parent classesTristan Partin
Names and types of some methods did not match their parent methods.
2023-07-12Annotate naked fundamental Python typesTristan Partin
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin
2023-07-02genvslite: fix the core option being listed as one of the per-project optionsEli Schwartz
Post-facto application of issues that were caught during post-merge review, after the genvslite PR was merged without a full review.
2023-06-14WIP: refactor loggable popen calls for consistencyEli Schwartz
2023-06-01vcs_tag: Add --always to git describeXavier Claessens
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-05-25ProgressBar: Fix some rendering issuesXavier Claessens
- 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-02extend install scripts to allow specific directory variable exportsEli Schwartz
This is useful for internal scripts that want to know about something other than MESON_INSTALL_PREFIX and MESON_INSTALL_DESTDIR_PREFIX, which is very specific to the prefix.
2023-04-26Add env kwarg to gnome.generate_gir().Volker Weißmann
Fixes #384
2023-04-17select the correct python_command for pyinstaller builds, even on not-WindowsEli Schwartz
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-11fix various spelling issuesJosh Soref
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-29Make --vsenv a readonly builtin optionXavier Claessens
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 Schwartz
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 Baker
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-19handle more corner cases where locking the build directory failsEisuke Kawashima
This can raise any OSError, but we only caught two of them that indicate a particular failure case. Also catch the generic error form with a more generic message. This produces better error messages in cases where e.g. exclusive lock is not supported.
2023-02-14allow install script to run in dry-run modeCharles Brunet
2023-02-01simplify instantiation of builtin type using builtins instead of functionsEli Schwartz
2023-02-01micro-optimize: define typing-only objects in TYPE_CHECKINGEli Schwartz
Union types that exist solely for use as annotations don't need to be created in normal runs.
2023-02-01treewide: add future annotations importEli Schwartz
2023-01-20haiku: set default prefix and library pathsX512
2023-01-20remove dead codeEli Schwartz
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-18devenv: Allow dumping into file and select a formatXavier Claessens
It is often more useful to generate shell script than dumping to stdout. It is also important to be able to select the shell format. Formats currently implemented: - sh: Basic VAR=prepend_value:$VAR - export: Same as 'sh', but also export VAR - vscode: Same as 'sh', but without substitutions because they don't seems to work. To be used in launch.json's envFile.
2023-01-16properly type utils/core.py and add it to mypyEli Schwartz
EnvironmentVariables was always broken, it used MutableMapping because everyone <3 abstract interfaces, especially when they are broken and don't actually do what you want. This needs a dict interface, exposing `.copy()`. We either use a dict or os._Environ, and the latter also supports that. Also fix a broken import, and the fallout from forgetting to update the signature of self.envvars in commit b926374205bd761085031755c87152d08bc10e9d.
2023-01-03mesonlib: remove filename parameter to mlog.warningDylan Baker
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