Commit Graph

106 Commits

Author SHA1 Message Date
Benoit Pierre 3f4957c713 rewriter: don't output target info to stderr
Send the info to stdout, where it belongs.
2024-09-20 19:57:40 -07:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Charles Brunet bd4fd90730 parser: revert to single StringNode type
this will allow transforming string types in the formater
2024-04-08 10:43:57 -07:00
Jouke Witteveen f013a68898 rewriter: allow setting values regardless of the previous type
Alterations to kwargs come in two flavors:
1. Remove/replace values (delete/set)
2. Modify values (add/remove)

Only for the second flavor do we care about the type of any existing
value.
2024-02-26 23:30:39 +02:00
Eli Schwartz fc41fd3542
add type annotations to mesonmain
An oddity: sys.stdout is statically defined as type TextIO instead of
TextIOWrapper, and thus doesn't have a .reconfigure method. This is
because they expect people to override sys.stdout with other objects,
which we do not do. Instead, assume it is always correct.

There are two final errors due to metaprogramming:
```
mesonbuild/mesonmain.py:196:13: error: Returning Any from function declared to return "int"  [no-any-return]
mesonbuild/mesonmain.py:225:9: error: Returning Any from function declared to return "int"  [no-any-return]
```
2024-02-12 18:52:43 -05:00
Eli Schwartz 4e83675bf8
rewriter: remove never-used default None when parsing arguments
The add_arguments function is always called with a formatter in
mesonmain.py, and if it were not, then it would be incorrect when
calling argparse itself -- because formatter_class cannot be None, and
defaults to its own builtin one. This violates None-safety.
2024-02-12 18:52:43 -05:00
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
Marcel Telka 6901ec394f Remove shebang from rewriter.py 2023-11-16 08:31:29 -05:00
Luke Elliott ce691f8c98 Add comments suggesting to keep shell completion scripts up-to-date near cmd line argument code 2023-11-01 00:06:19 +02:00
Charles Brunet 5b29eff8ad parser: simplify other node constructors 2023-09-11 07:51:18 -04:00
Charles Brunet 0f4891cdf4 parser: simplify Assignment and PlusAssignment nodes 2023-09-11 07:51:18 -04:00
Charles Brunet 02ff9553db parser: add SymbolNode to preserve operators 2023-09-11 07:51:18 -04:00
Charles Brunet 306562b466 parser: use IdNode for function name and assignment name 2023-09-11 07:51:18 -04:00
Charles Brunet 35936283d2 parser: preserve escape chars in strings
use separate Node for multiline strings
2023-09-11 07:51:18 -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
Charles Brunet 9792506536 rewriter: fix indentation of kwargs 2023-03-14 16:22:05 +02:00
Charles Brunet 7fcc9a95bd rewriter: add missing command aliases 2023-03-14 16:22:05 +02:00
Charles Brunet d4d118438d rewriter: activate vsenv 2023-03-14 16:22:05 +02:00
Eli Schwartz c9ac73a4da
simplify instantiation of builtin type using builtins instead of functions 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 4da14918cd pylint: enable consider-using-in 2022-09-19 20:57:52 -04:00
Dylan Baker 2a0082b13a ast: rename module constant to match PEP8 style 2022-06-01 22:49:10 -04:00
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00
Celeste Wouters c5148d8c73 rewriter: create {add,rm}_extra_files commands
Add ability to mutate a target's `extra_files` list through the
rewriter.

The logic is copied from sources add/rm, but changes the `extra_files`
kwarg instead of the sources positional argument.
Has additional logic to handle creating the `extra_files` list if it
doesn't exist.
2021-12-15 21:21:29 +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
Dylan Baker 06fdb29daa pylint: turn on superfluous parens warning
Which is really useful for catching parens used with keywords like
assert. Don't use parens with assert, it's bad.
2021-08-31 16:28:54 -04:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +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
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Luke Elliott 9efcdba0d5 Allow '//' as project function id due to git bash path conversion.
See https://stackoverflow.com/questions/54258996/git-bash-string-parameter-with-at-start-is-being-expanded-to-a-file-path
2021-01-12 17:42:57 +00:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
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-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
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-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker 7142c92285 use OptionKey for backend_options 2021-01-04 12:15:41 -08:00
Dylan Baker e2ef6930ff use OptionKey for coredata.user_options 2021-01-04 12:15:41 -08:00
Marc-André Lureau be2c1a4300 rewrite: fix modified member spelling 2020-11-05 21:22:14 +02:00
Marc-André Lureau 7ba7ea0897 rewrite: fix function spelling 2020-11-05 21:22:14 +02:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
Daniel Mensinger ab988198c7
review: Initial fixup 2020-03-02 10:47:20 +01:00
Daniel Mensinger c48b0dea27
types: Annotate ast/interpreter.py 2020-03-02 10:34:55 +01:00
Daniel Mensinger a75255bc4c
types: Annotate the AST visitors 2020-03-02 10:34:55 +01:00
Daniel Mensinger c14aea2812
types: Annotate mparser.py
This also fixes that the keys in ArgumentNode.kwargs are
all of the type BaseNode now. Before this commit, it was
possible that both strings and Nodes where used as keys.
2020-03-02 10:34:55 +01:00
Jon Turney c8f8d58273
Rename 'subdir' -> 'filename' in location objects 2020-02-28 11:54:08 +00:00
Jon Turney d1bd4ccf6e
Update rewriter for filename in node location 2020-02-28 11:54:05 +00:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Daniel Mensinger b5cec1c632 lgtm: ignore all safe `__init__ method calls overridden method` warnings 2019-12-05 00:22:10 +02:00
Daniel Mensinger fa4de71faf lgtm: Fix unused variable 2019-12-05 00:22:10 +02:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
John Ericson af2d7af998 Per machine do 'build.' and '' option prefixes
See the docs/ changes for details.
2019-06-05 23:05:34 -04:00
Daniel Mensinger 94c6da33a7 rewriter: Fix that default_options would not set the correct id
Currently default_options uses "" for the kwarks id, however this
is incorect and it must be "/". Additionally, this error won't be
ignored in the future with "--skip" (this is why the tests were
passing and this wasn't detected earlier).
2019-06-05 22:27:32 +03:00