aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake
AgeCommit message (Collapse)AuthorFilesLines
2023-02-13cmake: check that `re.search` returned a non-None valueDylan Baker1-6/+12
If an re call fails to find a match it returns None. We're not checking that, and crashing. Fixes: #11376
2023-02-01micro-optimize: define typing-only objects in TYPE_CHECKINGEli Schwartz2-5/+5
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 Schwartz5-0/+5
2023-02-01pyupgrade: use set literalEli Schwartz1-1/+1
2022-11-30pylint: enable the set_membership pluginDylan Baker4-9/+9
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-29pylint: enable the bad_builtin checkerDylan Baker2-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-29Fix crash when toolchain is missingSmallWood-D1-2/+3
Add a MissingCompiler class returned by compiler detecting methods intead of None - accessing such an object raises a DependencyException Fixes #10586 Co-authored-by: duckflyer <duckflyer@gmail.com>
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 Baker4-11/+11
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-09-19pylint: enable consider-using-inDylan Baker1-1/+1
2022-09-19compilers: don't use instance checks to determine propertiesEli Schwartz1-2/+1
In various situations we want to figure out what type of compiler we have, because we want to know stuff like "is it the pgi one", or "does it use msvc style". The compiler object has this property already, via an API specifically designed to communicate this info, but instead we performed isinstance checks on a compiler class. This is confusing and indirect, and has the side effect of requiring more imports everywhere. We should do away with it.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge7-152/+152
2022-07-18Applied tristan957's suggestionsVolker Weißmann2-3/+2
2022-07-18cmake module: Better warnings and error messages in some cases.Volker Weißmann3-0/+10
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz3-5/+12
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-18Fix generator expression list problems (fixes #10288)Daniel Mensinger1-6/+7
2022-04-03cmake: Better error message when configuring a CMake subproject fails.Daniel Mensinger2-4/+23
2022-03-29Fix CMake deprecation warning generated from interpreterTristan Partin1-1/+1
2022-03-07Merge pull request #9743 from mensinda/cmakeGeneratorFixedJussi Pakkanen4-7/+100
cmake: Add TARGET_ generator expression support (fixes #9305)
2022-02-16flake8: fix wrong numbers of blank line separatorsEli Schwartz1-0/+1
2022-02-03cmake: Deprecate CMake <3.17 supportDaniel Mensinger2-12/+11
2022-02-03cmake: Drop CMake server support and bump min. CMake to >= 3.14Daniel Mensinger3-434/+17
2022-01-23cmake: Add TARGET_ generator expression support (fixes #9305)Daniel Mensinger4-11/+72
2022-01-23cmake: Move generator expression evaluation to the end of the traceparserDaniel Mensinger2-3/+35
2022-01-10port from embedded data to importlib.resourcesEli Schwartz2-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 Mensinger4-78/+140
This also includes some refactoring, since the alternaticve would have been to duplicate the huge traceparser target code block again. fixes #9581
2021-11-21Support Visual Studio 2022 backendCrend King1-0/+1
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-10-08cmake: handle arguments in the [binaries] section of the machine filePaolo Bonzini1-6/+17
Sometimes, the machine file can include compiler command line options, in order to pick the correct multilib. For example, Meson uses "$cc --print-search-dirs" to find the library search path, where $cc is the cc from the machine file. Because the outputs of "gcc -m32 --print-search-dirs" and "gcc --print-search-dirs" are different, this only works if you have [binaries] cc = ['gcc', '-m32'] in the machine file. Right now, however, the cmake module assumes that the compiler listed in the machine file is either a compiler, or a "launcher" followed by the compiler. Check if the second argument starts with a slash (for Microsoft-like compilers) or a dash (for everyone else), and if so presume that the CMAKE_*_COMPILER_LAUNCHER need not be defined.
2021-10-04remove double importEli Schwartz1-2/+2
Imported both inside and outside of T.TYPE_CHECKING, the runtime import can be removed by quote-deferring one of the use sites. Update: In between then and now, this got removed from T.TYPE_CHECKING, move it back there rather than preserving the runtime import.
2021-09-24pylint: check for duplicate importsDylan Baker1-1/+0
I ran into one of these from LGTM, and it would be nice if pylint could warn me as part of my local development process instead of waiting for the CI to tell me.
2021-09-14apply flake8 fixes for unused imports and missing importsEli Schwartz1-1/+0
2021-09-14semicolons are not needed in pythonEli Schwartz1-1/+1
2021-08-31pylint: turn on superflous-parensDylan Baker3-12/+12
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-05more f-strings too complex to be caught by pyupgradeEli Schwartz1-2/+2
2021-07-05fix typo in log messageEli Schwartz1-1/+1
2021-07-05cmake: Only use the `cm_` prefix when it is actually required (fixes #8955)Daniel Mensinger1-1/+4
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger3-8/+8
2021-06-22Add Visual Studio 2012/2013 backends (#8803)fanc9991-1/+3
* backends: Add a Visual Studio 2013 backend This is more-or-less a quick port from the VS2015 backend, except that we update the Visual Studio version strings and toolset versions accordingly. Also correct the generator string for Visual Studio 2015 in mesonbuild/cmake/common.py. * backend: Add VS2012 backend Similar to what we did for Visual Studio 2013, add a Visual Studio 2012 backend. * vs2010backend.py: Implement `link_whole:` if needed We actually need Visual Studio 2015 Update 2 to use `/WHOLEARCHIVE:`, which is what we are currently using for `link_whole:` on Visual Studio. For Visual Studio versions before that, we need to expand from the static targets that were indicated by `link_whole:`, and any of the sub-dependent targets that were pulled in via the dependent target's `link_whole:`. This wil ensure `link_whole:` would actually work in such cases. * vs2010backend.py: Handle objects from generated sources Unforunately, we can't use backends.determine_ext_objs() reliably, as the Visual Studio backends handle this differently. * vs2010backend.py: Fix generating VS2010 projects Visual Studio 2010 (at least the Express Edition) does not set the envvar %VisualStudioVersion% in its command prompt, so fix generating VS2010 projects by taking account into this, so that we can determine the location of vcvarsall.bat correctly. * whole archive test: Disable on vs2012/2013 backends too The Visual Studio 2012/2013 IDE has problems handling the items that would be generated from this test case, so skip this test when using --backend=vs[2012|2013]. This test does work for the Ninja backend when VS2012 or VS2013 is used, though. Consolidate this error message with XCode along with the vs2010 backend. * docs: Add the new vs2012 and vs2013 backends Let people know that we have backends for vs2012 and 2013. Also let people know that generating Visual Studio 2010 projects have been fixed and the pre-vs2015 backends now handle the `link_whole:` project option.
2021-06-22Fix for Issue 8910 (Meson filters CMake asm files)Justin Handville1-2/+2
2021-06-07upgrade percent formatted strings pyupgrade did not catchEli Schwartz1-3/+3
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 Mensinger4-16/+29
2021-05-29cmake: exclude generated files from the buildsystem files listDaniel Mensinger1-0/+2
2021-05-29cmake: Fix CMakeToolchain (fixes #8293)Daniel Mensinger2-66/+94
Instead of guessing the internal compiler variables, Meson now runns CMake once to determine what they actually are.