Commit Graph

65 Commits

Author SHA1 Message Date
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
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-13 15:19:21 -05:00
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
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-11 13:41:03 -04:00
Eli Schwartz a01418db0a
remove useless type annotations
These annotations all had a default initializer of the correct type, or
a parent class annotation.
2023-08-11 13:37:17 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Eli Schwartz dcefe1f8fd
pyupgrade: use set literal 2023-02-01 17:01:30 -05:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
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-30 16:23:29 -05:00
Dylan Baker d5e899c768
pylint: enable the bad_builtin checker
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-29 23:26:05 -05:00
Dylan Baker a72840cd2e
pylint: enable use-a-generator
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-04 00:33:04 -04:00
Dylan Baker 4da14918cd pylint: enable consider-using-in 2022-09-19 20:57:52 -04:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Volker Weißmann 5f3c7125cc Applied tristan957's suggestions 2022-07-18 13:46:26 +02:00
Volker Weißmann cdd2dca174 cmake module: Better warnings and error messages in some cases. 2022-07-18 13:46:26 +02:00
Daniel Mensinger 1b9c4b7192 Fix generator expression list problems (fixes #10288) 2022-04-18 22:59:44 -04:00
Daniel Mensinger 4dd6cb8469 cmake: Better error message when configuring a CMake subproject fails. 2022-04-03 12:04:21 -04:00
Jussi Pakkanen 219f40c1e4
Merge pull request #9743 from mensinda/cmakeGeneratorFixed
cmake: Add TARGET_ generator expression support (fixes #9305)
2022-03-07 16:12:19 +02:00
Eli Schwartz 07d9c72e17
flake8: fix wrong numbers of blank line separators 2022-02-16 18:19:13 -05:00
Daniel Mensinger 63870da449 cmake: Deprecate CMake <3.17 support 2022-02-03 11:25:59 -05:00
Daniel Mensinger 42843c4cf6
cmake: Add TARGET_ generator expression support (fixes #9305) 2022-01-23 13:22:59 +01:00
Daniel Mensinger 99aae9b4df
cmake: Move generator expression evaluation to the end of the traceparser 2022-01-23 13:22:47 +01:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
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-31 16:28:54 -04:00
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
Eli Schwartz 566efba216 fix typo in log message 2021-07-05 17:55:04 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Daniel Mensinger 0e777e7c90
cmake: CMakeTraceParser improvements
- handle cached CMake variables differently
 - associate variables with source files
 - better performance (str to Path and generator expressions)
2021-05-29 13:20:25 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Dylan Baker f6672c7a19 use real pathlib module
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-11-20 15:08:40 -08:00
Daniel Mensinger fc57089bc5 cmake: Disable the new (CMake 3.16) PCH support
Subprojects that use the CMake PCH feature will cause
compilation/linker errors. The CMake PCH support
should thus be disabled until this can be properly
translated to meson.
2020-10-24 19:31:15 +02:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Daniel Mensinger 77b5c82d07 cmake: switch to pathlib (fixes #7322) 2020-10-04 10:45:48 +02:00
Daniel Mensinger c2d55afcb5
typing: fully annotate cmake.traceparser 2020-09-28 13:53:59 +02:00
Daniel Mensinger 02ea08ba66 cmake: make the traceparser permissive by default (fixes #7501) 2020-08-07 23:53:21 +03:00
Daniel Mensinger 1c1ec9ff11
cmake: resolve IMPORTED executables in custom commands (fixes #7509) 2020-08-03 17:48:12 +02:00
Michael Hirsch 477cacf155 cmake_traceparser: ignore parse error 2020-06-09 10:08:07 -07:00
Daniel Mensinger a252a17e6e cmake: always split property lists (fixes #7228) 2020-06-02 20:47:22 +03:00
georgev93 30b89ea573 Adding a conditional case in _guess_files to confirm that the complete path is put together in even if a portion of the path is a location that exists.
For instance if C:/Program Files (x86)/folder is passed to _guess_files, it would resolve to ['C:/Program Files', '(x86)/folder'] since C:/Program Files is an actual file location that can exist.
2020-04-28 19:54:34 +02:00
georgev93 8e397491b4 Adjust regex to handle cases such as C:/Program Files/folder 2020-04-24 10:47:52 +02:00
Daniel Mensinger cf4b9e6502 cmake: Do not compile explicit header files 2020-04-17 18:28:40 +03:00
Daniel Mensinger 4199cb32a5
cmake: Fix custom command CMake list issue 2020-04-12 15:11:37 +02:00
Daniel Mensinger 113ec96626
cmake: Fix relative paths for add_custom_{command,target}
Do this by tracking CMAKE_CURRENT_{SOURCE,BINARY}_DIR variables.
This is achieved by injecting CMake code with CMAKE_PROJECT_INCLUDE
and overriding some builtin functions with a wrapper that adds
additional trace information.
2020-02-20 11:16:37 +01:00
Daniel Mensinger 31eb41ec2f
cmake: traceparser better handle lists 2020-02-19 11:52:22 +01:00
Daniel Mensinger 796b4c120a cmake: Add support for the new JSON trace format 2020-02-12 20:58:37 +01:00
Daniel Mensinger 48cb1a7004
cmake: Fix spaces in compile flags (fixes #6566) 2020-02-04 11:37:55 +01:00
Daniel Mensinger acc6dbfab7
cmake: Add support for --trace-redirect 2020-01-26 18:23:41 +01:00
Daniel Mensinger 3607f50d7f
cmake: Refactor CMakeExecutor and CMakeTraceParser
This moves most of the execution code from the CMakeInterpreter
into CMakeExecutor. Also, CMakeTraceParser is now responsible
for determining the trace cmd arguments.
2020-01-26 18:23:34 +01:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Daniel Mensinger 4f6453bc32 cmake: Use trace for missing link flags (fixes #6386)
This is neccessary for static libraries, since the
CMake file API does not add link flags here.
2019-12-29 19:02:24 +02:00
Xavier Claessens daeee32d9b
cmake: Add support for add_custom_target() with a command
The command could have no output, in which case we create a dummy one.
2019-11-27 21:12:55 +01:00
Xavier Claessens 6844ad374e
cmake: Add support for add_dependencies()
Closes: #5983
2019-11-27 21:12:50 +01:00