summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/depscan.py
AgeCommit message (Collapse)Author
2025-04-03backend/ninja: use a two step process for dependency scanningDylan Baker
This splits the scanner into two discrete steps, one that scans the source files, and one that that reads in the dependency information and produces a dyndep. The scanner uses the JSON format from https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html, which is the same format the MSVC and Clang use for C++ modules scanning. This will allow us to more easily move to using MSVC and clang-scan-deps when possible. As an added bonus, this correctly tracks dependencies across TU and Target boundaries, unlike the previous implementation, which assumed that if it couldn't find a provider that everything was good, but could run into issues. Because of that limitation Fortran code had to fully depend on all of it's dependencies, transitive or not. Now, when using the dep scanner, we can remove that restriction, allowing more parallelism.
2024-03-29scripts/depscan: remove unnecessary functionDylan Baker
This basically existed for an assert which we don't need, as mypy would catch that issue for us anyway. Removing the function entirely has some small performance advantages
2024-03-29scripts/depscan: pick language once, at configure timeDylan Baker
We already have to decide whether to scan a file at configure time, so we don't want to have to do it again at compile time, every time the depscan rule is run. We can do this by saving and passing the language to use in the pickle, so depscan doesn't have to re-calculate it. As an added bonus, this removes an import from depscan
2024-03-29scripts/depscan: combine pickle and JSON data into a single fileDylan Baker
We don't need to write and pass two separate files to the depscanner, I've used the pickle because the pickle serializer/deserializer should be faster than JSON, thought I haven't tested.
2024-03-28depscan: use a defaultdict to simplify append actionDylan Baker
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
2022-07-25ninja depscanner: handle C++ sources named capital CEli Schwartz
In commit 4ca9a16288f51cce99624a2ef595d879acdc02d8 we added unreliable support (it warns you if you try it) for gcc-compatible treatment of uppercase-C files being C++ instead of C. In order to handle it correctly, we needed to evaluate can-compile by special-casing "C" to avoid lowercasing it for comparisons. This didn't cover all cases where we check if "C" is a C++ language file. We also straight-up check the language of a file (rather than working backwards to see if a C++ compiler can compile it) when doing module scanning, and this needs to special-case "C" as well. We also had one case where we only checked lowercase fortran extensions, but not lowercase C++ extensions. While we are at it, use lowercase for C++ as well, except the "C" special case. Fixes #10629
2022-07-16Ignore encoding errors when scanning. Closes #10571.Jussi Pakkanen
In Fortran and C++ all the bits we care about are in ASCII. 8-bit characters can only occur in comments and string literals and we don't parse those.
2022-03-29move a bunch of imports into TYPE_CHECKING blocksEli Schwartz
These are only used for type checking, so don't bother importing them at runtime. Generally add future annotations at the same time, to make sure that existing uses of these imports don't need to be quoted.
2021-10-27fix various flake8 whitespace errorsEli Schwartz
2021-10-04fix extra whitespaceEli Schwartz
discovered via flake8 --select E303
2021-10-04various python neatness cleanupsEli Schwartz
All changes were created by running "pyupgrade --py3-only" and committing the results. Although this has been performed in the past, newer versions of pyupgrade can automatically catch more opportunities, notably list comprehensions can use generators instead, in the following cases: - unpacking into function arguments as function(*generator) - unpacking into assignments of the form x, y = generator - as the argument to some builtin functions such as min/max/sorted Also catch a few creeping cases of new code added using older styles.
2021-08-31pylint: turn on superflous-parensDylan Baker
We have a lot of these. Some of them are harmless, if unidiomatic, such as `if (condition)`, others are potentially dangerous `assert(...)`, as `assert(condtion)` works as expected, but `assert(condition, message)` will result in an assertion that never triggers, as what you're actually asserting is `bool(tuple[2])`, which will always be true.
2021-08-18backends/ninja: write depscan input files to jsonDylan Baker
Currently, we write each file to the command line, but this can result in situations where the number of files passed exceeds OS imposed command line limits. For compilers, we solve this with response files. For depscan I've chosen to use a JSON list instead. JSON has several advantages in that it's standardized, there's a built-in python module for it, and it's familiar. I've also chosen to always use the JSON file instead of having a heuristic to decide between JSON and not JSON, while there may be a small performance trade off here, keeping the implementation simple with only one path is wort it. Fixes #9129
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04raw string literals are next to godlinessEli Schwartz
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-01-20Use case-insensitive suffix check for fortranJonas Lundholm Bertelsen
In Fortran it is common to use capital F in the suffix (eg. '.F90') if the source file makes use of preprocessor statements. Such files should probably be treated like all other fortran files by meson. Case insensitivity for suffixes was already implemented several places in meson before this. So most likely, the few places changed here were oversights anyway.
2021-01-13Fix misspellsAntonin Décimo
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2020-12-25Extend the C++ module scanner to handle Fortran, too.Jussi Pakkanen
2020-12-13Add mypy annotations.Jussi Pakkanen
2020-12-13Scan all C++ sources and ignore everything else.Jussi Pakkanen
2020-12-13C++ module compilation works for a simple project.Jussi Pakkanen