aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase.py
AgeCommit message (Collapse)AuthorFilesLines
2018-06-07Interpreter: Fix subdir_done() to exit from inside if/foreach blocksXavier Claessens1-3/+4
Closes: #3700.
2018-06-05FeatureNew: Print WARNING instead of ERRORNirbheek Chauhan1-2/+2
ERROR is reserved for non-zero exit codes. People will probably get confused.
2018-06-01Add 0.47.0 featuresSalamandar1-0/+1
2018-06-01Add Feature{New,Deprecated}Kwargs decoratorsSalamandar1-0/+30
2018-06-01Move target_version from coredata to mesonlibSalamandar1-3/+2
2018-06-01Add set instead of list for used features litsSalamandar1-4/+4
2018-06-01Cleanup : have more common code between FeatureNew and FeatureDeprecatedSalamandar1-18/+22
2018-06-01Split function wrapper from a use() methodSalamandar1-17/+22
2018-06-01Add version_compare_condition_with_{min,max} for specific comparison utils.Salamandar1-4/+56
Split FeatureNew and FeatureDeprecated Implement features report to be printed in some 'dev mode'
2018-06-01Add basic code for feature version detection:Salamandar1-0/+17
* store target version * Add empty method decorator
2018-05-21dict: fix CI issuesMathieu Duponchelle1-1/+1
2018-05-20dict: address review commentsMathieu Duponchelle1-2/+1
2018-05-20Add methods to the dict builtinKyrylo Shpytsya1-0/+39
Adds "has_key" and "get". Adapted and updated by Mathieu Duponchelle <mathieu@centricular.com>
2018-05-20Add new built-in type, dictMathieu Duponchelle1-15/+45
For now dicts are immutable, and do not expose any methods, they however support "native" syntax such as [] lookup, and foreach iterating, and can be printed.
2018-05-04Interpreter: don't flatten the arguments of various methodsMathieu Duponchelle1-19/+30
this fixes eg set_variable('foo', ['bar', 'baz']), which was previously erroring out complaining about the number of arguments. Closes #1481
2018-04-26interpreter: Verify permitted kwargs on all methodsXavier Claessens1-26/+33
2018-03-29Allow meson build file to exit early. (#2808)behlec1-0/+5
2018-03-13Merge pull request #3127 from bluetech/method-permitted-kwargsJussi Pakkanen1-0/+16
2018-03-03Fix remaining flake8 reportJon Turney1-1/+1
$ flake8 ./mesonbuild/interpreterbase.py:411:13: F821 undefined name 'set_variable' This looks like an actual bug which would affect disabler use :)
2018-02-23Warn if non-permitted keyword arguments are given to compiler methodsRan Benita1-0/+16
This can help future generations avoid mistakes like this: https://github.com/xkbcommon/libxkbcommon/commit/edb1c662394578a54b7bbed231d918925e5d8150 To avoid breaking builds, this is currently just an error. After sufficient time has passed this can hopefully become a hard error, similarly to the already-existing `permittedKwargs` warnings.
2018-02-15Add source location to warning for comparing different typesJon Turney1-2/+2
2018-02-15Fix test cases/failing/52 inconsistent comparisonJon Turney1-4/+15
Since PR #2884, this is failing with an exception Keep the behaviour we have had since PR #1810 (0.41.0), that ordering comparisons of different types fail with an InterpreterException. Also warn about equality comparisons of different types, which will one day become an error, as per PR #2884.
2018-02-01Comparing objects of different type prints a warning. Closes #2870.Jussi Pakkanen1-5/+7
2018-01-30Report warning/error locations in a format IDEs may already know how to parseJon Turney1-1/+1
Examples: meson.build:2:0: ERROR: Dependency is both required and not-found meson.build:4: WARNING: Keyword argument "link_with" defined multiple times. These are already matched by the default compilation-error-regexp-alist in emacs. Also: Don't start 'red' markup until after the \n before an error Unabsorb full-stop at end of warning with location from mlog.warning() Update warning_location test
2018-01-01Use location formatting in mlog.warning() for invalid kwarg warningJon Turney1-8/+10
This already reports the location (in a slightly different format), but using mlog.warning() will make it easier if we want to change the location format in future.
2017-12-04Created a new disabler type.Jussi Pakkanen1-10/+79
2017-11-26interpreter: Reduce to_sring method to base 10Iñigo Martínez1-6/+1
The int's to_string method implementation has been reduced to base 10.
2017-11-26interpreter: Support to_string method for int valuesIñigo Martínez1-0/+10
Although some other base types like boolean objects can be expresed as strings, this is not possible with int objects. This patch adds support to express int values as strings as hex, decimal or octal values.
2017-09-27Allow CustomTarget's to be indexedDylan Baker1-4/+6
This allows a CustomTarget to be indexed, and the resulting indexed value (a CustomTargetIndex type), to be used as a source in other targets. This will confer a dependency on the original target, but only inserts the source file returning by index the original target's outputs. This can allow a CustomTarget that creates both a header and a code file to have it's outputs split, for example. Fixes #1470
2017-09-12str.split() can now take a positional argumentNirbheek Chauhan1-8/+19
All the specified characters in the specified argument will be stripped. If unspecified, the old behaviour is used. Includes tests.
2017-08-14Printing unknown kwarg error message no longer crashes the parser.Jussi Pakkanen1-4/+10
2017-08-14Store current line number so it can be printed in warning messages. Closes ↵Jussi Pakkanen1-1/+5
#2181.
2017-07-02Merge pull request #2017 from mesonbuild/fix2012Jussi Pakkanen1-0/+1
Do not pickle interpreter objects by accident
2017-07-02Improve "Passed invalid keyword argument" warning.Jehan1-1/+1
I got this warning on a build: > WARNING: Passed invalid keyword argument preset. This will become a hard error in the future. I had to grep in meson code to understand that "preset" was the name of the invalid argument. This is not obvious at all depending on the argument name (here it looked like it was about argument presets). Let's make it clearer by putting it in quotes.
2017-07-01Make Interpreter object unpicklable as it was being pickled by accident in ↵Jussi Pakkanen1-0/+1
copies of kwargs.
2017-06-26Fixed issues raised in review.Jussi Pakkanen1-1/+1
2017-06-26Moved func_ methods from base class to Interpreter.Jussi Pakkanen1-47/+0
2017-06-26Decorator to check for permitted kwargs.Jussi Pakkanen1-0/+13
2017-05-17Don't allow non-equality comparisons across types.Elliott Sales de Andrade1-0/+5
2017-05-17Only allow equality comparisons for non-elementary types.Elliott Sales de Andrade1-0/+4
2017-05-17Remove extra casts on InterpreterBase.evaluate_statement.Elliott Sales de Andrade1-39/+5
The result of this method is always a "native" object, and code coverage (plus a manual inspection) shows that this conversion is never done.
2017-05-02Don't use len() to test emptiness vs not emptinessDylan Baker1-7/+7
Meson has a common pattern of using 'if len(foo) == 0:' or 'if len(foo) != 0:', however, this is a common anti-pattern in python. Instead tests for emptiness/non-emptiness should be done with a simple 'if foo:' or 'if not foo:' Consider the following: >>> import timeit >>> timeit.timeit('if len([]) == 0: pass') 0.10730923599840025 >>> timeit.timeit('if not []: pass') 0.030033907998586074 >>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass') 0.1154778649979562 >>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass") 0.08259823200205574 >>> timeit.timeit('if len("") == 0: pass') 0.089759664999292 >>> timeit.timeit('if not "": pass') 0.02340641999762738 >>> timeit.timeit('if len("foo") == 0: pass') 0.08848102600313723 >>> timeit.timeit('if not "foo": pass') 0.04032287199879647 And for the one additional case of 'if len(foo.strip()) == 0', which can be replaced with 'if not foo.isspace()' >>> timeit.timeit('if len(" ".strip()) == 0: pass') 0.15294511600222904 >>> timeit.timeit('if " ".isspace(): pass') 0.09413968399894657 >>> timeit.timeit('if len(" abc".strip()) == 0: pass') 0.2023209120015963 >>> timeit.timeit('if " abc".isspace(): pass') 0.09571301700270851 In other words, it's always a win to not use len(), when you don't actually want to check the length.
2017-02-02Fix an uninitialized variable access error.Hemmo Nieminen1-0/+2
To reproduce, one could write: foo = files('foo.c') foo[0].path() and get: Traceback (most recent call last): [snip] File "/home/trhd/Projects/meson/mesonbuild/interpreterbase.py", line 398, in method_call raise InvalidArguments('Variable "%s" is not callable.' % object_name) UnboundLocalError: local variable 'object_name' referenced before assignment Fix this by handling file objects separately.
2017-01-26interpreter: Implement array.get(index, fallback)Nirbheek Chauhan1-2/+14
If the index is out of range, the fallback value is used. Includes a test. Closes #1337
2017-01-23Better error message when using = rather than : for defining keywords.Jussi Pakkanen1-2/+8
2017-01-18cleanup: Remove redundant parenthesesMike Sinkovsky1-2/+2
2017-01-11style: [E303] too many blank lines (2)Mike Sinkovsky1-1/+0
2017-01-11style: [E712] comparison to True should be 'if cond is True:' or 'if cond:'Mike Sinkovsky1-3/+3
2017-01-01style: fix E225 violationsIgor Gnatenko1-1/+1
E225: missing whitespace around operator Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19tree-wide: remove blank lines at EOFIgor Gnatenko1-1/+0
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>