Commit Graph

46 Commits

Author SHA1 Message Date
Xavier Claessens 7902d2032d Refactor handling of machine file options
It is much easier to not try to parse options into complicated
structures until we actually collected all options: machine files,
command line, project()'s default_options, environment.
2020-10-16 17:42:24 -04:00
Daniel Mensinger 7c377e5a5d intro: Add extra_files key to intro output (fixes #7310) 2020-10-15 01:56:59 +03:00
Dylan Baker ce04a279ae ast/introspection: Fix typing violation due to untyped functions
When we add type annotations to this in compilers this will break,
unless we've already filtered out the non-string arguments.
2020-09-24 12:14:13 -07:00
Dylan Baker 4c2d0eb9bc
Merge pull request #7657 from mensinda/moreTyping
typing: Strict type annotations
2020-09-09 10:31:52 -07:00
Jon Turney d712c86a62
Implement add_languages(native:) in introspector 2020-09-09 13:38:59 +01:00
Daniel Mensinger 1743f636fd
typing: fix LGTM bot error 2020-09-08 20:15:59 +02:00
Daniel Mensinger e681235e5f
typing: fix code review 2020-09-08 20:15:58 +02:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Daniel Mensinger 3489442848
typing: completely type ast 2020-09-08 20:15:55 +02:00
Jon Turney f94e1eed97
Factor out an _add_languages() function in introspector
Factor out an _add_languages() function in introspector, rather than
calling func_add_languages() with arguments crafted to fake an
interpreter call.
2020-09-08 18:01:41 +01:00
Dylan Baker 591e6e94b9 Put machine file and cmd line parsing in Environment
This creates a full set of option in environment that mirror those in
coredata, this mirroring of the coredata structure is convenient because
lookups int env (such as when initializing compilers) becomes a straight
dict lookup, with no list iteration. It also means that all of the
command line and machine files are read and stored in the correct order
before they're ever accessed, simplifying the logic of using them.
2020-08-01 22:00:06 -07: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 ad5df1b9c3
types: Annotate ast/introspection.py 2020-03-02 10:44:01 +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 fc800a2cb8 mintro: Add version key to --scan-dependencies (fixes #6287) 2019-12-10 20:17:21 +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
Daniel Mensinger b72b5365af mintro: Fix crash related to the sources kwarg (fixes #5741) 2019-07-31 00:30:17 +03:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Daniel Mensinger cacc585b44 ast: fix #5376 2019-05-13 02:48:35 +03:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Daniel Mensinger 2bb4ec19f2
ast: resolve ID nodes in flatten_args 2019-04-23 09:10:42 +02:00
Dylan Baker add821db64 Don't use mutable types as default arguments
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,

def in(value: str, container: Optional[List[str]]) -> boolean:
   return src in (container or [])

if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):

def add(value: str, container: Optional[List[str]]) -> None:
    container = container if container is not None else []
    container.append(value)

I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
2019-04-23 02:03:19 +03:00
Daniel Mensinger 6da0df95c1
mintro: fix some interpreter crashes 2019-04-02 11:39:45 +02:00
Daniel Mensinger 1937bbafac
mintro: Fix crash when required is a function (closes #5177) 2019-04-02 11:21:05 +02:00
Daniel Mensinger e724fd5438
rewriter: Handle duplicate target 2019-03-04 13:00:29 +01:00
Daniel Mensinger 586ec5a28c
intro: Fixed code after rebase 2019-03-03 23:23:50 +01:00
Daniel Mensinger f9b41d5ecb
mintro: Dependencies from source 2019-03-03 23:19:03 +01:00
Daniel Mensinger 8a1411a1e8
Target introspection from source 2019-03-03 23:19:03 +01:00
Daniel Mensinger 7f9fb6a084 rewriter: Minor code cleanup 2019-03-03 20:25:07 +02:00
Daniel Mensinger bd5d54513c rewriter: Handle Arithmetic node 2019-03-03 20:25:07 +02:00
Daniel Schulte f0b0bcf86d mintro: Add subproject_dir to --projectinfo 2019-03-01 23:40:33 +02:00
Daniel Mensinger 4bf1a352cc mconf: Fixed crash for variables in targets (closes #4960) 2019-02-26 18:40:45 +02:00
Daniel Mensinger 24a2cf02e2
Can now find the assignment node of a value 2019-02-16 14:10:08 +01:00
Jussi Pakkanen 939b011114
Merge pull request #4858 from mensinda/rwKWARGS
rewriter: Add support for kwargs modification
2019-02-16 14:17:49 +02:00
Dylan Baker 5b896ed70b allow setting directory locations in a native file
This allows the person running configure (either a developer, user, or
distro maintainer) to keep a configuration of where various kinds of
files should end up.
2019-02-11 12:50:32 -08:00
Daniel Mensinger 8c364952af
Added dependecy kwargs support 2019-01-31 15:57:02 +01:00
Daniel Mensinger 5655865246
Added test case 2019-01-31 15:43:04 +01:00
Daniel Mensinger 8224ecfbe6
Some fixes and assignment based target find 2019-01-31 15:43:04 +01:00
Daniel Mensinger 6fe2c2b209
Fixed flake8 issues 2019-01-22 17:31:15 +01:00
Daniel Mensinger 86d5799bc4
First rewriter test case 2019-01-22 16:41:06 +01:00
Daniel Mensinger 08da3873dd
Added target AST Interpreter support 2019-01-22 16:09:35 +01:00
Daniel Mensinger 750af9c853
Moved the introspection interpreter 2019-01-22 16:09:34 +01:00