aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/ast/introspection.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-28Add support for meson.options as a replacement for meson_options.txtDylan Baker1-3/+5
We will still try to load `meson_options.txt` if `meson.options` doesn't exist. Because there are some advantages to using `meson.options` even with older versions of meson (such as better text editor handling) we will not warn about the existence of a `meson.options` file if a `meson_options.txt` file or symlink also exists. The name `meson.options` was picked instead of alternative proposals, such as `meson_options.build` for a couple of reasons: 1. meson.options is shorter 2. While the syntax is the same, only the `option()` function may be called in meson.options, while, it may not be called in meson.build 3. While the two files share a syntax and elementary types (strings, arrays, etc), they have different purposes: `meson.build` declares build targets, `meson.options` declares options. This is similar to the difference between C's `.c` and `.h` extensions. As an implementation detail `Interpreter.option_file` has been removed, as it is used exactly once, in the `project()` call to read the options, and we can just calculate it there and not store it. Fixes: #11176
2023-03-14rewriter: fix warning about empty sourcesCharles Brunet1-0/+1
2023-01-29introspect: avoid crashing when add_languages for an optional language failsEli Schwartz1-6/+16
Because that is what the real interpreter does, too. It logs a failure and carries on.
2022-11-30pylint: enable the set_membership pluginDylan Baker1-1/+1
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-06-13flake8: fix various whitespace nitsEli Schwartz1-1/+0
2022-06-01ast: rename module constant to match PEP8 styleDylan Baker1-2/+7
2022-06-01ast/introspection: tidy up imports a bit more with __future__.annotationsDylan Baker1-3/+8
This lets us not import quite as much at runtime
2022-06-01ast/introspection: sort importsDylan Baker1-9/+10
2022-03-24Make compilers list per subprojectXavier Claessens1-1/+4
Previously subprojects inherited languages already added by main project, or any previous subproject. This change to have a list of compilers per interpreters, which means that if a subproject does not add 'c' language it won't be able to compile .c files any more, even if main project added the 'c' language. This delays processing list of compilers until the interpreter adds the BuildTarget into its list of targets. That way the interpreter can add missing languages instead of duplicating that logic into BuildTarget for the cython case.
2022-03-22interpreter: Make compiler options per-subprojectXavier Claessens1-1/+10
2022-03-07build: plumb structured sources into BuildTargetsDylan Baker1-1/+1
2021-08-31pylint: turn on superflous-parensDylan Baker1-1/+1
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-06-25Split compiler detection from EnvironmentDaniel Mensinger1-1/+2
This moves all the compiler detection logic into the new compilers.detect module. This dramatically reduces the size and complexity of Environment.
2021-01-04Use a single coredata dictionary for optionsDylan Baker1-2/+2
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-04move OptionKey to mesonlibDylan Baker1-2/+2
There's starting to be a lot of things including coredata that coredata needs to itself include. putting it in mesonlib makes more sense
2021-01-04use new optionkey.is_* methodsDylan Baker1-1/+1
2021-01-04use the OptionKey type for command line and machine filesDylan Baker1-3/+3
2020-10-16Refactor handling of machine file optionsXavier Claessens1-1/+1
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-15intro: Add extra_files key to intro output (fixes #7310)Daniel Mensinger1-29/+39
2020-09-24ast/introspection: Fix typing violation due to untyped functionsDylan Baker1-7/+8
When we add type annotations to this in compilers this will break, unless we've already filtered out the non-string arguments.
2020-09-09Merge pull request #7657 from mensinda/moreTypingDylan Baker1-3/+8
typing: Strict type annotations
2020-09-09Implement add_languages(native:) in introspectorJon Turney1-2/+7
2020-09-08typing: fix LGTM bot errorDaniel Mensinger1-0/+4
2020-09-08typing: fix code reviewDaniel Mensinger1-1/+1
2020-09-08typing: more fixesDaniel Mensinger1-1/+2
2020-09-08typing: completely type astDaniel Mensinger1-3/+3
2020-09-08Factor out an _add_languages() function in introspectorJon Turney1-11/+15
Factor out an _add_languages() function in introspector, rather than calling func_add_languages() with arguments crafted to fake an interpreter call.
2020-08-01Put machine file and cmd line parsing in EnvironmentDylan Baker1-1/+1
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-03-05mesonbuild/mesonlib: Add type annotationsDylan Baker1-2/+2
2020-03-02types: Remove redundant __init__() -> None annotationDaniel Mensinger1-2/+2
2020-03-02types: Use import typing as TDaniel Mensinger1-24/+24
2020-03-02types: Annotate ast/introspection.pyDaniel Mensinger1-36/+56
2020-03-02types: Annotate ast/interpreter.pyDaniel Mensinger1-4/+3
2020-03-02types: Annotate the AST visitorsDaniel Mensinger1-3/+2
2019-12-10mintro: Add version key to --scan-dependencies (fixes #6287)Daniel Mensinger1-1/+6
2019-11-06Fix typos found by codespellWolfgang Stöggl1-2/+2
- Typos were found by codespell v1.16.0
2019-07-31mintro: Fix crash related to the sources kwarg (fixes #5741)Daniel Mensinger1-2/+6
2019-06-09Purge `is_cross` and friends without changing user interfacesJohn Ericson1-7/+8
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-05-13ast: fix #5376Daniel Mensinger1-1/+1
2019-04-29Fix builtin variable namesDaniel Mensinger1-3/+3
2019-04-29Fix blind exceptionsDaniel Mensinger1-1/+1
2019-04-23ast: resolve ID nodes in flatten_argsDaniel Mensinger1-3/+4
2019-04-23Don't use mutable types as default argumentsDylan Baker1-1/+2
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-02mintro: fix some interpreter crashesDaniel Mensinger1-1/+3
2019-04-02mintro: Fix crash when required is a function (closes #5177)Daniel Mensinger1-0/+2
2019-03-04rewriter: Handle duplicate targetDaniel Mensinger1-3/+4
2019-03-03intro: Fixed code after rebaseDaniel Mensinger1-1/+1
2019-03-03mintro: Dependencies from sourceDaniel Mensinger1-0/+8
2019-03-03Target introspection from sourceDaniel Mensinger1-2/+4
2019-03-03rewriter: Minor code cleanupDaniel Mensinger1-12/+13