aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/interpreter.py
AgeCommit message (Collapse)AuthorFilesLines
2023-02-01micro-optimize: define typing-only objects in TYPE_CHECKINGEli Schwartz1-3/+3
Union types that exist solely for use as annotations don't need to be created in normal runs.
2022-11-30pylint: enable the set_membership pluginDylan Baker1-3/+3
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-24migrate some type comments to modern type annotationsEli Schwartz1-54/+54
flake8 6 upgrades to pyflakes 3, and in turn this means that support for parsing `# type: ` style annotations has been removed. https://github.com/PyCQA/pyflakes/pull/684 This caused one file to fail linting, because it had a typing import which was only used by a type comment. ``` mesonbuild/cmake/interpreter.py:55:5: F401 '.common.CMakeConfiguration' imported but unused ``` Updating it to actual annotations allows pyflakes to detect its usage again, and flake8 passes. Do the whole file while we are here.
2022-11-24remove a couple of unneeded type annotationsEli Schwartz1-8/+8
These are trivially inferred based on their initialized values.
2022-10-04pylint: enable use-a-generatorDylan Baker1-7/+7
This catches some optimization problems, mostly in the use of `all()` and `any()`. Basically writing `any([x == 5 for x in f])` vs `any(x == 5 for x in f)` reduces the performance because the entire concrete list must first be created, then iterated over, while in the second f is iterated and checked element by element.
2022-10-03pylint: enable unnecessary-comprehensionDylan Baker1-1/+1
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge1-84/+84
2022-07-18cmake module: Better warnings and error messages in some cases.Volker Weißmann1-0/+1
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz1-2/+5
2022-07-03sort imports for neatnessEli Schwartz1-6/+6
2022-05-24cmake: fix detecting directories as input files (fixes #10244)Daniel Mensinger1-1/+1
2022-04-03cmake: Better error message when configuring a CMake subproject fails.Daniel Mensinger1-4/+8
2022-03-29Fix CMake deprecation warning generated from interpreterTristan Partin1-1/+1
2022-03-07Merge pull request #9743 from mensinda/cmakeGeneratorFixedJussi Pakkanen1-2/+2
cmake: Add TARGET_ generator expression support (fixes #9305)
2022-02-03cmake: Deprecate CMake <3.17 supportDaniel Mensinger1-12/+0
2022-02-03cmake: Drop CMake server support and bump min. CMake to >= 3.14Daniel Mensinger1-59/+17
2022-01-23cmake: Add TARGET_ generator expression support (fixes #9305)Daniel Mensinger1-2/+2
2022-01-10port from embedded data to importlib.resourcesEli Schwartz1-2/+2
2021-12-02cmake: Deprecate CMake <3.14 and warn for <3.17 (#9677)Daniel Mensinger1-0/+14
* cmake: Deprecate CMake <3.14 and warn for <3.17 See: - #7832 - #9676 * cmake: Add deprecation release note snippet
2021-12-01cmake: Fix old style dependency lookup with imported targetsDaniel Mensinger1-77/+6
This also includes some refactoring, since the alternaticve would have been to duplicate the huge traceparser target code block again. fixes #9581
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-09-14semicolons are not needed in pythonEli Schwartz1-1/+1
2021-08-31pylint: turn on superflous-parensDylan Baker1-5/+5
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-07-05cmake: Only use the `cm_` prefix when it is actually required (fixes #8955)Daniel Mensinger1-1/+4
2021-06-22Fix for Issue 8910 (Meson filters CMake asm files)Justin Handville1-2/+2
2021-06-02use an immutable list for an lru_cached functionsDylan Baker1-2/+3
When mutable items are stored in an lru cache, changing the returned items changes the cached items as well. Therefore we want to ensure that we're not mutating them. Using the ImmutableListProtocol allows mypy to find mutations and reject them. This doesn't solve the problem of mutable values inside the values, so you could have to do things like: ```python ImmutableListProtocol[ImmutableListProtocol[str]] ``` or equally hacky. It can also be used for input types and acts a bit like C's const: ```python def foo(arg: ImmutableListProtocol[str]) -> T.List[str]: arg[1] = 'foo' # works while running, but mypy errors ```
2021-05-30cmake: select correct generator in toolchain.pyDaniel Mensinger1-12/+2
2021-05-29cmake: exclude generated files from the buildsystem files listDaniel Mensinger1-0/+2
2021-05-29cmake: Fix CMakeToolchain (fixes #8293)Daniel Mensinger1-1/+1
Instead of guessing the internal compiler variables, Meson now runns CMake once to determine what they actually are.
2021-03-19split program related classes and functions out of dependenciesDylan Baker1-1/+1
Dependencies is already a large and complicated package without adding programs to the list. This also allows us to untangle a bit of spaghetti that we have.
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-33/+33
performed by running "pyupgrade --py36-plus" and committing the results
2021-01-23split mesonlib into a packageDylan Baker1-1/+1
Currently mesonlib does some import tricks to figure out whether it needs to use windows or posix specific functions. This is a little hacky, but works fine. However, the way the typing stubs are implemented for the msvcrt and fnctl modules will cause mypy to fail on the other platform, since the functions are not implemented. To aleviate this (and for slightly cleaner design), I've split mesonlib into a pacakge with three modules. A universal module contains all of the platform agnositc code, a win32 module contains window specific code, a posix module contains the posix specific code, and a platform module contains no-op implementations. Then the package's __init__ file imports all of the universal functions and all of the functions from the approriate platform module, or the no-op versions as fallbacks. This makes mypy happy, and avoids `if`ing all over the code to switch between the platform specific code.
2021-01-13Fix misspellsAntonin Décimo1-1/+1
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-04Merge pull request #8080 from dcbaker/submit/option-key-typeJussi Pakkanen1-5/+5
Use an object for option keys
2021-01-04Use a single coredata dictionary for optionsDylan Baker1-2/+2
This patches takes the options work to it's logical conclusion: A single flat dictionary of OptionKey: UserOptions. This allows us to simplify a large number of cases, as we don't need to check if an option is in this dict or that one (or any of 5 or 6, actually).
2021-01-04use OptionKey for builtin and base optionsDylan Baker1-1/+1
I would have prefered to do these seperatately, but they are combined in some cases, so it was much easier to convert them together. this eliminates the builtins_per_machine dict, as it's duplicated with the OptionKey's machine parameter.
2021-01-04move OptionKey to mesonlibDylan Baker1-2/+1
There's starting to be a lot of things including coredata that coredata needs to itself include. putting it in mesonlib makes more sense
2021-01-04use OptionKey for compiler_optionsDylan Baker1-3/+4
2021-01-04cmake: fix missing languages from CMake (fixes #8132)Daniel Mensinger1-8/+29
2020-12-29cmake: fix -framework dependencies (fixes #8045)Daniel Mensinger1-0/+14
2020-12-16cmake: Revert to using self.for_machine instead of MachineChoice.BUILD ↵Daniel Mensinger1-0/+1
(fixes #8028)
2020-11-20use real pathlib moduleDylan Baker1-1/+1
We added the _pathlib module to work around defeciencies in python 3.5's implementation, since we now rely on 3.6 lets drop this
2020-10-24cmake: Always create missing includes in build dirDaniel Mensinger1-4/+1
There really isn't any reason to not always create missing include directories inside the build dir. Just restricting this to generate generated sources should work in an ideal world, however, there exists lots of suboptimal CMake code where this assumption is not always true.
2020-10-16cmake: ignore CMAKE_TOOLCHAIN_FILE and CMAKE_PROJECT_INCLUDE to avoid ↵Daniel Mensinger1-1/+4
conflicts with the meson CMake logic
2020-10-13cmake: Add cross compilation supportDaniel Mensinger1-57/+43
2020-10-04pathlib: Fix resolve() by overriding it in Python 3.5Daniel Mensinger1-1/+1
2020-10-04cmake: switch to pathlib (fixes #7322)Daniel Mensinger1-128/+124
2020-09-28typing: fully annotate cmake.interpreterDaniel Mensinger1-171/+198
2020-09-27typing: fully annotate cmake.commonDaniel Mensinger1-2/+2
2020-09-10cmake: fix shared_module dependency (fixes #7715)Daniel Mensinger1-0/+4