Commit Graph

105 Commits

Author SHA1 Message Date
Dylan Baker f29f3f9f28 interpreterbase: Fix version checking for deprecation
Currently deprecation features use the same logic as new features, but
that doesn't work correctly. FeatureNew wants to warn about cases where
you claim to support >= 0.40, but use a feature from 0.42; deprecation
wants to warn when you claim to support >= 0.50, but use a feature that
was replaced in 0.45.

To make this work we need to invert the version check in the deprecation
function, so that if the deprecation is 0.45, and the supported version
is >= 0.50, we get a true not a false.
2020-05-12 10:24:24 -07:00
Dylan Baker ee790eec2a interpreter: Don't assign duplication and new feature warning to the same variable
Currently The Deprecated and New features checkers share an attribute
through a base class that should be per class. We need to duplicate this
and move it into each of the sublcasses

Fixes #7080
2020-05-12 10:24:24 -07:00
James Hilliard d7c24ccddd Allow get_variable to still function when the fallback is a disabler. 2020-04-30 13:06:56 -07:00
Xavier Claessens 4d6faf6a13 interpreterbase: Add warning when built-in object method has no kwargs 2020-03-19 23:01:58 +02:00
Dylan Baker 1bb66d1568 fix conversion of hasattr to getattr
getattr() requires a default (return if missing) value or it raises an
AttributeError. In a few cases I changed hasattr to getattr and didn't
set a default value, so those cases could except. This corrects that.
2020-03-15 22:30:19 +02:00
Dylan Baker 1a82880730 mesonbuild/mesonlib: Add type annotations 2020-03-05 09:31:29 -08:00
Daniel Mensinger d67888bf9b
types: Remove redundant __init__() -> None annotation 2020-03-02 10:52:59 +01:00
Daniel Mensinger 0302a697b8
types: Use import typing as T 2020-03-02 10:51:07 +01:00
Daniel Mensinger ab988198c7
review: Initial fixup 2020-03-02 10:47:20 +01:00
Daniel Mensinger 5a89a6f804
types: (partially) annotate interpreterbase.py
This commit annotates most of interpreterbase.py. However,
there are stil the @wraps missing, since I am unsure what
the types are supposed to be here.
2020-03-02 10:42:43 +01:00
Daniel Mensinger c48b0dea27
types: Annotate ast/interpreter.py 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 346b5c4be7
Store filename in node location
Warnings have a location node object (with subdir and lineno
attributes), which is passed as a location: kwarg to mlog.warning() and
formatted in _log_error().

Re-purpose the subdir attribute (path relative to the source root dir,
with an implied filename of 'meson.build'), which is stored into the
node by parser(), to contain a pathname.

(Properly I should rename 'subdir' -> 'file' everywhere, but that's a
lot of churn just to see if this works)

Notes:
The warning location node may also have a colno attribute, which is
currently ignored by _log_error().

We can't currently issue warnings with locations in meson_options.txt
because the filename isn't part of the location (as it's assumed to be
'meson.build).
2020-02-28 11:54:04 +00:00
Jon Turney 534a974da7
Adjust all the other places MesonException file attribute is set
A MesonException has file, lineno and colno attributes, which get
formatted as a location in mlog.exception().

The file attribute got changed from a path relative to the root source
directory to a pathname (absolute or relative to cwd) in one place in
commit b8fbbf59.  Adjust all the other places the file attribute is set
to match.

Also:
Setting MesonException.file seems to be missing in the case where Parser
returned a non-CodeBlockNode object.  Fortunately, that looks like it's
unreachable, but add it just in case.
2020-02-28 11:54:04 +00:00
Xavier Claessens 9b1a857473 dict: Fully evaluate keys
The only restriction is keys must be string after evaluation. This fix
various inconsistencies.
2019-12-04 16:45:56 -05:00
fchin 4e460f04f3 Fixed issue that the key's value type wasn't checked correctly.
Added two new failing tests.
2019-11-12 09:21:10 -05:00
franczc adb4e071e6 Adding dictionary entry using string variable as key. 2019-11-12 09:21:10 -05: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
James Hilliard 2b6c997e33 Return a disabler when an unknown method is called on a disabler object 2019-10-24 23:57:31 +03:00
Jussi Pakkanen 34ea71239d
Merge pull request #6011 from xclaesse/not-disabler
Fix `if not disabler()` case
2019-10-10 00:47:17 +03:00
Niklas Claesson b8fbbf5964 Make parser errors print relative path to meson.build file 2019-10-10 00:40:30 +03:00
Xavier Claessens 9855b2d3c5 Test disabler in foreach loops
The is_disabler() check in evaluate_foreach() was useless because we
already checked that items is a list.
2019-10-08 12:11:56 -04:00
Xavier Claessens 1930fc82e2 Fix `if not disabler()` case
Closes: #6010
2019-10-08 11:12:29 -04:00
James Hilliard b21fd95f73 Add is_disabler function
This is useful if one needs to check if a variable is a disabler.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2019-08-12 01:05:45 +03:00
Marc-André Lureau 3811101434 meson: handle nested disabler
Fixes #5659
2019-07-23 08:46:26 -07:00
Daniel Mensinger 5ec79185a0
Address code review 2019-04-29 12:23:13 +02:00
Daniel Mensinger 2b5831f94f
Fix flake8-bugbear warnings 2019-04-29 12:22:50 +02:00
Daniel Mensinger 75b7a856cd
ast: support elementary object methods 2019-04-23 09:10:47 +02:00
Paolo Bonzini 7a02b76e70 interpreterbase: protect string division with FeatureNew
Meson is not warning if you join paths with / but you are requesting a
version older than 0.49.0; fix this before adding more features to the
division operator.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-18 10:51:44 -07:00
Michael Hirsch, Ph.D 4e31ca3abe correct naming to CudaCompiler, pep8 2019-01-29 22:06:11 +02:00
Xavier Claessens 4b4f642e6a InterpreterBase: Fix extracting the node in all method/function calls
Closes: #4813.
2019-01-22 16:12:15 -05:00
Xavier Claessens 90d1f38d8e Interpreter: Set self.current_node during method/function calls
The current node is useful to pass as location kwarg to mlog.warning().
The node is not passed to InterpreterObject method arguments, and it's
easier to have it on the object than passing it through argument
everywhere.
2019-01-22 12:33:12 -05:00
Xavier Claessens 83766b3687 Fix flake8 errors 2019-01-16 11:16:46 -05:00
Jussi Pakkanen 95c620db67 Error out if kwargs dict contains a kwargs entry.
Yo dawg! We heard U don't like kwargs in kwargs, so we made it
impossible to put kwargs in your kwargs so now you can't kwargs with
your kwargs.
2018-12-07 21:35:26 +02:00
Jussi Pakkanen 58b838a80b Can specify keyword arguments with a dict. 2018-12-04 23:44:17 +02:00
Jussi Pakkanen 23ed0e1857 Make string division do path joining. 2018-11-02 21:02:25 +02:00
Xavier Claessens 61348da069 Add 'disabler' argument to functions returning not-found objects
When dependency(), find_library(), find_program(), or
python.find_installation() return a not-found object and disabler is
true, they return a Disabler object instead.
2018-10-23 22:09:55 +03:00
Xavier Claessens a816e1c1fa Interpreter: Add 'continue' and 'break' keywords
Closes: #3601
2018-10-04 20:14:37 -04:00
Xavier Claessens fa2e096aa0 Interpreter: Add "in" and "not in" operators
Closes: #3600
2018-10-04 20:14:37 -04:00
Xavier Claessens 4f088365e4 interpreter: Add support for dict addition 2018-08-14 23:46:42 +03:00
Nirbheek Chauhan f80c11e7ee Clarify the FeatureNew summary message
Fixes https://github.com/mesonbuild/meson/issues/3858
2018-08-11 09:15:05 -07:00
Nirbheek Chauhan 43ececb036 Skip FeatureNew checks when project() has not been parsed
Fixes https://github.com/mesonbuild/meson/issues/3944
2018-08-11 09:15:05 -07:00
Nirbheek Chauhan 2093d45a4e Print a more usable message when a subproject fails to configure
Instead of just printing the message in the exception, if it's
a MesonException, also print the file and the line number. If it's an
unknown exception, print the entire traceback so that we can pin-point
what the Meson bug causing it is.
2018-07-07 04:33:24 -07:00
Nirbheek Chauhan 4fb00ee1d8 Add new method: mlog.deprecation()
Instead of constructing it manually, use a helper.
2018-07-07 04:33:24 -07:00
Nirbheek Chauhan a1d9adba09 FeatureNew: Make all checks subproject-specific
We now pass the current subproject to every FeatureNew and
FeatureDeprecated call. This requires a bunch of rework to:

1. Ensure that we have access to the subproject in the list of
   arguments when used as a decorator (see _get_callee_args).
2. Pass the subproject to .use() when it's called manually.
3. We also can't do feature checks for new features in
   meson_options.txt because that's parsed before we know the
   meson_version from project()
2018-07-02 19:52:53 +05:30
Nirbheek Chauhan cd1d53ee75 FeatureNew: Declare functions as class methods explicitly 2018-07-02 07:05:08 +00:00
Nirbheek Chauhan 18cd3bd31a FeatureNew: Minor code cleanup, no changes
Early return reduces indentation level and makes the code easier to
read.
2018-07-02 07:05:08 +00:00
Nirbheek Chauhan 817dcaa23b Remove permittedSnippetKwargs, snippets are not special
All we needed to do was change _get_callee_args() to also support
snippets.
2018-07-02 07:05:08 +00:00
Salamandar df1970d3ad Various bug fixes for FeatureNew
* Use _get_callee_args to unwrap function call arguments, needed for
  module functions.

* Move some FeatureNewKwargs from build.py to interpreter.py

* Print a summary for featurenew only if conflicts were found. The
  summary now only prints conflicting features.

* Report and store featurenew/featuredeprecated only once

* Fix version comparison: use le/ge and resize arrays to not fail on
  '0.47.0>=0.47'

Closes https://github.com/mesonbuild/meson/issues/3660
2018-07-02 07:05:08 +00:00
Xavier Claessens 2d3bfa0778 Interpreter: Fix subdir_done() to exit from inside if/foreach blocks
Closes: #3700.
2018-06-07 12:56:27 +00:00